I need some help with a project for one of my classes, I cant seem to find the problem in my code thats keeping it from working. Here is what the project is, its implementing floating point addition using only integers.
Your goal for this project is to implement software emulation of floating point
addition for 32-bit (single-precision) floating point numbers.
Input/Output
Your program will prompt the user for two floating point numbers. It will then compute and display the sum. Here’s example I/O from four runs (you only need to prompt once per execution run):
Enter a floating-point value: 1
Enter a floating-point value: 1
2.000000000000000000
Here is my code: $t0, $t1 are the two floating points the program reads and then it starts here
#Floating Point addition
#get signs
srl $s3,$t0,31 #$s3 = first value SIGN
srl $s4,$t1,31 #$s4 = second value SIGN
#get exponent
sll $s5,$t0,1 #get the exponent value
srl $s5,$s5,24 #$s5 = first value EXPONENT
sll $s6,$t1,1 #get the exponent value
srl $s6,$s6,24 #$s6 = second value EXPONENT
#get fraction
srl $s7,$t0,9 #$s7 = first value FRACTION
srl $t8,$t1,9 #$t8 = second value FRACTION
compareExp:
beq $s5,$s6, addSig
blt $s5,$s6, shift1 #if first < second
blt $s6,$s5, shift2 #if second < first
j compareExp
shift1: #shift the smaller number to the right
srl $s7,$s7,1
addi $s5,$s5,1
j compareExp
shift2: #shift the smaller number to the right
srl $t8,$t8,1
addi $s6,$s6,1
j compareExp
addSig:
add $t3,$s7,$t8 #add significands
sll $t4,$s3,31 #sign
sll $t5,$s6,23 #exponent
add $t6,$t4,$t5
add $t6,$t6,$t3
mtc1 $t6,$f12
li $v0, 2
syscall
Im not asking for a solution because i know thats cheating but i was wondering if someone could point me in the right direction as to fixing whats wrong because i cant find the problem in my code. Thanks.