Lab # 5
Lab # 5
Objectives
At the end of this lab you should be able to:
Describe what interrupt vectors are and explain how they are used
Describe two main methods of IO interrupt handling
Explain the difference between the two main methods of IO interrupt handling
Compare the merits of the two main methods of IO interrupt handling
Lab Instructions
This lab activity comprises two parts, namely Lab tasks, and Post-Lab Viva session.
Each group to upload completed lab report on LMS for grading.
The students will start lab task and demonstrate each lab task separately for step-wise evaluation
There are related questions in this activity give complete answers. Also provide complete code
and results.
Investigating IO Interrupts
Introduction
Computer systems use the interrupt mechanism as a means of responding to
external events such as input and output operations. The CPU is momentarily
interrupted just before executing the next instruction and is forced to execute the
instructions of an interrupt handler. Once the interrupt handling is completed the
CPU is returned back to executing the instruction it was about to execute before it
was interrupted. The stack is used to store the CPU state such as the contents of
registers and the return address when interrupted. These are then restored once the
interrupt handler is exited.
Exercise 1 – Describe what interrupt vectors are and explain how they are used
In the compiler window, check only the boxes Generate code, Enable optimizer and
Redundant Code. Enter the following source code and compile it:
program Vectors
sub IntVect1 intr 1
writeln("This is intr 1")
end sub
while true
wend
end
In the compiled code window locate the subroutines IntVect1, IntVect2 and IntVect5.
Make a note of the starting addresses of these subroutines below:
1
Subroutine Starting address
IntVect1
IntVect2
IntVect5
Interrupt
INT1
INT2
INT5
Compare the two tables above and enter a brief comment on your observation in
the space below:
Tip: If you run the program at a slow pace (speed slider down), you should be able to
see the effects of clicking on the TRIGGER buttons.
Comment on your observations in the space below:
v = 0
writeln("Program Starting")
while true
read(nowait, v)
for i = 1 to 100
if v > 0 then
break *
end if
write(".")
next
wend
writeln("Program Ending")
end
Notes:
The nowait keyword in the read statement makes sure the program is not
suspended while waiting for an input.
If there is no input, the value of the variable v will remain unchanged.
The break * statement takes the program out of the outermost loop which in this
case is the while loop.
Next, enter the following source code in a new source editor and compile it.
program VectoredInt
var v integer
v = 0
writeln("Program Starting")
while true
for i = 1 to 100
if v > 0 then
break *
end if
write(".")
next
wend
writeln("Program Ending")
end
Briefly explain what the above program is doing (note where the read statement is in
this case)
Load the code generated in CPU memory. Reset and run this code at the fastest
speed. As soon as the Program Starting message is displayed on the Console, type
any single character in the INPUT box of the Console. Wait until the program
terminates.
Exercise 3 – Explain the difference between polled and vectored interrupts
Based on your observation in the previous exercise, briefly explain the difference in
the behaviours of the two programs, PolledInt and VectoredInt, with
respect to the speed of response to input. Explain why this difference.
Based on your observations in exercises 2, and looking at the table below, which
interrupt handling method listed in the table, is more efficient (put an X against it):
Interrupt method Select the most
efficient one
Polled
Interrupt
Vectored
Interrupt
Exercise 4 – Compare the merits of the two main methods of interrupt handling
1. Based on your observations above, suggest and briefly describe a reason
where you would use the Polled Interrupt method in preference to the
Vectored Interrupt method?
2. Very briefly describe where you would use the Vectored Interrupt method
in preference to the Polled Interrupt?