assembly - MIPS Branching issue -
i'm doing project in mips; create wanted long employed requirements. anyway, chose trivia program, has been difficult not impossible. ran problem today branching.
increscore: add $t9, $t9, 1 #increment incr. counter add $t8, $t8, 1 #increment counter move $v0, $t8 #move $v0 beq $v0, $s2, eqtwo #counter=2, question 2 beq $v0, $s3, eqthree #counter=3, question 3 beq $v0, $s4, eqfour #counter=4, question 4 beq $v0, $s5, eqfive #counter=5, question 5 bgt $v0, $t8, etally #counter>5, etally decrescore: add $a3, $a3, 1 #increment decr. counter add $t8, $t8, 1 #increment counter move $v0, $t8 #move $v0 beq $v0, $s2, eqtwo #counter=2, question 2 beq $v0, $s3, eqthree #counter=3, question 3 beq $v0, $s4, eqfour #counter=4, question 4 beq $v0, $s5, eqfive #counter=5, question 5 bgt $v0, $t8, etally #counter>5, etally etally: beq $t9, $s5, ewin #if increment counter = 5, branch easy win bltu $a3, $s5, eloss #if decrement counter < 5, branch easy loss
variables initialized in main:
li $s0, 0 #init score li $s1, 1 #constant; menu num; answer num li $s2, 2 #constant; menu num; answer num li $s3, 3 #constant; menu num; answer num li $s4, 4 #constant; menu num; answer num li $s5, 5 #constant; counter compare point li $s6, 6 #constant li $s7, 7 #constant li $t0, 8 #constant li $t1, 9 #constant li $t2, 10 #constant; counter compare point li $t3, 11 #constant li $t4, 12 #constant li $t5, 13 #constant li $t6, 14 #constant li $t7, 15 #constant; counter compare point li $t8, 0 #question counter li $t9, 0 #increment counter li $a3, 0 #decrement counter li $a1, 100 #constant
issue presenting instead of questions (those eqnums) running course , counter incrementing or decrementing fully, if @ time 1 question wrong, etally branch off loss. results in rest of questions being cut off/not run , main menu popping up. tried doing 'blt' instead of 'bltu' , tried using increment counter instead of both increment , decrement counters found none of these solves problem.
code 1k lines here link full source code. easy section lines 165 299.
figured out help! jester right- $t8 initialized 0 instead of 1 , throwing off!
Comments
Post a Comment