Homework 3, Part 2
Calculating the checksum for an array
Due:
Tuesday, Nov 20, 2007 at 11:59 pm
Outcomes
After successfully completing this assignment, you will
be able to...
- Enter, debug, and execute programs written in LC-3 machine code
- Explain the different addressing modes of the LC-3 ISA
- Use the LC-3 operate instructions, data movement instructions, and
conditional branch instruction to solve a programming problem
Before Starting
Read Chapters 4 and 5. You should have already completed
Homework 3, Part 1. You are welcome to use
my solution to HW3, Part 1, if you wish.
Description of Problem
There are various methods used to verify the accuracy of
transmitted information. A checksum is a number that is calculated
from data that is to be sent from one place to another. When the data and
the checksum arrive at their destination, the checksum is calculated from the
data again. If the new checksum equals the original checksum, the presumption is that the data is error-free. If the two calculated checksums are different,
then an error occurred during the data transmission.
In this assignment, the checksum on an array of
words will be calculated by counting the total number of bits set to 1 in the array.
Using LC3edit, create a file named checksum.bin
.
You will find the code you wrote
for Part 1 useful for Part 2 (you should manually cut and paste your code from Part 1; don't call it as a subroutine...we'll learn how to set up subroutines
later). Your program should begin at
location x3000. The program expects to find the size of the array stored in
location x3100 (you may assume that the size of the array <= 4096 (decimal) words).
It expects to find the address of
the array in location x3101. Your
program should store the final checksum in R7.
Prior to executing the program, you should manually load the indicated values
into locations x3100 and x3101, and initialize the elements of the array.
Example: If prior to program execution memory is loaded with these
values:
location contents
x3100 x0003
x3101 x4000
x4000 x0002
x4001 xFFFF
x4002 x0003
then upon completion of the program, R7 will contain x0013.
Documentation and Formatting
As with part 1, you should include an explanation of your algorithm
as a comment at the beginning of your program. Look at
my solution to HW3, Part 1 for guidance on
what kind of information to put in this comment. Also, as before,
your machine code instructions should be typed so that the individual
fields of the instructions are separated, and a comment should be
included for each instruction.
Deliverables
You must use turnin
to submit your LC-3 file checksum.bin
before 11:59pm on Tuesday, November 20. Make sure you include your name at the top of your
file.