Machine Problem 2, due Sep. 29

Part of the homework for CS:2630 (22C:60), Fall 2014
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

 
A Data Structure: Consider an array (called ARRAY) of pointers to (that is, addresses of) records (or what C and C++ call structs, or simple objects), where each record contains

The final entry in the array should have a null pointer (zero) for the address of the record.

Here is some example data, to illustrate this structure:

	TITLE	"mp2data.a by Douglas W. Jones, Sept. 15, 2014"
; -- demonstrates the data structure for MP2
	USE	"hawk.h"	; needed only for ALIGN directive

        INT     ARRAY		; make ARRAY visible to the main program

ARRAY:  W       ITEM1		; array[0]
        W       ITEM2           ; array[2]
        W       ITEM3           ; array[3]
        W       0               ; array[4] -- the end

ITEM1:	W	1,1
	ASCII	"Hello",0
	ALIGN	4
ITEM2:	W	1,2
	ASCII	"World",0
	ALIGN	4
ITEM3:	W	1,3
	ASCII	"-----",0

        END

The Assignment: Write a SMAL Hawk main program in the file mp2.a, such that can be linked to any data file conforming to the above specification to traverse the data structure and output all of the text at the indicated locations on the screen.

If you assemble the above data file and assemble your program, and then link them, the resulting executable object file will output:

Hello
world
-----

If you assemble your program and link it, and there is no mp2data.o file in your directory, the linker will find the official test data for this assignment. It is significantly more complex than the toy data given above. You will probably find the toy data to be more useful for debugging.

Hint: Homework 4, Problem 2 gave code for mp1test.a. That code processes a different data structure, but it should give insight into the structure of the program, as a whole.

Requirements: Your program must:

The above requirements should be taken seriously. We will not do detective work to determine who gets credit for what assignment. If your name is not in the title line for the source file, we will not grade your source file. This is partly a matter of professional ethics: Take credit for your work. It is also to defend an overloaded grader from having to do extra work.

Note that code that works perfectly can still earn significant penalties if it is not clear and readable. Comments that merely state what the code already says are useless. Consider these two alternatives:

        ADDI    R9,R8,4         ;   add R8 plus 4 and put it in R9
        ADDI    R9,R8,4         ;   make R9 point to the Y coordinate

The top line has a useless comment that merely restates what the instruction does. Anyone with vague familiarity with the Hawk instruction set already knows everything that this comment says. You will lose credit for such comments.

The second comment, quoted from Homework 4 problem 2, tells you things that are not in the code. It tells you that R8 and R9 are pointers (memory addresses), and it implies that 4 must be the difference between the two addresses. This information is not in the code -- it helps the reader understand the purpose of the add instruction in its context.

Submission: As with MP1, use the on-line Online Coursework Submission tool provided by the Liberal Arts Linux server cluster. The user interface for this is awful, but but it works. Your source file must be named mp2.a (the name is case-sensitive). This is the name you will type in response to the File/directory name prompt. When the submission tool prompts for Course type c_060. Select the assignment directory mp2.