assembly - NASM 中的 "push BYTE 0x80"和 "warning: signed byte value exceeds bounds"

标签 assembly x86 nasm

当我尝试组装以下代码时:

push BYTE 0x80

NASM 显示以下警告:
warning: signed byte value exceeds bounds

这是什么意思?请注意,低于 0x80 的值不会导致警告。

最佳答案

PUSH imm8实际上并没有将一个字节压入堆栈。它至少压入一个字,该字将从字节操作数进行符号扩展。因此,操作数为 0x80你实际上最终推了 0xff80 , 0xffffff800xffffffffffffff80 ,这很可能是 NASM 警告您的内容。

这在 Intel's manual 中有描述:

The D flag in the current code-segment descriptor determines the default operand size; it may be overridden by instruction prefixes (66H or REX.W).
The operand size (16, 32, or 64 bits) determines the amount by which the stack pointer is decremented (2, 4 or 8).
If the source operand is an immediate and its size is less than the operand size, a sign-extended value is pushed on the stack.

关于assembly - NASM 中的 "push BYTE 0x80"和 "warning: signed byte value exceeds bounds",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27957075/

相关文章:

assembly - 是否可以将汇编语言转换为 LLVM IR,对其进行优化,然后将其重新编译为不同的体系结构?

c - 有助于理解 C 和 C++ 中#define、const 和 enum 在汇编级别上的差异

c - 如何将 32 位 float 转换为 8 位有符号字符? (4 :1 packing of int32 to int8 __m256i)

assembly - 使用 stat 系统调用获取文件大小

linux - 我的自旋锁有问题吗?

c++ - 具有 "aggressive"可变语义的 C 和 C++ 编译器

assembly - 使用 NASM 在 64 位模式下不支持 pop 指令?

nasm - 旧dos组件中的硬件VGA文本模式IO问题

macos - 非法指令 : 4 (Mac 64-bit, NASM)

c - 汇编局部变量和寄存器