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.