Question: MIPS Arithmetic Step 1. Open and run the assembly file - Paste code below to your favorite text editor (notepad,etc) - Open the assembly file
MIPS Arithmetic Step 1. Open and run the assembly file - Paste code below to your favorite text editor (notepad,etc) - Open the assembly file in QtSpim using the File Open icon (an open folder). - Run the assembly file by clicking on Simulator Go. The program should start at the first instruction in memory (0x00400000). You may have to change the address to match your program start. - Hint: for debugging, you may find it easier to single step through the program. To do this, first reload it and reinitialize everything. Then, set the PC (use Simulator Set Value; PC; 0x00400000). Then Single Step (F10) and observe how each instruction affects the machine state. Again, you may have to reset the address to start at your first instruction.
#QTSPIM MIPS CODE
.text main: ori $s7,$0,4097 # put a memory location in $s7 sll $s7,$s7,16 # ori $s0,$0,0x2 # put 2 into $s0 and $s0,$s0,$zero # clear $s0 ori $s0,$zero,0x2 # put 2 back into $s0 nor $s0,$s0, $zero # complement $s0 ori $s0,$zero,0x2 # put 2 back into $s0 ori $s1,$0,0x3 # put 3 into $s1 add $s2,$s0,$s1 # add beq $s2,$zero, exit sw $s2, 4($s7) # store the result to memory j exit ori $s0,$zero,0x2 # pretend like we might do nor $s0,$s0, $zero # other work after jump
# exit gracefully exit: addi $v0,$0,10 # load exit syscall # exit
## end of file
Question 1. Look at code provided. Write down what it does. Question 2. What is the result and where is the result stored? Explain how it gets there.
Question 3. Why are they using the ori instruction? Question 4. Why a complement operation is used in this code?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
