4 ms·
Start with the Godbolt Compiler Explorer (godbolt.org). Start by looking at the assembly generated for something you understand and learn to read assembly from
by CalChris 5y ago
Start with the Godbolt Compiler Explorer (godbolt.org).
Start by looking at the assembly generated for something you understand and learn to read assembly from that. For example, this is an absolute function:
https://godbolt.org/z/356P1j56W https://godbolt.org/z/356P1j56W
Try taking out that -O3 and see what happens. Just edit it out and hit return. Oh, you may have to Google sxtb but I think you might be able to guess what it means. You'll probably end up looking up instructions in the ISA manual. I do that all the time, even for instructions I 'know'. This is the A64 manpage for sxtb.
https://developer.arm.com/documentation/dui0801/g/A64-General-Instructions/SXTB https://developer.arm.com/documentation/dui0801/g/A64-Genera...
I read a thousand times more assembly than I write, and I write assembly. BTW, Godbolt should be taught in 61C type courses. I just checked and it isn't.
- b3morales 5y agoGodbolt is great, but you may as well just do it locally. For example, for clang or gcc, pass `-S` to output asm and `-g` for debug information, which will embed comments in the output to point back to the original source lines that generated that result. Other compilers should have similar options -- this is what Godbolt is doing under the hood.
- CalChris 5y agoOf course you can do it locally. But you can share a Godbolt link. If you are asking or explaining something on StackExchange, Godbolt is the standard. You can document implementation decisions with Godbolt links in source code (LLVM 13 has 8 of them). You can share them on the Discord LLVM channels or in github reviews. You can examine how the assembly changes by release and optimization level with Godbolt. You compare GCC vs LLVM vs Intel vs ... You can look at how other targets work, arm64 vs x86_64 vs ....