当我尝试组装以下代码时:
push BYTE 0x80
NASM 显示以下警告:
warning: signed byte value exceeds bounds
这是什么意思?请注意,低于 0x80 的值不会导致警告。
最佳答案
PUSH imm8
实际上并没有将一个字节压入堆栈。它至少压入一个字,该字将从字节操作数进行符号扩展。因此,操作数为 0x80
你实际上最终推了 0xff80
, 0xffffff80
或 0xffffffffffffff80
,这很可能是 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
orREX.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/