In a bootloader, the second last line is :
TIMES 510-($-$$) db 0
Now, will this command also do the same :
db 510-($-$$) DUP (0)
If not why?
I know what TIMES
does, but its not mentioned in my x86 book by Mazidi (Pearson Publication). Any idea why?
And what is the meaning of the $
sign exactly? Different sites have different information about $
.
And is the line TIMES 510-($-$$) db 0
absolutely necessary even if my bootloader code is of 512 bytes in size?
So can anyone help me with these questions?
Best Answer
TIMES
andDUP
are assembler specific commands, and as such aren't part of x86 assembly language. Same goes for$
and$$
.The
$
symbol denotes the current address of the statement, and the$$
denotes the address of the beginning of current section. So the lines withDUP
andTIMES
calculate the current address in the section and subtracts it from 510. This effectively just zeroes out the section from the beginning to the current address.