Question: I have written the following program according to the attached image. With my testing, I believe the issue with the program is in the subtraction

I have written the following program according to the attached image. With my testing, I believe the issue with the program is in the subtraction in Step1. Please help me with getting the subtraction to work correctly, as I believe that it is the only thing holding this program back from working correctly.
.data
prompt1: .asciiz "Enter Dividend: "
prompt2: .asciiz "
Enter Divisor: "
ans1: .asciiz "
Quotient: "
ans2: .asciiz "
Remainder: "
.text
.globl main
main:
# print prompt1
la $a0, prompt1
li $v0,4
syscall
# take in dividend
li $v0,5
syscall
# place in remainder reg
li $t0,0
move, $t1, $v0
# print prompt2
la $a0, prompt2
li $v0,4
syscall
# take in divisor
li $v0,5
syscall
move $t2, $v0
li $t3,0
# initialize quotient reg
li $t4,0
# initialize loop counter
li $t5,32
Step1:
addi $t5, $t5,-1 # decrement loop counter
#sub $t0, $t0, $t2 # subtract remainder by divisor
#sub $t0, $t0, $t3
subu $t7, $t2, $t0
sltu $t8, $t2, $t0
subu $t0, $t3, $t8
bltz $t0, Step2b
Step2a:
sll $t4, $t4,1 # shift quotient
ori $t4, $t4,1 # set LSB to 1
j Step3
Step2b:
add $t0, $t0, $t2 # rem = rem + div
sll $t4, $t4,1 # shift quotient
Step3:
andi $t6, $t2,1 # extract LSB of left divisor
sll $t6, $t6,31 # shift bit to MSB
srl $t2, $t2,1 # shift left divisor left
srl $t3, $t3,1 # shift right divisor left
or $t3, $t3, $t6 # set MSB of right divisor
bnez $t5, Step1
Done:
# print ans1
la $a0, ans1
li $v0,4
syscall
# print quotient
move $a0, $t4
li $v0,1
syscall
# print ans2
la $a0, ans2
li $v0,4
syscall
# print remainder
move $a0, $t1
li $v0,1
syscall
li $v0,10
syscall
I have written the following program according to

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!