Hardware and Real Interrupts-Microprocessor and Assembly Language Programming-Assignment, Exercises of Microprocessor and Assembly Language Programming

This task was assigned at Quaid-i-Azam University for Microprocessor and Assembly Language Programming course by Prof. Saleem Raza. Its main points are: Hooking, Vector, Stack, Chaining, Asterisks, Reprogram, Characters, Port, Chip, Frequency

Typology: Exercises

2011/2012

Uploaded on 08/04/2012

saqqi
saqqi 🇵🇰

4

(33)

40 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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.
pf2

Partial preview of the text

Download Hardware and Real Interrupts-Microprocessor and Assembly Language Programming-Assignment and more Exercises Microprocessor and Assembly Language Programming in PDF only on Docsity!

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. 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.

HINT: To write to the hard disk programs call the BIOS service INT 0x13 with AH=3.

  1. Write a keyboard interrupt handler that disables the timer interrupt (no timer interrupt should come) while Q is pressed. It should be re- enabled as soon as Q is released.
  2. Write a TSR to calculate the current typing speed of the user. Current typing speed is the number of characters typed by the user in the last five seconds. The speed should be represented by printing asterisks at the right border (80th column) of the screen starting from the upper right to the lower right corner (growing downwards). Draw n asterisks if the user typed n characters in the last five seconds. The count should be updated every second.
  3. Write a TSR to show a clock in the upper right corner of the screen in the format HH:MM:SS.DD where HH is hours in 24 hour format, MM is minutes, SS is seconds and DD is hundredth of second. The clock should beep twice for one second each time with half a second interval in between at the start of every minute at a frequency of your choice.

HINT: IBM PC uses a Real Time Clock (RTC) chip to keep track of time while switched off. It provides clock and calendar functions through its two I/O ports 70h and 71h. It is used as follows: mov al, out 0x70, al ; command byte written at first port jmp D1 ; waste one instruction time D1: in al, 0x71 ; result of command is in AL now Following are few commands 00 Get current second 02 Get current minute 04 Get current hour All numbers returned by RTC are in BCD. E.g. if it is 6:30 the second and third command will return 0x30 and 0x06 respectively in al.