"push BYTE 0x80" 和 "warning: signed byte value exceeds bounds" 在 NASM
"push BYTE 0x80" and "warning: signed byte value exceeds bounds" in NASM
当我尝试assemble以下代码时:
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
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.
当我尝试assemble以下代码时:
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.