Machine Problem 2, due Mar 10

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

Assignment:

Write a SMAL Hawk program that outlines the drawing area of your computer's terminal window with x characters. If your terminal window happens to be 74 characters wide and 25 characters tall, you should see something like this after your program runs:

 HAWK EMULATOR
   /------------------CPU------------------\   /----MEMORY----\
   PC:  00000000                R8: 00000000   FFFFFC: --
   PSW: 0000FE01  R1: 0000000E  R9: 00000000   FFFFFE: --
   NZVC: 0 0 0 1  R2: 0001003C  RA: 00000000 ->000000: LIL     R2,#01003C
                  R3: 00000078  RB: 00000000   000004: JSR     R1,#0001A4
                  R4: 20202078  RC: 00000000   000008: LIL     R1,#001000
                  R5: FF000100  RD: 00000000   00000C: JSRS    R1,R1
                  R6: 00000000  RE: 00000000   00000E: BR      #000000
                  R7: 00000000  RF: 00000000   000010: CPUSET  R1,#3

 **HALTED**  r(run) s(step) q(quit) ?(help)

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
x                                                                        x
x                                                                        x
x                                                                        x
x                                                                        x
x                                                                        x
x                                                                        x
x                                                                        x
x                                                                        x
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

WARNING: There have been reports of errors in some Windows ssh clients (Secure CRT, PuTTY). The error is that they do not always show the leftmost columns of the screen correctly. If the left x marks do not show, but everything else looks good, this may be the fault of your tools, not your program. Try your code from ssh on a Mac or Linux machine to be sure, or change to a different ssh client.

Suggestions:

Your program will probably need the assembly language equivalent of several for loops, some calls to PUTAT, and some calls to PUTCHAR.

You can solve this problem with one main program and no new subroutines of your own. In that case, you need 4 for loops, one for each line of x marks.

You can do better. For full credit, use a single subroutine called MAKEROW that plots the row of x marks using a single for loop. The main program would just use the screen height and width to compute the parameters to 4 calls to this subroutine. In a high level language, the subroutine might be documented as follows:

makerow(x,y,dx,dy,n)

Makes a row of n x marks.

The first x mark is plotted at coordinates x and y.

The coordinates of successive x marks are adjusted by adding dx, dy to the coordinates of the previous x marks.

Requirements:

Grading

As mentioned above, the assignment number mp1 and your name must appear on the title of the listing. In addition, the file name of the file you submit must be mp1.a. No upper case, no alternatives.

Notes

The midterm exam on Mar. 7 will include at least one question that will be closely related to this assignment. Those who have not begun to work on it before the exam will be at a distinct disadvantage.

If you ask for help debugging your code, your code must be well commented. We will not look at "naked" assembly code with no comments to suggest what it is intended to do, and when we find poor comments or discrepancies between the comments and the code, we may ask you to fix those before we look at the code in any detail. Of course, if you ask for help with the comments themselves, we will be glad to offer suggestions.