assembly - RESB、RESW、RESD、RESQ在NASM中分配了多少字节?

标签 assembly x86 nasm

这个问题在这里已经有了答案:





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/

相关文章:

assembly - 将 64 位常量移动到 x86 程序集中的内存中

Linux反汇编程序

c++ - g++ 处理复制 std::complex

assembly - 为什么 ia32/x64 操作码映射文档 0x66 和 0xF2 作为操作码 0x0F38F1 (CRC32) 的双重强制前缀?

linux-kernel - nosmep 和 noexec=off 有什么区别

linux - CPU_ZERO "undefined symbol"在 NASM 中使用 pthread_setaffinity_np

assembly - 在长模式下更改 GDT 并更新 CS

c - 为什么像这样初始化二维数组会更糟​​?

linux - 选择 ARM 或 x86 进行启动

c - 开发 GUI 并加载引导加载程序库