Machine problem 1
EECS 284
Posted: January
25, 2000
Due: February
1, 2000
Learning objectives
-
To understand how instructions can be encoded in machine language to control
the operation of a digital computer.
-
To explore sequential, iterative and conditional control structures.
-
To understand the use of various addressing modes.
Program requirements
-
You will process a series of values stored in memory beginning at address
x3200 and compute some simple statistics about them.
-
The number of inputs is not known in advance. Your program will begin
by processing the value at x3200 and continue processing values until it
loads a sentinel indicating that it has reached the end of the input values.
The input values will be interpreted as non-negative 16-bit two's complement
integers. Any negative value encountered will be treated as a sentinel,
indicating that no additional values should be processed.
-
Your program should:
-
Count the number of input values in the list and store this number at location
x3100.
-
Count the number of input values that are greater than 255 (x00FF) and
store this number at location x3101.
-
Store the number of input values that are less than 256 (x0100) at location
x3102.
-
Find the smallest value in the list and store its value at location x3103.
-
Store the address of the smallest value at location x3104.
-
You may perform these computations in any order. Your program should
HALT the LC-2 when all calculations are completed.
-
You will hand-code the program by preparing a text file containing instructions
specified in either binary or hexadecimal. (If you use binary, the
file should have the suffix ".bin". If you use hexadecimal, the
file should have the suffix ".hex".)
-
The first line of your program will be interpreted as the address at which
the program should be loaded in memory. You should use the starting
address x3000 for all programs for this class.
-
Your program must include a program header comment in this format, as the
first information in the
file:
;
; Author's Name:
; Author's uniquename:
; Program Number:
; Course:
; Date:
;
; SUMMARY
; Say what the program does.
;
; INPUT
; Describe the set of inputs, where
they are
; located, and how they are encoded.
;
; OUTPUT
; Describe what is being stored as
output.
;
; ASSUMPTIONS
; List assumptions you make about
the program. For
; example, if you assume that a particular
input
; data item is always valid, state
that.
;
; REGISTER USAGE
; List each register used in the
program and explain
; how it is used. For example,
if you use R2 to hold
; the address of the input value
currently being
; processed, you might list "R2 --
input pointer".
;
-
Add a comment before each section of the program, describing what it does.
-
Add comments after most of your commands, describing what they do.
-
Each line of code and comments should fit on the page; i.e., they should
not wrap around or be truncated. Long statements that would run off the
page should be split in an aesthetically pleasing manner.
-
You will turn in your program (the bin or hex file) as an
attachment to an e-mail message to the instructor (jimeng@umich.edu).
The message should have the subject line "EECS 284 Program 1".
Suggestions and hints
-
If you haven't done so already, you should complete Machine
Problem 0 to familiarize yourself with the LC-2 software and the instruction
format of the LC-2's machine language. (At the least, you will need to
obtain the LC-2 software from the web and install it on a computer, which
is explained in MP0.)
-
Remember that you will need to convert your program to a "true-binary"
object file before loading it into the simulator for testing.
-
You can test your program by loading a set of test values into the simulator
after you have loaded your onject file. You can use the "set value"
option in the "simulate" menu to load a series of test vaues. Remember
to end your list with a negative number. Remember to use the x-prefix
to specify hex addresses and values.