Machine Problem 1, due Feb. 9
A Data Structure: Consider an array called (naturally) ARRAY containing pointers to (that is, the addresses of) records in memory. (C and C++ refer to such records as structs; In C++, Java and Python, records are objects of methodess classes.) Each record contains three fields:
The final entry in the array should have a null pointer (zero) for the address of the record.
A Framework: Here is an example SMAL source file to construct such a data structure:
TITLE "mp1.a by Douglas W. Jones, Jan. 9, 2015" ; -- demonstrates the data structure for MP1 NULL = 0 ; declare the value used for NULL pointers INT ARRAY ; make ARRAY visible to the test program ARRAY: W ITEM1 ; array points to the record ITEM1 W ITEM2 ; array W ITEM3 ; array W NULL ; array, a null pointer ; -- the records: ITEM1: W TEXT1 ; pointer to text H 5 ; X = 5 H 1 ; Y = 1 ITEM2: W TEXT2 H 2, 1 ; an alternative compacted form ITEM3:W SOMETEXT H 2,2; don't write code like this, it works but it's hard to read SOMETEXT:ASCII"world",0 TEXT1: ASCII "lo", 0 TEXT2: ASCII "Hel", 0 END
A Test Program: The object file mp1test.o contains an executable program for the HAWK computer. If you run these shell commands on the Liberal Arts Linux server cluster, presuming you have first followed the instructions in the Getting Started handout, you will assemble your data file, link it to the test program, and run the test program:
smal mp1.a link mp1.o mp1test.o hawk link.o
The output: Running the test program as above launches the Hawk emulator but does not start the emulated computer. What you see is the initial state of the CPU before it executes any code. If you hit the r key on the keyboard, the emulated computer will start executing instructions. At that point, you should see the following output on the screen below the CPU state:
The Assignment: Modify the program so that:
<your name> Machine Problem 1
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.
Submission: Programming assignments will be submitted on-line using 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 mp1.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 cs_2630. Select the assignment directory mp1.
You must submit your work using the submit command from the a CLAS Linux machine. If you make repeated submissions, only the last one will count.