Using PLP Tool / MIPS create a program that should start by loading the numbers
ID: 667703 • Letter: U
Question
Using PLP Tool / MIPS create a program that should start by loading the numbers 2015 and 250 into registers $a0 and $a1 respectively. The start of your program is a good place to initialize any other registers with values that you don’t plan on changing inside the program. It should then have an infinite loop that performs two steps: reading the value of the switches and use control flow instructions to perform the indicated arithmetic operation. The result should be stored in register $v0. After doing this it should return to the start of the loop and repeat these two steps. Use the following switch convention:
Explanation / Answer
Comments added
.text
.globl main
main:
#Storing variables
li $a0, $a0, 2015
# store 2015
li $a1, $a1, 250
w $t0, 0($t1) # reading operation case number
jr $t0 # jump to appropriate operation
L0: add $v0, $a0, $a1 # addition
J Exit
L1: sub $v0, $a0, $a1 # subtraction
J Exit
L2: mul $v0, $a0, $a1 # multiplication
J Exit
L3: div $v0, $a0, $a1 # division
Exit: <next instruction>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.