## Assembler Developer

Moderators: None (Apply to moderate this forum)
Number of posts: 1756

This Forum Only

Need some help with MIPS Code Posted by obsidian13 on 12 Apr 2012 at 7:47 AM
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

#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:
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
j compareExp

shift2: #shift the smaller number to the right
srl \$t8,\$t8,1
j compareExp

sll \$t4,\$s3,31 #sign
sll \$t5,\$s6,23 #exponent

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.

## Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic