Abstract Your goal for this project is to implement software emulation of floating point addition for 32-bit (single-precision) floating point numbers in MIPs.
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
Enter a floating-point value: 2.2 Enter a floating-point value: 1.4 3.599999904632568400
Issues to Resolve Here’s a few issues: How will you deal with negative values? How will your normalizing algorithm work? What’s the easiest way to access bit fields within a word?
*You may not use any floating-point instructions for this project!!*
I have done the same in integers but need some help in floating point without using them! .data st1: .asciiz "\nIn binary:\n" st2: .asciiz "\nEnter 1st Integer:" st3: .asciiz "\nEnter 2nd Integer:" st4: .asciiz "\nYour answer is: " st5: .asciiz "\n--------------------------------\n" st6: .asciiz "\n"
.text
main:
la $a0,st2 # Put the address of the string in $a0
li $v0, 4
syscall
li $v0, 5 # Code for input integer
syscall
move $s1, $v0 #storing first integer in s1
la $a0,st3 # Put the address of the string in $a0
li $v0, 4
syscall
li $v0, 5 # Code for input integer
syscall
move $s2, $v0 #storing second integer in s2
add $s0,$s2,$s1 #add and store in t3
la $a0,st4 #text to display
li $v0,4
syscall
li $v0,1 #for printing int
move $a0,$s0 # move s0 to a0 to print s0
syscall
la $a0,st1
li $v0,4
syscall
move $t3,$s0
move $t2,$s2
move $t1,$s1
li $s5,32 # set up counter
loop1:
rol $t1,$t1,1 #roll the bit left by on bit high to low
and $t0,$t1,1 #mask off low bit
add $t0,$t0,48 #combine t0 with 48 to form 1 or 0
move $a0,$t0 #output ascii character
li $v0,11
syscall
li $t5,1
sub $s5,$s5,$t5 #decrement counter
bne $s5,$zero,loop1 #keep loop if not zero
la $a0,st6
li $v0,4
syscall
li $s5,32
loop2:
rol $t2,$t2,1 #roll the bit left by on bit high to low
and $t0,$t2,1 #mask off low bit
add $t0,$t0,48 #combine t0 with 48 to form 1 or 0
move $a0,$t0 #output ascii character
li $v0,11
syscall
li $t5,1
sub $s5,$s5,$t5 #decrement counter
bne $s5,$zero,loop2 #keep loop if not zero
la $a0,st5 #line
li $v0,4
syscall
li $s5,32
loop:
rol $t3,$t3,1 #roll the bit left by on bit high to low
and $t0,$t3,1 #mask off low bit
add $t0,$t0,48 #combine t0 with 48 to form 1 or 0
move $a0,$t0 #output ascii character
li $v0,11
syscall
li $t5,1
sub $s5,$s5,$t5 #decrement counter
bne $s5,$zero,loop #keep loop if not zero
li $v0,10 #close the program
syscall
.end main
1- Use IEEE 754 to represent your floating point numbers 2- Add up the exponents, then add up the significands, check if you need to increase the exponent 3- Deal with negative signs (2's complement, single bit the first one represents sign)
This is a pretty easy problem and I agree with the comments above, I just thought you could use some good hints Good luck!