Spring 2002 CSCI 255 Lab 9

This lab is under contruction!

This lab is scheduled for 10 & 11 April.

Goals and Methods

This week we'll look at:

  1. Using TRAPs
  2. Writing subroutines
  3. Writing TRAPs

Start off creating and then connecting to a directory called csci/255/lab9.

The task

Your job is to write a "drain" routine. A drain routine reads and discards input characters. In our case, we are going to discard and echo all input characters until a ^D is read.

You are going to do this with both a subroutine and a trap.

The main routine

We are providing the following main routine to call your subroutine at memory location x3000 and then your trap at trap number x55.


;; Lab 9 main routine
        .ORIG    x4000
        LEA      R0,MsgSt
        PUTS
        LD       R0,CX3000
        JSRR     R0,#0

        LEA      R0,MsgDr
        PUTS
        TRAP     x55

        HALT

CX3000  .FILL    x3000
MsgSt   .STRINGZ "\nCalling your drain subroutine located at x3000\n"
MsgDr   .STRINGZ "\nCalling your drain trap located at trap x55\n"
        .END

I suggest you store this routine in the file lab9main.asm. You can also copy it into your working directory by typing the following command:

Writing the subroutine

Your subroutine should use the GETC and OUT traps to input and echo characters. Do not use the keyboard and CRT device registers in your subroutine.

Make sure your subroutine is loaded at memory location x3000, and save your code in the file lab9sub.asm.

Writing the trap

Your subroutine should use read and write the keyboard and CRT device registers to intut and echo characters.

You must load your trap routine into memory and make sure that memory location x55 contains the address of your trap routine! Save your trap code in the file lab9trap.asm.

Going home

When you are done, show the lab instructor your work, exit the simulator and log out of the Linux workstation. Do not delete your files. Your lab instructor will examine them later.

You may check if your programs are stored correctly and can be assemled by typing the following command:

Working under Windows

If you work under Windows it is your responsibility to get your two routines in the right place.