我有以下SPIM代码,并试图确定我做错了什么。我无法找到为什么我的输出无法正常工作。
.globl main
.data
prompt1: .asciiz "Please enter the first pool size: "
prompt2: .asciiz "Please enter the number to be selected from 1st pool: "
prompt3: .asciiz "Please enter the second pool size: "
prompt4: .asciiz "Please enter the number to be selected from 2nd pool: "
message: .asciiz "The odds are 1 in "
.text
main:
#print 1st prompt and get its value
li $v0, 4
la $a0,prompt1
syscall
li $v0, 5
syscall
move $t1, $v0
#print 2nd prompt and get its value
li $v0, 4
la $a0,prompt2
syscall
li $v0, 5
syscall
move $t2, $v0
#print 3rd prompt and get its value
li $v0, 4
la $a0,prompt3
syscall
li $v0, 5
syscall
move $t3, $v0
#print 2nd prompt and get its value
li $v0, 4
la $a0,prompt4
syscall
li $v0, 5
syscall
move $t4, $v0
#perform the calculations for 1st poor
move $t5,$t1
addi $s0,$zero,1
bge $t1,$t2,calc1 #if $t1 is greater than $t2, the loop continues
sub $t6,$t5,$t2
addi $s1,$zero,1
bge $t6,$1,calc2 #if $t6 is greater than $zero, then the loop continues
#perform the calculations for 2nd poor
move $t7,$t3
addi $s2,$zero,1
bge $t3,$t4,calc3 #if $t1 is greater than $t2, the loop continues
sub $t0,$t7,$t4
addi $s3,$zero,1
bge $t0,$1,calc4 #if $t6 is greater than $zero, then the loop continues
#perform final calculation
div $s4, $s0,$s1
div $s5, $s2,$s3
mul $s6,$s4,$s5
#display outputs
li $v0,4
la $a0,message
syscall
li $v0,1
move $a0,$s6
syscall
li $v0,10
syscall
#end of program
calc1:
mul $s0,$s0,$t1
addi $t1,$t1,-1
calc2:
mul $s1,$s1,$t6
addi $t6,$t6,-1
calc3:
mul $s2,$s2,$t3
addi $t3,$t3,-1
calc4:
mul $s3,$s3,$t0
addi $t0,$t0,-1