For these programming exercises, use only those instructions that have been discussed so far in these notes:
add lhu sb addi lui sh addiu lw sll addu mfhi sra and mflo srl andi mult sub div multu subu divu nor sw lb or xor lbu ori xori lh
In the Settings menu of SPIM set Bare Machine ON, Allow Pseudo Instructions OFF, Load Trap File OFF, Delayed Branches ON, Delayed Loads ON, Mapped IO OFF, Quiet OFF.
Run the programs by setting the value of the PC to 0x400000 and then single stepping (pushing F10) or by multiple stepping (push F11 and enter a number of steps). Observing the results in the SPIM window.
Your program has a data section declared as follows:
.data .byte 12 .byte 97 .byte 133 .byte 82 .byte 236
Write a program that adds the values up, computes the average, and stores the result in a memory location. Is the average correct?
Hint: there are two easily-made errors in this program.
Click here to go back to the main menu.