Reputation: 145
I thought I correctly implemented a while loop, but why am I not getting any output?
My book isn't that great of a help, and I haven't been able to find a resource online.
##### The Data Segment #########
.data
strFirstNumber: .asciiz "Enter the first number (0-63): "
strSecondNumber: .asciiz "Enter the second number (0-63): "
strError: .asciiz "That number is not in the 0-63 range.\n\n"
#### The Text Segment ##########
.text
.globl main
main:
li $t2, 0
#First Number
li $10, 64
li $v0, 4
la $a0, strFirstNumber
syscall
li $v0, 5
syscall
blez $v0, in_error
bgeu $v0, $10, in_error
j DoneIf
in_error:
li $v0, 4
la $a0, strError
syscall
li $v0, 4
la $a0, strFirstNumber
syscall
li $v0, 5
syscall
bltz $v0, in_error
bgeu $v0, $10, in_error
DoneIf:
move $t0, $v0
#Second Number
li $v0, 4
la $a0, strSecondNumber
syscall
li $v0, 5
syscall
bltz $v0, in_error2
bgeu $v0, $10, in_error2
j DoneIf2
in_error2:
li $v0, 4
la $a0, strError
syscall
li $v0, 4
la $a0, strSecondNumber
syscall
li $v0, 5
syscall
blez $v0, in_error2
bgeu $v0, $10, in_error2
DoneIf2:
move $t1, $v0
Loop:
beq $t2, $t0, Exit
add $t3, $t1, $t1
add $t2, $t2, 1
j Loop # go to Loop
Exit:
li $v0, 1
add $a0, $0, $t3
syscall
jr $31
Upvotes: 1
Views: 343
Reputation: 3
It is because you haven't described in the program what process happens in 'syscall' There seems to be no real output result.
Upvotes: 0
Reputation: 3184
It's nearly impossible to say what's wrong:
$t
registers to store value. This is bad because MIPS define them as scratch regiters. Use $s0
to $s7
insteadBTW, if you correctly entered both numbers, your code must run into the loop. Again, given that syscalls probably trashed registers, it may run for a ... long ... time.
Try to change register allocation first, then remove the loop that does not change the result computed into $t3
. And possibly check that your syscall to print work correctly.
Upvotes: 1