为什么不能一个字节推到奔腾IA-32堆栈? [英] Why is it not possible to push a byte onto a stack on Pentium IA-32?
问题描述
我是来学习,你不能直接推到字节英特尔奔腾的堆栈,任何人都可以给我讲解一下好吗?
I've come to learn that you cannot push a byte directly onto the Intel Pentium's stack, can anyone explain this to me please?
这是我一直在给出的原因是因为ESP寄存器字寻址(或者,这是假设在我们的模型),它必须是一个连地址。我会承担一些递减32位二进制数不会与寄存器的排列混乱的价值,但显然我不明白就好了。
The reason that I've been given is because the esp register is word-addressable (or, that is the assumption in our model) and it must be an "even address". I would have assumed decrementing the value of some 32-bit binary number wouldn't mess with the alignment of the register, but apparently I don't understand enough.
我已经尝试了一些NASM测试,并拿出如果我声明一个变量(DB咬123),并将它推到堆栈,ESP是递减4(表明它推32位?)。但是,推字节咬(对不起,我选择的变量名),将导致一种错误:
I have tried some NASM tests and come up that if I declare a variable (bite db 123) and push it on to the stack, esp is decremented by 4 (indicating that it pushed 32-bits?). But, "push byte bite" (sorry for my choice of variable names) will result in a kind error:
TEST.ASM:10:错误:不支持非32位ELF重
test.asm:10: error: Unsupported non-32-bit ELF relocation
智慧的任意一个关键词将是极大的这段乱世pciated AP $ P $。我第一年的本科所以对不起,我在任何的这种天真。
Any words of wisdom would be greatly appreciated during this troubled time. I am first year undergraduate so sorry for my naivety in any of this.
推荐答案
其基于堆栈的创建方式:
Its based on how the stack was created:
的地址大小属性
堆栈段确定堆栈
指针的大小(16位,32位或64位)。该
当前的操作数大小属性
code段确定的金额
堆栈指针(2,4或
8个字节)。
The address-size attribute of the stack segment determines the stack pointer size (16, 32 or 64 bits). The operand-size attribute of the current code segment determines the amount the stack pointer is decremented (2, 4 or 8 bytes).
在非64位模式:如果
地址大小和操作数大小
属性是32,在32位的ESP
注册(堆栈指针)
递减4如果这两个属性
是如图16所示,16位SP寄存器(堆栈
指针)是由2递减。
In non-64-bit modes: if the address-size and operand-size attributes are 32, the 32-bit ESP register (stack pointer) is decremented by 4. If both attributes are 16, the 16-bit SP register (stack pointer) is decremented by 2.
来源: http://www.intel.com/Assets/PDF/手动/ 253667.pdf
皮克。 4-320卷。 2B
pg. 4-320 Vol. 2B
的修改的
只是想也是一个有趣的阅读是手册的有关堆栈的部分指出,这解释了关于创建堆栈段进一步。
Just wanted to point out also that an interesting read is the section on stacks in the manual, it will explain creating a stack segment further.
http://www.intel.com/Assets/PDF/manual/ 253665.pdf
第6.2章
这篇关于为什么不能一个字节推到奔腾IA-32堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!