Department of Electrical and Computer Engineering

The University of Texas at Austin

EE 306, Fall 2019
Programming Assignment 5
Due: December 9th, 17:00
Yale N. Patt, Instructor
TAs: Sabee Grewal, Arjun Ramesh, Joseph Ryan, Chirag Sakhuja, Meiling Tang, Grace Zhuang

You must do every programming assignment by yourself. You are permitted to get help ONLY from the TAs and Dr. Patt. When you have completed the program, and tested it sufficiently so that you are comfortable that it works on any input, submit it for grading according to the submission instructions at the end of this handout.

The purpose of this assignment is to show how interrupt-driven Input/Output can interrupt a program that is running, execute the interrupt service routine, and return to the interrupted program, picking up exactly where it left off (just as if nothing had happened). In this assignment, we will use the Keyboard as the input device for interrupting the running program.

The assignment consists of three parts:


The user program.

Your user program, which starts at x3000, will continually (i.e. in an infinite loop) print the following banner:

====================
*    *  *******
*    *     *
*    *     *
*    *     *
 ****      *

****   ****  ****
*     *      *
****  *      ****
*     *      *
****   ****  ****
====================
To ensure the output on the screen is not too fast to be seen by the naked eye, the user program should include a piece of code that will count down from 40000 after the entire banner is output on the screen. A simple way to do this is with the following subroutine DELAY:

DELAY   ST  R1, SaveR1
        LD  R1, COUNT
REP     ADD R1, R1, #-1
        BRnp REP
        LD  R1, SaveR1
        RET
COUNT   .FILL x7FFF 
SaveR1  .BLKW #1


The keyboard interrupt service routine.

The keyboard interrupt service routine, which starts at x1000, will examine the key typed to see if it it is a decimal digit.

If the character typed is NOT a decimal digit, the interrupt service routine will, starting on a new line on the screen, print "<the input character> is not a decimal digit." For example, if the input key is '#', the interrupt service routine will print

# is not a decimal digit.
The service routine would then print a line feed (x0A) to the screen, and finally terminate with an RTI.

If the character typed IS a decimal digit, the interrupt service routine will, starting on a new line on the screen, print out the number, N, N times. For example, if the input key is '4', the interrupt service routine will print
4444
If the input key is '5', the interrupt service routine will print
55555
The service routine would then print a line feed (x0A) to the screen, and finally terminate with an RTI.

Hint: Don't forget to save and restore any registers that you use in the interrupt service routine.


The operating system enabling code.

Unfortunately, we have not YET installed Windows or Linux on the LC-3, so we provide you with starter code that enables interrupts. You must use the starter code for this assignment. The locations to write the user program and interrupt service routine are marked with comments.

The starter code does the following:

1. Initializes the interrupt vector table with the starting address of the interrupt service routine. The keyboard interrupt vector is x80 and the interrupt vector table begins at memory location x0100. The keyboard interrupt service routine begins at x1000. Therefore, we must initialize memory location x0180 with the value x1000.

2. Sets bit 14 of the KBSR to enable interrupts.

3. Pushes a PSR and PC to the system stack so that it can jump to the user program at x3000 using an RTI instruction.


Your job.

Your job is to do two things:

  1. Write the user program described above.
  2. Write the keyboard interrupt service routine described above.

We have provided part of the output of a sample run as an example of how the console should look when you run the program. Since the user program doesn't halt, the banner will continue printing indefinitely.

Notes:


Submit your Program: The program you are to submit is the .asm file. Save your .asm file, and give it the name interrupt.asm. Submit this file on Canvas.