为什么在 Pentium IA-32 上不能将一个字节压入堆栈? [英] Why is it not possible to push a byte onto a stack on Pentium IA-32?

查看:26
本文介绍了为什么在 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 测试,发现如果我声明一个变量(bite 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

在这个困难时期,我们将不胜感激任何智慧之言.我是本科一年级,很抱歉我在这方面的天真.

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 位).这当前的操作数大小属性代码段决定了数量堆栈指针递减(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

pg.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 章

这篇关于为什么在 Pentium IA-32 上不能将一个字节压入堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆