这个问题在这里已经有了答案:
What are the sizes of tword, oword and yword operands?
(2 个回答)
4年前关闭。
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?
是的。
大小后缀在整个 NASM 中是一致的,例如
d*
和 res*
.它们将字节到 qword 的 x86 指令助记符后缀匹配。 (例如 psubd
适用于压缩双字元素)。甚至还有一个指令助记符使用
o
(八字): cqo
.y 和 z 大小后缀显然与 ymm 和 zmm 寄存器大小匹配,即使指令助记符现在类似于
VBROADCASTI32X8
因为 AVX512 屏蔽粒度。
关于assembly - RESB、RESW、RESD、RESQ在NASM中分配了多少字节?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44860003/