1 00:00:00,240 --> 00:00:06,720 At this point we received the interrupt only once. Because we jump to end right 2 00:00:06,720 --> 00:00:07,570 after we enter the timer handler. 3 00:00:08,160 --> 00:00:13,680 The timer interrupt is configured as reoccurring interrupt which is fired every 10ms. 4 00:00:14,040 --> 00:00:19,560 If the handler returns instead of jumping to label end, we will receive interrupts again and again. 5 00:00:20,430 --> 00:00:26,820 So our interrupt handler will be called very 10ms. The printing character here need to be changed, 6 00:00:26,970 --> 00:00:29,210 otherwise only character T is printed, 7 00:00:29,760 --> 00:00:35,940 and we cannot tell if the interrupt is fired multiple times. So we increment the value of the character 8 00:00:35,940 --> 00:00:37,530 each time the handler is called. 9 00:00:40,550 --> 00:00:42,620 We use instruction increment. 10 00:00:45,210 --> 00:00:46,960 We will see the character is changing. 11 00:00:47,430 --> 00:00:52,620 Also, when handling the hardware interrupt, we need to acknowledge the interrupt before we return from the handler, 12 00:00:52,620 --> 00:00:58,350 otherwise we will not receive the interrupt again. To acknowledge the interrupt, 13 00:00:59,040 --> 00:00:59,540 we write the value 14 00:00:59,550 --> 00:01:02,100 to the command register of the PIC. 15 00:01:02,680 --> 00:01:06,720 The bit 5 of the value is non-specific end of interrupt. 16 00:01:06,840 --> 00:01:08,040 We set it to 1. 17 00:01:08,530 --> 00:01:10,560 So the value we use is 20. 18 00:01:11,620 --> 00:01:17,320 We remove jump instruction and move al 20. 19 00:01:19,700 --> 00:01:22,640 then we write it to the command register of the master. 20 00:01:27,170 --> 00:01:33,800 Ok, when the handler returns now, the timer interrupt will fire periodically and we will see the character is changing 21 00:01:33,800 --> 00:01:34,440 . 22 00:01:34,910 --> 00:01:35,720 Let's test it out. 23 00:01:48,440 --> 00:01:51,290 OK, as you see the third character is changing. 24 00:01:53,140 --> 00:01:54,520 Now, let's do another test. 25 00:01:58,210 --> 00:02:02,080 In the use entry, we remove the code of privilege test. 26 00:02:04,800 --> 00:02:09,750 The next thing we are going to do is we are going to increment the character in the user entry 27 00:02:09,750 --> 00:02:14,430 so that we can see the control is transferring between user entry and timer handler constantly. 28 00:02:15,520 --> 00:02:22,120 When the timer handler is called, the processor pushes rsp rip of the previous tasks on the stack 29 00:02:22,120 --> 00:02:28,570 and we return from the handler, those registers value will be restored so that the previous tasks continues 30 00:02:28,570 --> 00:02:29,680 . 31 00:02:30,640 --> 00:02:37,330 In this case, we will go back to the code in the user entry after the handler returns. 32 00:02:37,330 --> 00:02:39,340 In order to see we actually return to where it was interrupted, 33 00:02:39,520 --> 00:02:41,320 we also increment the character. 34 00:02:45,900 --> 00:02:47,820 We show the characters in white color. 35 00:02:49,620 --> 00:02:56,100 Also, we need to jump to the beginning of the user entry so that we will loop through the code. 36 00:02:56,310 --> 00:03:01,020 if everything goes well, we should see the characters are changing in two different locations on the screen 37 00:03:01,020 --> 00:03:01,520 . 38 00:03:02,430 --> 00:03:03,290 Let's check it out. 39 00:03:16,100 --> 00:03:20,000 OK, as you can see, we have two set of characters changing on the screen. 40 00:03:22,290 --> 00:03:24,870 This is testing on the real machine and it works. 41 00:03:26,220 --> 00:03:27,570 That's it for this lecture. 42 00:03:27,630 --> 00:03:28,950 See you in the next video.