Next Generation Emulation banner
1 - 1 of 1 Posts

· Registered
Joined
·
1 Posts
Discussion Starter · #1 ·
Hi , i'm working now on "PCSpim multiplication of IEEE double floating numbers" and my attempts to multiply them without using FP unit failed so i would be very gratefull if someone could give me a hand and say why it dosen't work : .data
title: .asciiz "\n\nFLOATING POINT MULTIPLICATION PROGRAM\n\n"
prm1: .asciiz "Enter the first float:\n"
prm2: .asciiz "Enter the second float:\n"
fin1: .asciiz "\nThe result from FPU:\n"
fin2: .asciiz "\nThe result from CPU loaded to FPU:\n"
arg1: .space 32
arg2: .space 32

.text
main :
li $v0,4 #title
la $a0,title
syscall

li $v0,4 #entering fot the fist argument
la $a0,prm1
syscall

li $v0,7
syscall
mov.d $f2,$f0 #first argument in $f2

li $v0,4 #entering for the second argument
la $a0,prm2
syscall

li $v0,7
syscall
mov.d $f4,$f0 #second argument in $f4



### OPERATIONS IN CPU ###

####storing float agruments in CPU registers####
mfc1 $t0,$f3 #first argument in $t0
mfc1 $s4,$f2 #part of mantysa of first argument
mfc1 $s5,$f4 #part of mantysa of second argument

and $t1,$t0,2147483648 #first sign in $t1
and $t2,$t0,2146435072 #first exponent in $t2
and $t3,$t0,1048575 #second mantissa in $t3

mfc1 $t4,$f5 #second argument in $t4

and $t5,$t4,2147483648 #second nr sign in $t5
and $t6,$t4,2146435072 #second nr exponent in $t6
and $t7,$t4,1048575 #second nr mantissa in $t7

xor $s1,$t1,$t5 #final sign in $s1

addu $s0,$t2,$t6 #adding of exponents
addu $s2,$s0,1074790400 #final exponent after adding polarization in $s2
and $s2,$s2,2146435072
move $t1,$0
move $t5,$0
move $t2,$0
move $t6,$0



addu $t3,$t3,1048576
addu $t7,$t7,1048567
addiu $t5,$t5,53
move $t2,$s4
move $t1,$t3

mnoz1:

blez $t5, koniec
and $s3,$s5,1
beq $s3,1,dod1
srl $s4,$s4,1
srl $s5,$s5,1

mnoz2:
and $s7,$t3,1
beq $s7,1,przenies

mnoz3:
and $s6,$t7,1
beq $s6,1,dod2
srl $t3,$t3,1
srl $t7,$t7,1
sub $t5,1
j mnoz1

przenies :
and $s0, $s4,2147483648
addu $s4,$s4,2147483648
beq $s0,0,dod
j mnoz3


dod :
addu $t3,$t3,1
j mnoz3


dod2:


srl $t3,$t3,1
addu $t3,$t3,$t1
sub $t5, 1
j mnoz1

dod1:


srl $s4,$s4,1
addu $s4,$s4,$t2
srl $s5,$s5,1

j mnoz2


koniec:
#addu $s2,$s2,1048576
and $t2,$t3,1047552


or $s6,$s1,$s2 #gluting S3 and E3 together in $s6
or $s7,$s6,$t2 #gluting S3, E3 and M3 together in $s7

### MOVING RESULT TO FPU AND PRINTING IT ###
mtc1 $s7,$f15 #result moved to float register $f6
mtc1 $t3,$f14

li $v0,4
la $a0,fin2
syscall



li $v0,3
mov.d $f12,$f14
syscall
thx from the mountain
 
1 - 1 of 1 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top