Reputation: 1119
I tried to create a variable in the BSS section in NASM:
section .bss
i DD 12345
But when trying to create an object file I got the following warning:
warning: attempt to initialize memory in BSS section `.bss': ignored
Which is understandable I suppose since the BSS section can only contain uninitialized variables. So I attempted the following:
section .bss
i DD 0
But I still get the same warning.
Upvotes: 5
Views: 7653
Reputation: 58772
Use RESB
and friends. See the nasm manual:
3.2.2 RESB and Friends: Declaring Uninitialized Data
RESB, RESW, RESD, RESQ, REST, RESO, RESY and RESZ are designed to be used in the BSS section of a module: they declare uninitialized storage space. Each takes a single operand, which is the number of bytes, words, doublewords or whatever to reserve. As stated in section 2.2.7, NASM does not support the MASM/TASM syntax of reserving uninitialized space by writing DW ? or similar things: this is what it does instead. The operand to a RESB-type pseudo-instruction is a critical expression: see section 3.8.
For example:
buffer: resb 64 ; reserve 64 bytes
Upvotes: 6
Reputation: 9
The resb and Friends in nasm manual is used to reserve specific amount of bytes in the BSS section of the cod: section .bss
Notice that this section must be defined in lowercase (bss) in order not to throw the error.
So you may try:
section .bss ; Create the reservation section.
buffer: resb 128 ; Reserve 128 bites of the memory with label "buffer"
Upvotes: 0