DB
allocates in chunks of 1 byte.
DW
allocates in chunks of 2 bytes.
DD
allocates in chunks of 4 bytes.
DQ
allocates in chunks of 8 bytes.
So I assume that:
RESB 1
allocates 1 byte.
RESW 1
allocates 2 bytes.
RESD 1
allocates 4 bytes.
RESQ 1
allocates 8 bytes.
Am I correct?
The documentation doesn't say much:
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
wordvar: resw 1 ; reserve a word
realarray resq 10 ; array of ten reals
ymmval: resy 1 ; one YMM register
zmmvals: resz 32 ; 32 ZMM registers
To reserve memory for uninitialized data, the following directives are used: RESB – Reserves 1 byte. RESW – Reserves 2 bytes or a Word. RESD – Reserves 4 bytes or a Doubleword. RESQ – Reserves 8 bytes or a Quadword.
3.2 Pseudo-Instructions The current pseudo-instructions are DB , DW , DD , DQ and DT , their uninitialised counterparts RESB , RESW , RESD , RESQ and REST , the INCBIN command, the EQU command, and the TIMES prefix.
Looking at the nasm source, it looks like: 'oword'/'DO' is 8 times as big as "word" (O for "octoword"), synonymous with dqword ("double-quad"); that would be 128 bits, corresponding to the size of an SSE vector register. 'tword'/'DT' is 80 bits (T for "ten bytes"), the full size of an Intel x87 floating point register.
Am I correct?
yes.
The size suffixes are consistent throughout NASM, for d*
and res*
. They match x86 instruction mnemonic suffixes for byte to qword. (e.g. psubd
works with packed dword elements).
There's even an instruction mnemonic that uses o
(oct-word): cqo
.
y and z size suffixes obviously match ymm and zmm register sizes, even though the instruction mnemonics are now things like VBROADCASTI32X8
because of AVX512 masking granularity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With