4 ms·
My best introduction to any asm language is just my C compiler putting out asm (gcc -S, I think). I can create small programs to do what I want, and see what t
by lallysingh 10y ago
My best introduction to any asm language is just my C compiler putting out asm (gcc -S, I think). I can create small programs to do what I want, and see what the compiler puts out.
- Liblor 10y agohttps://gcc.godbolt.org https://gcc.godbolt.org is also helpful, it colorizes the assembly output corresponding to the C/C++ source. Furthermore, you can simply change between Intel and AT&T synatx.
- pwaring 10y agoThe -S flag also works in clang, although the output may differ. For example, last time I checked a comparison check of i < 10 in a for loop would become: cmpl $9, -4(%rbp) jle .L3 under GCC ('if i <= 9, loop') and: cmpl $10, -8(%rbp) jge .LBB0_4 under clang ('if i >= 10, end the loop'). Neither GCC or clang does an exact conversion, and they both produce different assembly instructions (optimisations disabled in both cases). If you build a cross-compiler, you can also output assembly for architectures other than your local machine, though this can be quite fiddly (see crosstool-ng for a project which has done most of the work for you).