Continue with the divide by zero handler.
As you can see we have added push and pop instructions. What the push instructions do is saving the state of cpu
when interrupt or exception occurs.
When that happens, only some of registers are saved, such as rip and rsp registers.
In the handler, we will use and modify registers to perform specific tasks.
Therefore when we return from the handler, the value of registers may have changed
of CPU is not the same as it was before the entropic and the state of cpu is not the same as it was before the interrupt occurs.
So in order to restore the state of cpu after the interrupt handling is done, we store all the general purpose registers
on the stack.
In 64-bit mode, we have 16 general purpose registers. Rsp is pushed on the stack
when cpu calls the handler,
So here we push 15 registers.
After we handle the interrupt, we pop the original value in those registers and return.
Stack is like a last-in first-out structure. So we pop the value on the stack in reverse order.
Ok now, if the interrupt is fired, the handler will save all the general purpose registers first,
do its work and then pop the value on the stack back to those registers.
When we return from the handler, the previous work CPU is doing is resumed just like the interrupt never happened.
As you see, when divided by zero handler is called, we just stop here. So we don�t test the code in this lecture
.
In next video, we will discuss the timer interrupt and test it in that example.
That's it for this lecture.
See you in the next video.