I'm sure this is the most belabored question here as this comes from a school assignment but I have perused google for far too long. Can someone help me get this code to output? I've tried putting the li, print_int calls in both loops and keep getting weird answers. This code comes from a previous answer so I've changed the registers to what MIPS uses, the shifts originally ended with 31, I changed them to 1, and the ending jr call was to $31, I changed it to $ra. My minor changes don't seem to help, so could someone with analytical abilities in Logic and Computer Systems help, as I'm sure it's only a line of code that needs to be fixed.
# input
# $t0 = op1
# $t1 = op2
# output
# $t0 = res
#
# $t2 = sign
# $t3 = temp
# $t4 = acc/current total
# $t5 = temp for 0 comparison
.text
.align 2
.globl main
main:
la $a0,prompt1 # prompt user for input
li $v0,4
syscall
li $v0,5 # read keyboard into $v0
syscall
move $t0,$v0 # first number in $t0
la $a0,prompt2 # prompt user for input
li $v0,4
syscall
li $v0,5 # read keyboard into $v0
syscall
move $t1,$v0 # second number in $t1
smult:
sra $t2,$t0,1 # sign = asr op1,1
xor $t0,$t0,$t2 # invert op1s bits if < 0
sub $t0,$t0,$t2 # add 1 if < 0
sra $t3,$t1,1 # same but for op2
xor $t1,$t1,$t3
sub $t1,$t1,$t3
xor $t2,$t2,$t3 # save the sign of mult
xor $t4,$t4,$t4 # init res acc mov $t4,0
xor $t5,$t5,$t5 # used for 0 cmp
j lmult_start
lmult_loop:
andi $t3,$t1,1 # get lsb of op2
sll $t3,$t3,1 # if set add op1 to res acc
sra $t3,$t3,1
and $t3,$t3,$t0
add $t4,$t4,$t3
sll $t0,$t0,1 # shift op1 left 1
srl $t1,$t1,1 # and op2 right 1
li $t0,1
syscall
lmult_start:
bne $t1,$t5,lmult_loop # break when op2 is 0
addi $t0,$t4,0 # put result in $t0
xor $t0,$t0,$t2 # invert if sign is negative
sub $t0,$t0,$t2
li $t0,1
syscall
jr $ra # return
.data
prompt1:
.asciiz "\n\nEnter the first number "
prompt2:
.asciiz "Enter the second number "