CSCI 162 Spring 2018: Computer Architecture Lab 2: A Subroutine construct


(Feb 6 and 8)
For this lab, you will write two MARIE assembly language programs.

Go to the MARIE option at Applications -> Other, or use the Marie web app



Write an assembler program that does the following:

For example, if the secret hex number is D, then your guesses and output might be the following:
10
H
15
L
14
14 28 56


You can label the parts of the code that you jump to `if', `then', `else', and `endif', or use other labels that identify the conditions that the code fragment is meant to handle (such as guessIsLower or guessIsHigher or guessedCorrectly). Note that `skipcond 400' is the instruction for skipping the next instruction if the AC is zero.

The subroutine (function) should have label "double", and you use JnS to get there, and JumpI to return back to the line of code you left. Recall the label should leave room for a return address, as in

double,  hex 0
         load double_input
         subt zero
         store double_output
         JumpI double



The first line of "double" code is the spot to store the return address. After that is the code to double the value that is in double_input, and store it again in double_output. Then return where control left off before entering the subroutine by executing "JumpI double". (Note that the above code is not correctly doubling the value -- it is meant only as an example of how to formulate the code to which your program will "Jump and Store" or JnS.)

CSCI 162 Course Outline