Homework #2 - Due Oct. 7 (Tuesday)
The high-level language program to calculate xy could be written as
Main Program: result := 1 for counter := 1 to y do result := result * x end for
In assembly language this translates to the following program:
# Mark Fienup <Your name here as a comment> .data x: .word 2 y: .word 3 result: .word 0
.text .globl main main: lw $8, x # store x in reg. $8 lw $9, y # store y in reg. $9 li $10, 1 # store result in $10 and initialize it to 1 for: li $11, 1 # store counter in $11 and initialize it to 1 for_compare: bgt $11, $9, end_for for_body: mul $10, $10, $8 # mult. result by x addi $11, $11, 1 j for_compare end_for: sw $10, result li $v0, 10 # system code for exit syscallYour assignment is to type in the above program using some editor like Notepad (directions on back). Run the assembly language programming using pcspim.
Turn in: Print out of the file containing the program and the resulting PCSpim window after running the program (directions on back).
Entering the Program using Notepad:
Running the Program using PCSpim:
Click "OK" in the Run Parameters window
Printing the PCSpim window using Word:
clicking on the frame
drag the lower-right corner to make the picture bigger