Assign a user input value from a loop to different registers in MIPS

1.5k Views Asked by At

The question goes like this: 1. Print the following message: "Enter an integer" 2. Read the input 3. Do this for 5 times 4. Check for the valid input. Repeat the process again for invalid input 5. Calculate the value of P * Q - ( R + S * T). 6. Print P * Q - ( R + S * T) = X.

I am confused on how to assign the user input from the loop to a different register for every new loop iteration.

This is my code:

 .data
msg1: .asciiz "Please enter an integer:"
.align 2
array: .space 100

.text
main:
    la $t3 array
    loop:

        la $a0, msg1 #output message
        li $v0, 4
        syscall
        li $v0, 5 #read in user input
        syscall
        move $t0, $v0
        beq  $t1,5, endloop #get user input up to 5 times 



        b loop #loop until it reaches 5 

    endloop:

    jr $ra
0

There are 0 best solutions below