Assembler Developer

Moderators: None (Apply to moderate this forum)
Number of threads: 960
Number of posts: 1752

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
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
#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.



 

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
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.