NASM - The Netwide Assembler

NASM Forum => Using NASM => Topic started by: ThatGuy22 on December 16, 2010, 07:30:37 PM

Title: resb help
Post 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?
Title: Re: resb help
Post by: Keith Kanios on December 16, 2010, 07:32:33 PM
RESB and Friends @ NASM Manual (http://www.nasm.us/doc/nasmdoc3.html#section-3.2.2)
Title: Re: resb help
Post by: ThatGuy22 on December 16, 2010, 08:57:07 PM
ok I read it and I still don't understand why I get a warning. From what it says it only takes 1 operand.
Title: Re: resb help
Post by: Keith Kanios on December 16, 2010, 09:15:44 PM
Quote from: NASM Manual Section 3.2.2
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.
Title: Re: resb help
Post by: Frank Kotler on December 17, 2010, 01:33:04 PM
Sounds good if you say it quick...

Code: [Select]
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...

Code: [Select]
; 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

Title: Re: resb help
Post by: ThatGuy22 on December 17, 2010, 02:11:43 PM
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?
Title: Re: resb help
Post by: Frank Kotler on December 17, 2010, 04:00:52 PM
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"...

Code: [Select]
; 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

Title: Re: resb help
Post by: ThatGuy22 on December 17, 2010, 05:26:03 PM
ok, thanks