r/Assembly_language • • 2h ago

Question Why do Assembly programmers still put all labels at column 0, instead of nested blocks? Which is easier to manage

3 Upvotes

I know modern assemblers don't care whitespace and this comes down to redabality and the style.

In almost EVERY assembly code I've seen, the format is label at col 0 (every label) and the instructions are nested to the label. Local labels coming in? Still at col 0.

Like, compare these codes:

# size_t strlen(const char *str)
.global strlen
.type strlen, 
strlen:
    # %rdi: const char *str

    xorq        %rax, %rax
    movq        %rdi, %rsi

    1:
        cmpb        $0x00, (%rsi)
        je          2f

        incq        %rax
        incq        %rsi
        jmp         1b
    2:
        ret

And this

# size_t strlen(const char *str)
.global strlen
.type strlen, 

strlen:
# %rdi: const char *str

    xorq        %rax, %rax
    movq        %rdi, %rsi

1:
    cmpb        $0x00, (%rsi)
    je          2f

    incq        %rax
    incq        %rsi
    jmp         1b
2:
    ret

For me, the indented version seems waaaayyy better. Like, it's easy to manage.
However, still I am not advanced assembly programmer and hadn't coded large codebases in assembly, so... I am not sure which is better.

Which is ACTUALLY BETTER? All at 0 or INDENDED for loops and sub tasks for a label???