Homework 4
WPI Basketball Score Analyzer - an LC-3 Assembly Language Program
Due on Tuesday, December 5, 2006 at 11:59 pm
Outcomes
After successfully completing this assignment, you will
be able to...
- Enter, debug, and execute programs written in LC-3 assembly language
- Use the LC-3 TRAP instruction to do I/O
- Convert integers to ASCII strings
- Process an array of records
Before Starting
Read Chapters 6 and 7.
Description of Problem
In this project you'll write a program to process an array of records, where
each record contains information about a WPI basketball game. Your program
will print a summary of the scores followed by the win/loss record for WPI.
Input and Output
The format
of each record in the database is as follows: the first item is the name of
the
opponent, stored as a zero-terminated ASCII string (one character per
word); the second item is the number of points scored by WPI (an integer);
and the third item is the number of points scored by the opponent (an
integer). The database can contain any number of such records, and the
last record in the database will be followed by a memory location containing
the value x0000. The team scores can take on any value between 0 and #999.
The database starts at location x4000.
Given this input:
x4000 'B'
x4001 'e'
x4002 'c'
x4003 'k'
x4004 'e'
x4005 'r'
x4006 x0000
x4007 #94
x4008 #43
x4009 'N'
x400A 'i'
x400B 'c'
x400C 'h'
x400D 'o'
x400E 'l'
x400F 's'
x4010 x0000
x4011 #106
x4012 #53
x4013 x0000
Your program should display this output:
WPI: 94, Becker: 43
WPI: 106, Nichols: 53
Wins: 2, Losses: 0
The format of your output should look just like the given example.
Hints
This program is more complicated than it might first appear - don't
wait until the last minute to do this assignment.
Break the program into
manageable parts instead of trying to write the whole thing at once.
Here is
one way you might want to approach this assignment:
- Write the code to extract the name of each opponent. The
output from this first version of the program using the sample
input would be:
WPI: , Becker:
WPI: , Nichols:
- Add the code that will convert the integer scores to ASCII
strings, and print them out. The
output from this second version of the program would be:
WPI: 094, Becker: 043
WPI: 106, Nichols: 053
You are welcome to make use of the code on page 277 in the text when
designing your binary-to-ASCII conversion.
- Add the code to get rid of leading zeros. The
output from this third version of the program would be:
WPI: 94, Becker: 43
WPI: 106, Nichols: 53
- Add the code to calculate and print the win/loss record.
There are other ways to break up
the assignment; the point is to concentrate on one subtask at a time,
test it completely, then move on to the next. Comment as you code!
Design Considerations
Make use of subroutines where appropriate. For example, your routine
to convert an integer to an ASCII string, and your routine to strip
off leading zero's, should both be coded as subroutines.
Documentation Guidelines
You will be using the LC3Edit program to create your assembly language
source file. Follow these formatting and documentation guidelines:
- The program should contain an introductory comment that includes
the programmer's name, login name, and section number, the date,
and a brief description of the program. Your description should serve
as a general summary of your program's approach to the problem and
will also serve as a guideline for assigning partial credit. It is in
your best interest to make all of your ideas clear through this summary.
If a register will be used for a specific purpose throughout the
program, that register's purpose should be noted in the introductory comments.
For example,
; Register Usage
; R4 - address of word currently being processed in database
; R5 - number of wins
; R6 - number of losses
- Each field in a line of assembly language source code should be
separated by a single tab character. Labels should begin on the
left margin (column 1). In the example below, "GetString" begins in
column 1, and a tab is placed before "ldr", "r0", and "; R0..."
GetString ldr r0, r4, #0 ; R0 contains character to be copied
- Arguments in the operand field should be separated by one space
- Either upper- or lower-case characters can be used in assembly
language instructions, but be consistent. Choose upper- or lower-case and
stick with it.
- Main sections of code should be separated by a blank line
- Main sections of code should be preceded by a comment, for example
; this loop will copy the name of the opponent into StringBuf
- Comments in the comment field of an instruction should clarify
the instruction in the context of the problem being solved. For
example, the first comment below is helpful to a
reader of the program; the second comment adds no new information or
insight:
add r3, r3, #1 ; point to next location in StringBuf
rather than
add r3, r3, #1 ; add 1 to R3
Deliverables
You should turn in two files for this assignment. basketball.asm
contains the assembly language code for your program. scores.asm
contains sample data you used to test your program.
Using web-based turnin
submit your LC-3 source files before 11:59pm on Tuesday, Dec 5.