given a a label
L1: db "beat it",10,0
L2:
what is the meaning of:
mov eax,L2
sub eax,L1
L2 to register, and sub register from label include string
given a a label
L1: db "beat it",10,0
L2:
what is the meaning of:
mov eax,L2
sub eax,L1
L2 to register, and sub register from label include string
MOV EAX,L2 moves the address the label represents to the register.
Unlike MOV EAX,[L2] which gets a value (the content of the memory) from that address.
It's a pointlessly inefficient way to do at runtime what you should have done at assemble time with mov eax, L2 - L1 to get the number of bytes between those labels. i.e. get the assembler to calculate the sizeof the array for you, instead of hard-coding the constant.
Normally you'd do something like L1_length equ $ - L1 to define an assemble time constant. See How does $ work in NASM, exactly?
But anyway, since the symbol isn't inside [] (and this is NASM, not some other flavour of Intel syntax), L1 is an immediate operand; the absolute address of the symbol (in this case defined by a label).
For example, mov eax, L2 puts the absolute address of the label into EAX, with a mov r32,imm32 instruction.