the meaning of times in nasm
Posted: Tue Oct 21, 2003 2:54 am
I always see the code
times 512-($-$$)-2 db 0
dw 0xaa55
what's the '$','$$' and 2 mean ?
times 512-($-$$)-2 db 0
dw 0xaa55
what's the '$','$$' and 2 mean ?
The Place to Start for Operating System Developers
http://f.osdev.org/
the reason to use ($-$$) rather than $ is that you usually have an 'ORG' directive that makes your section start at a non-zero address.NASM supports two special tokens in expressions, allowing
calculations to involve the current assembly position: the `$' and `$$'
tokens. `$' evaluates to the assembly position at the beginning of the
line containing the expression; so you can code an infinite loop using
`JMP $'. `$$' evaluates to the beginning of the current section; so you
can tell how far into the section you are by using `($-$$)'.