Author Topic: resb help  (Read 16455 times)

Offline ThatGuy22

  • Jr. Member
  • *
  • Posts: 40
resb help
« 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?

Offline Keith Kanios

  • Full Member
  • **
  • Posts: 383
  • Country: us
    • Personal Homepage
Re: resb help
« Reply #1 on: December 16, 2010, 07:32:33 PM »

Offline ThatGuy22

  • Jr. Member
  • *
  • Posts: 40
Re: resb help
« Reply #2 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.

Offline Keith Kanios

  • Full Member
  • **
  • Posts: 383
  • Country: us
    • Personal Homepage
Re: resb help
« Reply #3 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.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2616
  • Country: us
Re: resb help
« Reply #4 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


Offline ThatGuy22

  • Jr. Member
  • *
  • Posts: 40
Re: resb help
« Reply #5 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?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2616
  • Country: us
Re: resb help
« Reply #6 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


Offline ThatGuy22

  • Jr. Member
  • *
  • Posts: 40
Re: resb help
« Reply #7 on: December 17, 2010, 05:26:03 PM »
ok, thanks