Question: My problem is that this loops infinitely until i press enter without entering a value in MARS but i need to only loop 3 times

My problem is that this loops infinitely until i press enter without entering a value in MARS but i need to only loop 3 times all this code does is take 2 values given by the user and plugs into a formula

MIPS Code :

.data prompt1: .asciiz "Enter a value for f: " prompt2: .asciiz " Enter a value for g: " result: .asciiz " Answer for f = g - (f + 5): "

.text li $t2,1 li $t3, 0 li $t4, 3 for1: beq $t3, $t4, Exit li $v0,4 la $a0,prompt1 syscall li $v0,5 syscall #takes input move $s1,$v0 li $v0,4 la $a0,prompt2 syscall li $v0,5 syscall #takes second input move $t0,$v0 Add $t1,$s1,$t2 sub $s1,$t0,$t1 # does the formula required for this lab li $v0,4 la $a0,result syscall li $v0,1 move $a0,$s1 syscall j for1 Exit: li $v0,10 syscall #ends

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!