Lab 10-1
Lab 10-1
Laboratory Manual
for
Computer Organization and Assembly Language Programming
Page 1
OBJECTIVES:
Understand the use of IN and OUT instructions for direct hardware communication.
Learn to manipulate and handle Programmable Interrupt Controller (PIC) ports.
Experiment with interrupt chaining and unhooking interrupts for custom handling.
Explore the basics of the Programmable Interval Timer (PIT) and its integration with interrupts.
Gain insight into terminating and staying resident (TSR) programs and their applications.
1. Write an assembly program to read the status from the PIC control port.
2. Display the result of this read operation on the screen.
Instructions:
1. Write another program that configures the PIT to generate interrupts at a specific frequency.
2. Configure the PIT by writing to its control register and setting up the interval.
Instructions:
Page 2 of 4
Task 2: Interrupt Chaining and Unhooking an Interrupt
Part 1: Chain a Custom Interrupt
1. Hook INT 08h (the timer interrupt) with a custom handler that increments a counter on each
timer tick.
2. Chain this interrupt to retain the original INT 08h handler so that it executes after your custom
code.
Instructions:
1. Write code to unhook your custom handler and restore the original INT 08h vector.
2. Ensure that the program terminates safely and restores the interrupt environment to its original
state.
Instructions:
Use the DOS interrupt to replace the interrupt vector with the original handler.
Verify that the original handler is properly restored by observing that the counter no longer
increments after unhooking.
Task 3: Creating and Debugging a Terminate and Stay Resident (TSR) Program with INT
09h.
Instructions:
Write a custom handler for INT 09h to monitor key presses. Use 0x3509 to get current vector for
INT 09h and 0x2509 to set.
Set the TSR to stay in memory and keep your handler active.
Use INT 3 within the handler to halt execution on specific key presses (e.g., 'A' key) for
debugging.
Observe and document any changes in register values when execution halts.
Page 2
Activity to try at home:
Page 4