gpt4 book ai didi

windows - 如何在 NASM 的 BSS 部分创建变量?

转载 作者:行者123 更新时间:2023-12-03 11:06:48 25 4
gpt4 key购买 nike

我试图在 NASM 的 BSS 部分创建一个变量:

section .bss
i DD 12345

但是在尝试创建目标文件时,我收到以下警告:
warning: attempt to initialize memory in BSS section `.bss': ignored

我想这是可以理解的,因为 BSS 部分只能包含未初始化的变量。所以我尝试了以下方法:
section .bss
i DD 0

但我仍然收到同样的警告。

最佳答案

使用 RESB和 friend 。见 nasm manual :

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

关于windows - 如何在 NASM 的 BSS 部分创建变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27909823/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com