
EXERCISES
1. Suggest a reason for the following. The statements are all true.
a. We should disable interrupts while hooking interrupt 8h. I.e.
while placing its segment and offset in the interrupt vector
table.
b. We need not do this for interrupt 80h.
c. We need not do this when hooking interrupt 8h from inside
the interrupt handler of interrupt 80h.
d. We should disable interrupts while we are changing the stack
(SS and SP).
e. EOI is not sent from an interrupt handler which does
interrupt chaining.
f. If no EOI is sent from interrupt 9h and no chaining is done,
interrupt 8h still comes if the interrupt flag is on.
g. After getting the size in bytes by putting a label at the end of a
COM TSR, 0fh is added before dividing by 10h.
h. Interrupts are disabled but divide by zero interrupt still
comes.
2. If no hardware interrupts are coming, what are all possible reasons?
3. Write a program to make an asterisks travel the border of the screen,
from upper left to upper right to lower right to lower left and back to
upper left indefinitely, making each movement after one second.
4. [Musical Arrow] Write a TSR to make an arrow travel the border of the
screen from top left to top right to bottom right to bottom left and
back to top left at the speed of 36.4 locations per second. The arrow
should not destroy the data beneath it and should be restored as
soon as the arrow moves forward.
The arrow head should point in the direction of movement using the
characters > V < and ^. The journey should be accompanied by a
different tone from the pc speaker for each side of the screen. Do
interrupt chaining so that running the TSR 10 times produces 10
arrows traveling at different locations.
HINT: At the start you will need to reprogram channel 0 for 36.4
interrupts per second, double the normal. You will have to reprogram
channel 2 at every direction change, though you can enable the
speaker once at the very start.
5. In the above TSR hook the keyboard interrupt as well and check if 'q'
is pressed. If not chain to the old interrupt, if yes restore everything
and remove the TSR from memory. The effect should be that pressing
'q' removes one moving arrow. If you do interrupt chaining when
pressing 'q' as well, it will remove all arrows at once.
6. Write a TSR to rotate the screen (scroll up and copy the old top most
line to the bottom) while F10 is pressed. The screen will keep rotating
while F10 is pressed at 18.2 rows per second. As soon as F10 is
released the rotation should stop and the original screen restored. A
secondary buffer of only 160 bytes (one line of screen) can be used.
7. Write a TSR that hooks software interrupt 0x80 and the timer
interrupt. The software interrupt is called by other programs with the
address of a far function in ES:DI and the number of timer ticks after
which to call back that function in CX. The interrupt records this
information and returns to the caller. The function will actually be
called by the timer interrupt after the desired number of ticks. The
maximum number of functions and their ticks can be fixed to 8.
8. Write a TSR to clear the screen when CTRL key is pressed and restore it
when it is released.
9. Write a TSR to disable all writes to the hard disk when F10 is pressed and re-
enable when pressed again like a toggle.