how to use the time prefix

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
jghj
Posts: 1
Joined: Tue Oct 18, 2005 11:00 pm

how to use the time prefix

Post by jghj »

hi guys.

At the moment I'm reading lots about os developing (or first about the bootstrap)
I understand what I have to do, only this two lines I don't understand:

times 510-($-$$) db 0
dw 0AA55h

They resize the file to 512 MB and the last word is 0AA55h.
But i don't understand it. What says 510-$-$$

I didn't find any specification for the times prefix

i hope you'll help me.
Last edited by jghj on Tue Oct 18, 2005 11:00 pm, edited 1 time in total.
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Re: how to use the time prefix

Post by JAAman »

http://nasm.sourceforge.net/doc/html/nasmdoc1.html

this is the complete documentation for nasm it tells all about the times directive -- just look in the table of contents(link on top of page) and you'll find all this information


basically times places something multiple times and is followed by the number of times but we don't know how large the code is and it needs to be exactly 512 bytes -2 for the signature (0xAA55) so we need to fill up to byte 510 with 0 (thats what the db 0 is -- db means Data Byte) $ represents the current place in code -but it doesn't resolve to a number (its dependent on the start address) so nasm uses $$ to represent the starting point (which also doesn't resolve into a number) but when the two are subtracted then nasm uses that as a special case to calculate the offset from start of file

these docs also contain the instruction set reference its easier to get to then the intel manuals but less complete (not as detailed and leaves out some important information about how the instructions operate)
Post Reply