NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: ThatGuy22 on December 16, 2010, 07:30:37 PM
-
I use resb to reserve bytes for a buffer for graphics in my DOS program, but I alway get a warning. The warning says something like uninitialized space declared, zeroing. I think it is the format i'm using, I do this:
resb 64000 and I get the warning so I tried this:
resb 64000 db 0x00 and still get it, so how do I format it?
-
RESB and Friends @ NASM Manual (http://www.nasm.us/doc/nasmdoc3.html#section-3.2.2)
-
ok I read it and I still don't understand why I get a warning. From what it says it only takes 1 operand.
-
RESB, RESW, RESD, RESQ, REST, RESO and RESY are designed to be used in the BSS section of a module: they declare uninitialized storage space.
-
Sounds good if you say it quick...
section .BSS
resb 1
How come I still get a warning? Well... the "known" section names are case sensitive, and are expected to be lowercase! The quoted part of the manual doesn't make this clear, and is arguably misleading...
; nasm -f obj myfile.asm
section .data
resb 1
How come I don't get a warning? Well... it's acceptable in "-f obj" output format. Dunno why.
So this brings us, again(!), to the question:
"What command line are you using to assemble this?"
It makes a difference!
Best,
Frank
-
I use "nasm -f bin Program.asm -o Program.com"
So the resb has to be in the .bss section in order to not give that warning?
-
Right. In "-f bin" mode, Nasm merely moves "section .data" after "section .text" and "section .bss" after that - they are not actually in distinct "segments". In a .com file, your stack is above that, at the top of our one-and-only segment - 64000 bytes in ".bss" is going to come awfully close to that, depending on how much code/data is present. This "could" cause mysterious problems as your code grows...
FWIW, if you want all those zeros in your "on-disk file"...
; in "section .text" or "section .data"
times 64000 db 0
... or simply ignore the warning...
Attempting to put initialized code or data in "section .bss" is "ignored" - probably an actual error!
Best,
Frank
-
ok, thanks