Why is it important for a stack to be a FILO structure for the services of interrupts in a microprocessor?

StackOverflow https://stackoverflow.com/questions/16362059

  •  14-04-2022
  •  | 
  •  

Question

I am trying to understand stacks and their implementations, but the most thing that has been bugging me is "Why is it important for a stack to be a FILO structure for the services of interrupts in a microprocessor?" What do I need to understand first before I can understand the Stack concept. Can anyone please give me a comprehensive explanation on this. Thank you

Was it helpful?

Solution

FILO is useful because it allows for data within the stack to be restructured before it is accessed. Specifically, FILO allows things to be reliably reversed. If you have a situation where inner elements are returned before outer elements (as might be common with recursion) then the FILO is perfect.

http://www.i-programmer.info/babbages-bag/263-stacks.html?start=2 Has an excellent explanation of the utility of the FILO paradigm.

As for interrupts, again the utility is that subroutines will call an interrupt before anything else.

There are actually a few reasons that FILO can be useful for interrupts. http://www.eee.metu.edu.tr/~cb/e447/Chapter%204%20-%20v2.0.pdf has an introduction to the concepts. One example would be when it is desirable for registers to be pulled from a program and restored to a program in reverse order.

This article has an animation that demonstrates the exact utility of FILO: http://users.ece.utexas.edu/~valvano/assmbly/stack.htm

OTHER TIPS

When an interrupt is being called it stores the current content + next instruction address on stack.

suppose you encounter one nested interrupt (i.e interrupt within interrupt) then you will require to store things in sequence like data + next address of 1st interrupt on encountering 1st interrupt, executing few instruction there and again encountering next interrupt, here you will require to store data + address of 2ndinterrupt. while returning you will go back to last address where interrupt was called from there again completion of that interrupt you will return to 1st interrupt (FILO).

Hence we use FILO.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top