Although there are lots of C and C++ style guides to choose from, I've not been able to find anything for assembler. Has anyone come across one?
I've looked at the linux kernel source, and unlike the C style, I'm not as comfortable using the style used in the assembler code. A couple of my issues with it:
1) Use of local labels (.Lfoo:) means no symbol gets emitted to the .o, making disassembly harder to follow.
2) Heavy use of preprocessor macros (#define FOO ...) instead of using asm macros where possible
I've noticed the v-usb code uses #define and #undef to name registers used in asm functions.
https://github.com/obdev/v-usb/b...
I'd prefer a cleaner way to do it. For example, using one .S file per function would permit dropping the #undefs at the end.
AVR-libc pseudo-instruction macros start with an X_, such as X_sbiw. I have macros I've written such as addi (uses subi with the arg negated), and have thought about using the same pattern.
I also wonder if there isn't a better disassembler I could use instead of avr-objdump. There's lots of things I wish it would do, like display global and local symbols differently. In the code below millis is global and _reload is local.
00000000 <millis>: 0: e0 e0 ldi r30, 0x00 ; 0 2: f0 e0 ldi r31, 0x00 ; 0 00000004 <_reload>: 4: 60 81 ld r22, Z 6: 71 81 ldd r23, Z+1 ; 0x01 8: 82 81 ldd r24, Z+2 ; 0x02 a: 93 81 ldd r25, Z+3 ; 0x03 c: 00 80 ld r0, Z e: 06 16 cp r0, r22 10: 01 f4 brne .+0 ; 0x12 <_reload+0xe> 12: 08 95 ret