EE-218 Lab News

April 03, 2006

 

System Debugging Problem 1: Lab10-Problem1

System Debugging Problem 2: Lab10-Problem2

You can download the wookie simulator to help you with your preparation as the following link: wookie171 simulator


 

Lab 10

System Debugging

Before the Lab

When a computer program is written, it is necessary not only to choose the proper instructions but also to properly format each instruction statement. Assemblers and compilers will generate syntax errors when processing source program statements that are improperly written, but even when the programs are edited to eliminate all syntax errors, there is no guarantee that the program will run successfully or function properly. Only executing the instructions can test the program's logic. A newly written program is likely to have mistakes and therefore must be tested carefully before attempting to let it run by itself. Systems like the HC11-VDK and the Axiom boards with their debugging features are usually used so that the problems can be analyzed. The program can be stopped and corrected when something is wrong. System debugging is the name given to this process. It verifies not only that the program does calculations and handles data correctly but also that the software properly controls the external hardware.

One of the most common tools in system debugging is the use of a 'Monitor' program in ROM. By now, you are familiar with both monitor programs used by the Axiom boards, namely the BUFFALO. They contain many features for program development and analysis. Following are some of the most important facilities used in debugging:

  1. Break point setting.

  2. Ability to test a subroutine by 'CALLing' it directly from keyboard.

  3. Memory display and edit.

  4. Registers display and edit.

  5. Tracing through a set of instructions.

It is interesting to know how the monitor handles the tracing and break points. Software interrupts can be used to implement these facilities.

For the trace command, the Output Compare 5 (OC5) interrupt can be used to time out after the first cycle of the first Op code fetched. To use this feature to examine a program's operation, the PC is set to the instruction to be tested, and a T command is then entered to execute the instruction. This monitor program command serves to set up the OC5 timer count values and enable its interrupt to occur after a prescribed number of clock cycles. This is the exact time required to run through the monitor routines and start executing the user's instruction. The microprocessor will run the instruction pointed to by the PC at normal clock speed and then stop to service the OC5 interrupt. The service routine gets the registers contents from the stack to display them. It then reenters the monitor command loop, displays the prompt, and waits the next command. An option can be added to this feature to run a specified number of instructions before getting the interrupt.

For the break point facility, the monitor temporarily inserts a software interrupt SWI instruction in place of a user's program instruction, and saves the code that was in that location. When this SWI instruction is reached, an interrupt service routine is called. It displays the content of the registers and puts back the user's instruction in place so that, when checking the code in memory, the user finds its code and not the code for the SWI.

In the Lab

You will be given a software code along with the specification of typical inputs and expected outputs. Your task will be the following:

  • To devise test cases to debug the program. You should indicate to your T.A. the reason for selecting those test cases.

  • Use the debugging facilities provided by monitors to fix the program's problems. You have to take notes when you are solving those problems. Provide a systematic way of debugging.

The main objective of this lab is to learn how to systematically debug a program and prove that it is working according to the specs given. Try to use test cases that are not trivial (e.g. for a sorting program you will need to try its output if the list to sort is empty, if the list has only one number, if the list has negative and positive numbers, if the list has the same number repeated several times, etc.).

After the Lab

Explain the program that you were to debug, and the approach you used to fix it.

Include a list of the test cases you used.

Can you think of other facilities that could be added to the BUFFALO monitor (considering the size of memory available) to make the debugging easier?

Assume that you are supposed to talk about very common mistakes you and your classmates have made in the lab assignments. What are those? Besides code inspection, what helps you find the errors? Can you provide a systematic approach to finding programming bugs?

 

          TABLE 1.  BUFFALO Monitor Program Commands

COMMAND DESCRIPTION
ASM[<address>] Assembler/disassembler
BF <addr1> <addr2> <data> Block fill memory with data
BR [-] [<address>]... Breakpoint set
BULK Bulk erase EEPROM
BULKALL Bulk erase EEPROM & CONFIG register
CALL [<address>] Execute subroutine
G [<address>] Execute program
HELP Display monitor commands
LOAD <host download command> Download (S-records) via host port
LOAD <T> Download (S-records) via terminal port
MD [<addr1> [<addr2>]] Dump memory to terminal
MM [<address>] Memory modify
MOVE <addr1> <addr2> [,dest>] Move memory to new location
P Proceed from breakpoint
RM[p,y,x,a,b,c,s,] Register modify
T [<n>] Trace $1-$FF instructions
TM Enter transparent mode
VERIFY <host download cmd> Compare memory to download data via host port
VERIFY <T> Compare memory to download data via terminal port

BUFFALO UTILITY SUBROUTINES

Several subroutines exist that are available for performing I/O tasks. A jump table has been set up in ROM directly beneath the interrupt vectors. To use these subroutines, execute a jump to subroutine (JSR) command to the appropriate entry in the jump table. By default, all I/O performed with these routines are sent to the terminal port. Redirection of the I/O port is achieved by placing the specified value (O=SCI, 1=ACIA) into RAM location IODEV.

Utility subroutines available to the user are as follows:

UPCASE  If character in accumulator A is lower case alpha, convert to upper case.
WCHEK  Test character in accumulator A and return with Z bit set if character is white space (space, comma, tab).
DCHEK  Test character in accumulator A and return with Z bit set if character is delimiter (carriage return or white space).
INIT  Initialize I/O device.
INPUT  Read I/O device.
OUTPUT  Write I/O device.
OUTLHLF  Convert left nibble of accumulator A contents to ASCII and output to terminal port.
OUTRHLF  Convert right nibble of accumulator A contents to ASCII and output to terminal port.
OUTA  Output accumulator A ASCII character.
OUTlBYT  Convert binary byte at address in index register X to two ASCII characters and output. Returns address in index register X pointing to next byte.
OUTlBSP  Convert binary byte at address in index register X to two ASCII characters and output followed by a space. Returns address in index register
OUT2BSP  Convert two consecutive binary bytes starting at address in index register X to four ASCII characters and output followed by a space. Returns address in index register X pointing to next byte.
OUTCCRLF  Output ASCII carriage return followed by a line feed.
OUTSTRG  Output string of ASCII bytes pointed to by address in index register X until character is an end of transmission ($04).
OUTSTRGO  Same as OUTSTRG except leading carriage return and line feed is skipped.
INCHAR  Input ASCII character to accumulator A and echo back. This routine loops until character is actually received.

Utility jump subroutines for performing I/O tasks are shown below. These subroutines are in ROM and are programmed as jumps. To use the jump subroutine, execute a JSR to the applicable address shown below.

$FFAO JMP UPCASE Convert character to uppercase
$FFA3 JMP WCHEK Test character for white space
$FFA6 JMP DCHEK Check character for delimiter
$FFA9 JMP INIT Initialize I/O device
$FFAC JMP INPUT Read I/O device
$FFAF JMP OUTPUT Write I/O device
$FFB2 JMP OUTLHLF Convert left nibble to ASCII and output
$FFB5 JMP OUTRHLF Convert right nibble to ASCII and output
$FFB8 JMP OUTA Output ASCII character
$FFBB JMP OUTlBYT Convert binary byte to 2 ASCII characters and output
$FFBE JMP OUT1BSP Convert binary byte to 2 ASCII characters and output followed by space
$FFCl JMP OUT2BSP Convert 2 consecutive binary bytes to 4 ASCII characters and output followed by space.
$FFC4 JMP OUTCRLF Output ASCII carriage return followed by line feed
$FFC7 JMP OUTSTRG Output ASCII string until end of transmission ($04)
$FFCA JMP OUTSTRGO Same as OUTSTRG except leading carriage return and line fees is skipped
$FFCD JMP INCHAR Input ASCII character and echo back

 


| EE-218  Homepage | Syllabus | Schedule | Lab News | Faculty | Contact Information | Lab Info | Project |


Department of Electrical Engineering and Computer Science
Box 1824 Station B
Nashville, TN 37235
Phone: 322-2771
Fax: 343-6702


 | Search | Site Index | People Finder | Phone Directory | VUnet | VUmail | VU Library | Help |


Last Updated: Tuesday, January 16, 2007

Juan J. Rodriguez-Moscoso

Teeradache Viangteeravat

Copyright © 2003 Vanderbilt University