Machine Problem 1, due Jun. 24

Part of the homework for CS:2630, Spring 2015
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

A sequence

n: 0 1 2 3 4 5 6 7...
f(n): 0 1 3 6 10 15 21 28...

f(n) = n(n+1)/2

f(n) = Σ i
i = 1

A Hawk program skeleton

If you substitute the following application code for the application code section of the hello world program given in Chapter 5 of the notes, you will have a program that prints the first 20 non-negative integers:

; --- begin application code ---
        LIS     R8,0            ; n = 0
LOOP:                           ; loop {

        MOVE    R3,R8           ;   -- parameter n, the number to output
        LIS     R4,4            ;   -- parameter 4, the field width
        LIL     R1,PUTDEC
        JSRS    R1,R1           ;   putdec( n, 4 )

        ADDSI   R8,1            ;   n = n + 1
        CMPI    R8,19
        BLE     LOOP            ; } until (R8 > 19)
; --- end application code ---

The Assignment

  1. Get a copy of the hello world program from Chapter 5 of the notes, and make sure it works under the Hawk emulator.
  2. Modify your copy by changing the title to say "MP1 by NAME" (use your own name for NAME)
  3. Modify your copy by substituting in the above code and make sure it works, giving the output 0 1 2 3 etc.
  4. Modify your copy so that, instead of the oputput n, the program outputs f(n) as defined in the sequence above and make sure it works, giving the output 0 1 3 6 etc.
  5. Modify your copy so that, instead of outputting the results starting at screen coordinates <0,0>, the output starts at <0,1>, that is, on the second line of the Hawk emulator screen display instead of on the first line, and, as usual, make sure it works!
  6. Modify your copy so that additional output text appears, starting at screen coordinates <0,0>, saying exactly the same thing as your program title, and, as usual, make sure it works!

All code you add must be at least as readable and at about as well commented as the code distributed above and in the notes.

An absolute rule: We do not do detective work to connect printed paper copies of assignments with the person who did the work. We assemble and print all assignments as part of the grading process. If your name is not included in the title line, you will not receive any credit.


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 CS2630. Select the assignment directory mp1. Remember, this is a Linux system, file names are case sensitive.

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. Submissions must be in place before midnight on the indicated day.