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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started