汇编 – RESB,RESW,RESD,RESQ在NASM中分配多少字节?

本文详细解析了NASM汇编语言中用于声明未初始化数据的指令RESB、RESW、RESD、RESQ等的使用方法及对应字节数。RESB分配1字节,RESW分配2字节,RESD分配4字节,RESQ分配8字节,适用于BSS段数据声明。此外,还介绍了RESY和RESZ指令与YMM和ZMM寄存器大小的匹配。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参见英文答案 > What are the sizes of tword, oword and yword operands?                                    2个 
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的大小后缀是一致的.它们将字节与xword的x86指令助记符后缀相匹配. (例如psubd使用压缩的dword元素).

甚至还有一个使用o(oct-word):cqo的指令助记符.

y和z大小后缀明显匹配ymm和zmm寄存器大小,即使指令助记符现在像VBROADCASTI32X8因为AVX512屏蔽粒度.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值