CS611
Programming Assignment 6
Fall 1998


Write a debugger for assembly language programs running on the sim611 machine.

The debugger should be interactive and should accept the following commands:

  1. E hexaddr (examine) [15 points]

    The contents of the byte at the given address should be displayed in hex format. If the address is not valid (either an illegal hex address follows the 'E' or the given address is out of range), an error indicator should be displayed. The user should be re-prompted after the E command completes.

  2. B hexaddr (set break) [20 points]

    Set a breakpoint at the given address. If control reaches that address, the debugger should pause the program, print a newline character, print the address in hex format, print another newline character, and wait to input a debugger command. The user is responsible for seeing that breakpoints are only set at addresses where opcode bytes are located. If the address is not valid (either illegal hex address follows the 'B' or the given address is out of range), an error indicator should be displayed. The user should be re-prompted after the B command completes. Breakpoints are persistent and remain until explicitly cancelled with the C command.

  3. S (step) [20 points]

    Execute one instruction and return to the debugger. The user should be re-prompted after the S command completes.

  4. G (go) [15 points]

    Resume execution of the program. This is like the gdb "cont" command.

  5. C hexaddr (cancel break) [15 points]

    Cancel a breakpoint. If the breakpoint had not been previously established, an error indicator should be displayed. If the address is not valid (either illegal hex address follows the 'C' or the given address is out of range), an error indicator should be displayed. The user should be re-prompted after the C command completes.

  6. Q (quit debugger) [15 points]

    The debugger (and the overall program) should be halted.

The debugger prompt should be a newline character, followed by the hex address of the next instruction to be executed in the user program, followed by another newline character. If an error occurs in the response to a debugger prompt, display a newline, a question mark, another newline and then re-prompt the user.

You may assume that any letters in addresses and debugger commands will only be given using uppercase. The user should only type one space between the command and the hex address. The user should place a newline character immediately following the hex address. For commands that do not take a hex address then the newline will immediately follow the command. You can assume the input meets these requirements. You do not have to error check them. However you should be checking the potential errors listed above for each debugger command. When checking addresses to see if they are in range, you can simply check them against the 64K boundary.

All addresses displayed and input should be relative to the user's program. The debugger should adjust them as necessary.

The debugger will have to be written in the assembly language of the sim611 machine. Put your debugger code in the file debug.asm. as611 will take a -g flag followed by the name of an assembler file containing the debugger code. That is, to run as611 on prog.asm for execution with debugger support:

% as611 -g debug.asm prog.asm

Then to run the program with the debugger:

% sim611 prog.obj

The assembler does not make any alterations to the symbol names in the debugger module. Therefore you should make all labels in the debugger module start with DBG to attempt to avoid name conflicts.

Any module that has been assembled for debugging should initially come up in the debugger when executed (run through the simulator). Also if a run time error occurs, like memory reference out of bounds, the debugger should get control (however no error message need be printed).

You may assume that the user program does not try to handle any exceptions on its own. You may also assume the the user program will set up a stack correctly and that that stack will not get corrupted.

When a HALT instruction is executed, the program (and debugger) should just exit normally.

To do this assignment you will need to understand how the simulator handles exceptions (run time errors). Also be sure you understand the instructions BPT, TCLR, and TSET, and the register R13.

Since this program is written in assembly language, special care should be taken to ensure that the program is readable. You may lose points if your program is not properly structured or adequately documented.

Your programs will be graded using an Alpha machine (e.g. alberti) so be sure to test in that environment.

Your programs should be submitted for grading from either alberti, hopper, or christa. To turn in this assignment, type:

~cs611/bin/submit prog6 debug.asm

Notes:

Submissions can be checked by typing:

~cs611/bin/scheck prog6

To receive full credit for the assignment, you must turn in your files prior to 8am on Monday December 7. Late submissions will be accepted at the penalty of 5% per day up to one week late.

Remember: as always you are expected to do your own work on this assignment.


Last modified on November 12, 1998.

Comments and questions should be directed to pjh@cs.unh.edu