Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For these programming exercises, use only those instructions that have been disc

ID: 3700413 • Letter: F

Question

For these programming exercises, use only those instructions that have been discussed so far in these notes:

USING MARS Simulator

Write a program that stores the number 0 in the first four bytes of the .data section, then stores the number 1 in the next four bytes, then stores the number 2 in the four bytes after that and so on. Do this for numbers 0 through 24.

Of course you will do this in a counting loop. The address in the data section is contained in a base register. Increment the base register each time a number is stored.

The data section of your program should look like

add div mflo slt, slti addi divu mult sltu, sltiu addiu j multu sra addu lb nor srl and lbu or sub andi lh ori subu beq lhu sb sw bgez lui sh xor bltz lw sll xori bne mfhi

Explanation / Answer

.data array: .space 100 .text addi $t0, $0, 0 lui $t1, 0x1001 WHILE: beq $t0, 25, END sb $t0, 0($t1) sb $t0, 1($t1) sb $t0, 2($t1) sb $t0, 3($t1) addi $t0, $t0, 1 addi $t1, $t1, 4 j WHILE END: