RESB、RESW、RESD、RESQ在NASM中分配了多少字节?
How many bytes do RESB, RESW, RESD, RESQ allocate in NASM?
DB
以 1 字节为单位分配。
DW
分配 2 个字节的块。
DD
以 4 字节为单位分配。
DQ
以 8 字节为单位分配。
所以我假设:
RESB 1
分配 1 个字节。
RESW 1
分配 2 个字节。
RESD 1
分配 4 个字节。
RESQ 1
分配 8 个字节。
我说得对吗?
这个documentation就不多说了:
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
Am I correct?
是的。
对于 d*
和 res*
,尺寸后缀在整个 NASM 中是一致的。它们将 byte 到 qword 的 x86 指令助记符后缀匹配。 (例如 psubd
适用于打包的双字元素)。
甚至还有一个使用o
(八进制字)的指令助记符:cqo
.
y 和 z 大小后缀显然匹配 ymm 和 zmm 寄存器大小,即使由于 AVX512 屏蔽粒度,指令助记符现在类似于 VBROADCASTI32X8
。
DB
以 1 字节为单位分配。
DW
分配 2 个字节的块。
DD
以 4 字节为单位分配。
DQ
以 8 字节为单位分配。
所以我假设:
RESB 1
分配 1 个字节。
RESW 1
分配 2 个字节。
RESD 1
分配 4 个字节。
RESQ 1
分配 8 个字节。
我说得对吗?
这个documentation就不多说了:
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
Am I correct?
是的。
对于 d*
和 res*
,尺寸后缀在整个 NASM 中是一致的。它们将 byte 到 qword 的 x86 指令助记符后缀匹配。 (例如 psubd
适用于打包的双字元素)。
甚至还有一个使用o
(八进制字)的指令助记符:cqo
.
y 和 z 大小后缀显然匹配 ymm 和 zmm 寄存器大小,即使由于 AVX512 屏蔽粒度,指令助记符现在类似于 VBROADCASTI32X8
。