I'm working on "Craps" (a dice game) for an assignment and i'm puzzled about one thing in my code. I'm trying to figure out why both the win prompt and lose prompt trigger when the beq if statement triggers. In craps if the rolling player rolls a 7 or an 11 they win, and somehow the win condition is also triggering the losing condition prompt found at the bottom of the code.
Thanks for your help
.text
main:
li $v0, 4 # Load system call code 4 into register $v0; System call code 4 represents print_string.
la $a0, heading # Load address of string to print.
syscall # Perform system call.
# Prompt for the integer to enter
li $v0, 4
la $a0, prompt
syscall
# Read the integer and save it in $s0
li $v0, 5
syscall
move $s0, $v0
# Output the text
li $v0, 4
la $a0, output
syscall
# Output the value
li $v0, 1
move $a0, $s0
syscall
li $t0, 3 # t0 is a constant 10
li $t5, 0 # t1 is our counter (i)
loop:
beq $t5, $s0, end # if t1 == 10 we are done
##################body of loop
# Output the text
li $v0, 4
la $a0, rng
syscall
.text
li $a1, 6 #Here you set $a1 to the max bound.
li $v0, 42 #generates the random number.
syscall
add $a0, $a0, 1 #Here you add the lowest bound
li $v0, 1 #1 print integer
syscall
move $t1, $a0
# Output the text
li $v0, 4
la $a0, registerMoved
syscall
# Output the value
li $v0, 1
move $a0, $t1
syscall
# Output the text
li $v0, 4
la $a0, rng
syscall
#generation of second random number
li $a1, 6 #Here you set $a1 to the max bound.
li $v0, 42 #generates the random number.
syscall
add $a0, $a0, 1 #Here you add the lowest bound
move $t2, $a0
syscall
# Output the value
li $v0, 1
move $a0, $t2
syscall
# Output the text
li $v0, 4
la $a0, registerMoved
syscall
# Output the value
li $v0, 1
move $a0, $t2
syscall
add $t3, $t1, $t2
# Output the text
li $v0, 4
la $a0, combined
syscall
li $v0, 1
move $a0, $t3
syscall
li $t1, 7
beq $t1, $a0, WIN # if(input==7 output win)
li $t2, 11
###### end of body of loop
addi $t5, $t5, 1 # add 1 to t1
j loop # jump back to the top
end:
# Exit the program
li $v0, 10
syscall
.text
WIN:
# Output the text
li $v0, 4
la $a0, winString
syscall
END_WIN:
.text
LOSE:
# Output the text
li $v0, 4
la $a0, loseString
syscall
END_LOSE:
.data
heading: .asciiz "Welcome to the game of craps\n"
registerMoved: .asciiz "\nThe register was copied to another address: "
prompt: .asciiz "Enter a number of rolls: "
die_roll: .asciiz "The dice roll is: "
win: .asciiz "You have won"
loss: .asciiz "You have lost"
output: .asciiz "\n You entered for the number of rolls :"
rng: .asciiz "\nThe number generated was: "
combined: .asciiz "\nThe combined value is: "
winString: .asciiz "The rolling player wins "
loseString: .asciiz "The rolling player loses "```