NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: scmaccal on October 01, 2013, 05:00:16 PM
-
Greetings,
I would like to see how: times 510-($-$$) db 0 and db works from a assembly language point of view. Is there an option that I can add that will produce the assembly code of these NASM macros(?) when I assemble a program? I just tried the -l option but that was not helpful.
-
It's just a bunch of zeros - sufficient to pad your bootsector (?) out to 510 bytes. (bytes 511 and 512 are the boot signature) Ndisasm would show them... but would try to disassemble them. A hex dump would show them. Not much to see...
Best,
Frank
-
Frank,
Thank you for replying. I did in fact do a disassemble of the binary in question. You are correct, a bunch of zeros. :) So my question now is how would I go about writing the code that does the same as: times 510-($-$$) db 0
by hand. I suspect you may see a theme with this post and the other one that you were kind enough to answer. I want to use as much Intel syntax as possible in my programs. I am doing this because I want to develop a deeper knowledge of how to program in assembly language without relying on the assembler to do the work for me. If I wanted that I would write in C. ;)
Kind regards,
Scott
-
Hi Scott,
Well, literally:
db 0
db 0
db 0
db 0
; enough times
but you could do:
db 0, 0, 0, 0, 0 ; enough times
with the same result.
When I can get both remaining brain cells to fire at the same time, I can do things Nasm can't do. Counting bytes isn't one of them. Nasm can count bytes faster and more accurately than I can. If you've got more brain cells than you know what to do with, you can count 'em yourself of course. I've gotta save my strength! :)
Best,
Frank