At this point we received the interrupt only once. Because we jump to end right
after we enter the timer handler.
The timer interrupt is configured as reoccurring interrupt which is fired every 10ms.
If the handler returns instead of jumping to label end, we will receive interrupts again and again.
So our interrupt handler will be called very 10ms. The printing character here need to be changed,
otherwise only character T is printed,
and we cannot tell if the interrupt is fired multiple times. So we increment the value of the character
each time the handler is called.
We use instruction increment.
We will see the character is changing.
Also, when handling the hardware interrupt, we need to acknowledge the interrupt before we return from the handler,
otherwise we will not receive the interrupt again. To acknowledge the interrupt,
we write the value
to the command register of the PIC.
The bit 5 of the value is non-specific end of interrupt.
We set it to 1.
So the value we use is 20.
We remove jump instruction and move al 20.
then we write it to the command register of the master.
Ok, when the handler returns now, the timer interrupt will fire periodically and we will see the character is changing
.
Let's test it out.
OK, as you see the third character is changing.
Now, let's do another test.
In the use entry, we remove the code of privilege test.
The next thing we are going to do is we are going to increment the character in the user entry
so that we can see the control is transferring between user entry and timer handler constantly.
When the timer handler is called, the processor pushes rsp rip of the previous tasks on the stack
and we return from the handler, those registers value will be restored so that the previous tasks continues
.
In this case, we will go back to the code in the user entry after the handler returns.
In order to see we actually return to where it was interrupted,
we also increment the character.
We show the characters in white color.
Also, we need to jump to the beginning of the user entry so that we will loop through the code.
if everything goes well, we should see the characters are changing in two different locations on the screen
.
Let's check it out.
OK, as you can see, we have two set of characters changing on the screen.
This is testing on the real machine and it works.
That's it for this lecture.
See you in the next video.