问题描述
8086微处理器在堆栈已满并且什至在我将某些东西推入其中时会如何处理?
What'll be the behaviour of the 8086 Microprocessor when the stack is full and even then I push something into it?
推荐答案
在8086上,PUSH指令或隐式堆栈推入将SP寄存器减2,并在SS:SP处存储适当的数量(即16 * SS + SP).如果SP寄存器为$ 0000,则数据将进入SS:$ FFFE.如果SP寄存器为$ 0001,则数据的MSB将到达SS:$ 0000,而LSB将到达SS:$ FFFF.处理器不会对堆栈回绕有任何特别的注意.尽管堆栈环绕通常是一件坏事,但8086在某些情况下可以忽略不影响任何事情.例如,如果SS指向不需要其他任何东西的64K RAM,而一个永不退出的程序有时会通过简单地调用"main()"而不重新设置堆栈来重新启动自身,则堆栈可以绕回而无需由于所有有效地址的计算都将以相同的方式进行环绕,因此会影响程序的运行.
On the 8086, a PUSH instruction or implicit stack push will decrement the SP register by two and store the appropriate quantity at SS:SP (i.e. 16*SS+SP). If the SP register was $0000, the data will go to SS:$FFFE. If the SP register was $0001, the MSB of the data will go to SS:$0000 and the LSB will go to SS:$FFFF. The processor will not take any special notice of the stack wraparound. While stack wraparound would typically be a bad thing, there are some situations on the 8086 where it could be ignored at wouldn't affect anything. For example, if SS pointed to 64K of RAM that wasn't needed for anything else, and a program which was never going to exit sometimes restarted itself by simply calling "main()" without resetting the stack, the stack could wrap around without affecting program operation, since all effective-address calculations would wrap around the same way.
请注意,在80386及更高版本的处理器上,堆栈下溢行为已更改. PUSH,CALL等使用32位(或64位)地址计算,而不是16位,并且将它们包装为$ FFFFFFFF(或$ FFFFFFFFFFFFFFFFFF)而不是$ FFFF.
Note that on the 80386 and later processors, the stack-underflow behavior is changed. PUSH, CALL, etc. use 32-bit (or 64-bit) address calculations, rather than 16-bit, and those wrap to $FFFFFFFF (or $FFFFFFFFFFFFFFFF) rather than $FFFF.
这篇关于8086微处理器的堆栈溢出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!