Reputation: 8577
In the next code:
section .data
sa db ’abxdefghxl’,0
la EQU $ - sa
sb db ’abcdexghil’,0
section .text
As I saw in my program, when I do mov ecx, la - then I got the number 11 in ECX.
I didn't understand why - the number of abxdefghxl
is not 10. We also count the 0?
Upvotes: 0
Views: 765
Reputation: 7131
$ represents the current position. And since the current position is after the complete declaration of "sa", the expression $-sa is 11. Remember that in assembly there is no thing like a "string" data type, "sa" is just a collection of bytes.
Upvotes: 1
Reputation: 28525
Assume sa
to start at 0x400
. You have defined 10 ( abxdefghxl
) plus 1 ( 0
at the end ) And hence la
wwould start at 0x40B
. $ represents the current instruction/directive address. Hence $-sa
= 0xB
or 11
Upvotes: 2