(Solved) : Could Somebody Tell A0 Mips Code Range Please Guesss Program Asks User Enter Guess Repromp Q33883691 . . .

COULD SOMEBODY TELL ME WHY $a0 in my MIPS CODE IS OUT OF RANGEPLEASE

######################
# guess.s
# ——-
# This program asks the user to enter a guess. It
# reprompts if the user’s entry is either an invalid
# hexadecimal number or a valid hexadecimal number
# that is outside the range specified in the program
# by min and max.
#
.data
min: .word 1
max: .word 10
msgguess: .asciiz “Make a guess.n”
msgnewline: .asciiz “n”
.text
.globl main
main:
# Make space for arguments and saved returnaddress
subi $sp, $sp, 20
sw $ra,16($sp)

# Get the guess
la $a0, msgguess
lw $a1, min
lw $a2, max
jal GetGuess

# Print the guess
move $a0, $v0
jal PrintInteger

# Print a newline character
la $a0, msgnewline
jal PrintString

# Return
lw $ra, 16($sp)
addi $sp, $sp, 20
jr $ra

################################
# GetGuess
################################

.data
invalid: .asciiz “Not a valid hexadecimal number.n”
badrange: .asciiz “Guess not in range.n”
.text
.globl GetGuess
#
# C code:
#
# int GetGuess(char * question, int min, int max)
# {
# // Local variables
# int theguess; // Store this on the stack
# int bytes_read; // You can just keep this one in a register
# int status; // This can also be kept in a register
# char buffer[16]; // This is 16 contiguous bytes on thestack
#
# // Loop
# while (true)
# {
# // Print prompt, get string (NOTE: You must pass the
# // address of the beginning of the character array
# // buffer as the second argument!)
# bytes_read = InputConsoleString(question, buffer, 16);
# if (bytes_read == 0) return -1;
#
# // Ok, we successfully got a string. Now, give it
# // to axtoi, which, if successful, will put the
# // int equivalent in theguess.
# //
# // Here, you must pass the address of theguess as
# // the first argument, and the address of the
# // beginning of buffer as the second argument.
# status = axtoi(&theguess, buffer);
# if (status != 1)
# {
# PrintString(invalid); // invalid is a global
# continue;
# }
#
# // Now we know we got a valid hexadecimal number, and the
# // int equivalent is in theguess. Check it against min and
# // max to make sure it’s in the right range.
# if (theguess < min || theguess > max)
# {
# PrintString(badrange); // badrange is a global
# continue;
# }
#
# return theguess;
# }
# }
#
#
GetGuess:
# stack frame must contain $ra (4 bytes)
# plus room for theguess (int) (4 bytes)
# plus room for a 16-byte string
# plus room for arguments (16)
# total: 40 bytes
# 16 byte buffer is at 16($sp)
# theguess is at 32($sp)
#

#######################
# YOUR CODE HERE #
#######################

subi $sp, $sp, 40
sw $ra, 36($sp)
sw $s2, 32($sp)#theguess
sw $s1, 16($sp)#buffer

LOOP:
lw $a0, 40($sp) #Question
la $a1, 16($sp) #Buffer
li,$a2, 16 #16

jal InputConsoleString
move $t0, $v0

# if(bytes_read==0) return -1;
beqz $t0, Lnegative

# axtoi(&theguess, buffer)
la $a0, 32($sp)
la $a1, 16($sp)
jal axtoi
move $t1, $v0

# if(status==1) go to Lequal
beq $t1, 1, Lequal

#print String(invalid)
la, $a0, invalid
jal PrintString
b LOOP

Lequal:
lw $t2, 44($sp) #min
lw $t3, 48($sp) #max
lw $t4, 32($sp) #theguess

Lgreater:
bge $t4, $t2, Lcheck
b Lrange

Lcheck:
ble $t4, $t3, Lend
b Lrange

Lrange:
la $a0, badrange
jal PrintString
b LOOP

Lend:

move $v0, $t4

lw $ra, 36($sp)
lw $s2, 32($sp)
lw $s1, 16($sp)
addi $sp, $sp, 40

jr $ra

Lnegative:

li $v0, -1

lw $ra, 36($sp)
lw $s2, 32($sp)
lw $s1, 16($sp)
addi $sp, $sp, 40

jr $ra

.include “./util.s”

COULD SOMEBODY TELL ME WHY $a0 in my MIPS CODE IS OUT OFRANGE.

 

Expert Answer


. . .