Reputation: 213
.data
myarray BYTE "Hi there",0
myarray_len EQU $-myarray
myarray2 BYTE myarray_len DUP(' '); sets myarray_len number of
; bytes to be equal to ' '
I am trying to figure out what the second line in the above code does
myarray_len EQU $-myarray
I know its creating an item called myarray_len
and that EQU
will set the left side of that statement to the the right side similar to a #define in C++. I am not sure what the $-myarray
does. Based on the rest of the code I could probably guess but that wouldn't help me a ton since I still wouldn't know what both symbols are doing. I looked on this site and on several places on google and wikipedia, I know its a dumb simple question but I just couldn't find the answer. I assume that the $
has something to do with creating space in memory since its also used in str$
but not sure what '-' does.
Upvotes: 2
Views: 187
Reputation: 490048
$
stands for the current address as the assembler is allocating space in the data segment. So, in this case it's subtracting the address at the end of myarray
from the address at the beginning of myarray
, to give the length of myarray
.
Then myarray2
is allocating the same amount of memory, but filling it with space characters.
Upvotes: 3