Compiler Explorer

Saw this article on hackaday

For this site:

https://godbolt.org/

Which is a web ide that outputs live assembly. The cool thing is you can choose from tons of different frameworks. I was scrolling through the options and it’s mostly GCC and x86 stuff but then I got to these:

Dang! So close, too bad it doesn’t have Arduino Leonardo. How different is the code compile though? Theoretically shouldn’t the C++ code be mostly compatible? Not really sure if the 32u4 and 328 have wildly different command sets.

I guess it would be missing all the usb stuff…

Any ideas maybe it’s possible to do something like this or try to get them to somehow get the leonardo supported too? Maybe this would have been way more helpful back in the beginning development! :slight_smile:

AVR GCC is good enough for analysing arbitrary C++ code.

GCC also already comes with an ‘objdump’ tool that spits out assembly code.
Not quite as user-friendly, but if you really want to look at a program’s assembly it can probably handle more code than godbolt.


Also:

They’re pretty much the same.
The IO registers change, the ROM & RAM location & size changes, but the CPU is the same avr5 core.

https://www.nongnu.org/avr-libc/user-manual/using_tools.html

So the code output by gcc should be identical (other than addresses changing).

1 Like

What would this mean for the future of Arduboy?

When I was looking at this before I was using AVR gcc 5.4.0 from the drop down (this is the same gcc version as shipped with Arduino 1.8.7) and the following compiler switches

-Wall -Wextra -Os -mmcu=atmega32u4

This should more or less generate the same code as building using the Arduino IDE. Note that you can’t include Arduino libraries.

Someone could always contact Matt Goldbolt and ask if he could add a preset for Arduboy?

2 Likes

I’ve used CE a few times, but I find it’s more useful to have a full disassembly than trying to look at a snippet. GCC might do things differently in the context of a full program.

2 Likes