1428

Stack Overflow of 8086 microprocessor

Question:

What'll be the behaviour of the 8086 Microprocessor when the stack is full and even then I push something into it?

Answer1:

There is no end. I mean the stack in these processors has a reverse order (from right to left). So it will go on up to a rom block or the end of memory. This causes an exception in the processor wich could soft reset itself.

Answer2:

The 8086 has no 'protected mode', therefore no 'guard page at the bottom of the stack', therefore no well-defined exception. Instead your push will overwrite whatever code or data is below the bottom of the stack, which will eventually (but not immediately) result in "undefined behaviour" if that code is executed or that data is used.

Answer3:

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.

Note that on the 80386 and later processors, the stack-underflow behavior is changed. PUSH, POP, CALL, RET, etc. use ESP rather than SP, and ESP wraps to $FFFFFFFF rather than $FFFF.

Recommend

  • Converting to JPEG given image data and UTI
  • How do you close open files using Swift?
  • How to load shared libraries symbols for remote source level debugging with gdb and gdbserver?
  • Pattern combining type test and literal
  • Update web.config file in asp.net
  • Using bitbake is it possible to have a different do_install for a package based on the target image?
  • Meteor: Block access to application if user's email is not verified
  • Authentication - JavaScript - Logout issue
  • Dealing with XElement null value
  • Can I use worksheet_change for a specific column only?
  • phpmailer - How to verify a sent email arrived at its destination
  • Problem in concatenation of objects in javascript
  • Using an STL Iterator without initialising it
  • Enumerating Controls on a Form
  • order post according to custom array position
  • Silverlight DependencyProperty.SetCurrentValue Equivalent
  • Why Encoding.ASCII != ASCIIEncoding.Default in C#?
  • How to use carriage return with multiple line?
  • one Local Olampyad Questions on Informatic in 2011
  • Avoid links criss cross / overlap in d3.js using force layout
  • What is the “return” in scheme?
  • htaccess rewriting URLs with multiple forward slashes
  • Display Images one by one with next and previous functionality
  • Web-crawler for facebook in python
  • php design question - will a Helper help here?
  • How do I rollback to a specific git commit
  • A cron job substitute?
  • KeystoneJS: Relationships in Admin UI not updating
  • AngularJs get employee from factory
  • Acquiring multiple attributes from .xml file in c#
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • embed rChart in Markdown
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Authorize attributes not working in MVC 4
  • How can I remove ASP.NET Designer.cs files?
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • How can I use `wmic` in a Windows PE script?
  • Unable to use reactive element in my shiny app
  • java string with new operator and a literal
  • Net Present Value in Excel for Grouped Recurring CF