Selaa lähdekoodia

Fix some comments

master
Christos Choutouridis 4 vuotta sitten
vanhempi
commit
63b81a9496
1 muutettua tiedostoa jossa 28 lisäystä ja 25 poistoa
  1. +28
    -25
      fpmul.asm

+ 28
- 25
fpmul.asm Näytä tiedosto

@@ -2,12 +2,12 @@
.globl main
main:
# intro - stack-frame
addi $sp, $sp, -8 # main
addi $sp, $sp, -8 # main
sw $ra, 4($sp)
sw $fp, 0($sp)
addi $fp, $sp, 0 # stack arguments (no)
addi $fp, $sp, 0 # stack arguments (no)

li $a0, 0xbf800000 # <-- test case goes here
li $a0, 0xbf800000 # <-- test case goes here
li $a1, 0x3f800000
jal multFloat

@@ -27,18 +27,18 @@ main:
# $v0: The floating point word
encodeFloat:
# intro - stack-frame
addi $sp, $sp, -8 # encodeFloat
addi $sp, $sp, -8 # encodeFloat
sw $ra, 4($sp)
sw $fp, 0($sp)
addi $fp, $sp, 0 # stack arguments (no)
addi $fp, $sp, 0 # stack arguments (no)
sll $v0, $a0, 31 # v0 = sign << 31
sll $v0, $a0, 31 # v0 = sign << 31
addi $a1, $a1, 127 # v0 |= (exp + offset) << 23
addi $a1, $a1, 127 # v0 |= (exp + offset) << 23
sll $a1, $a1, 23
or $v0, $v0, $a1
li $t0, 0x7FFFFF # v0 |= (mant & 0x7FFFFF);
li $t0, 0x7FFFFF # v0 |= (mant & 0x7FFFFF);
and $a2, $a2, $t0
or $v0, $v0, $a2

@@ -49,7 +49,7 @@ encodeFloat:
jr $ra

#
# decodeFloat
# decodeFloat(number)
# arguments
# $a0 : 32bit floating point
# return
@@ -81,7 +81,7 @@ decodeFloat:
jr $ra # return
#
# multFloat
# multFloat(f1, f2)
# arguments
# $a0 : 32bit floating point 1
# $a1 : 32bit floating point 2
@@ -100,15 +100,15 @@ multFloat:
sw $s0, 0($sp)
addi $fp, $sp, 0 # stack arguments (no)

move $s0, $a1
jal decodeFloat #[v0, v1, a1] <- [s, e, m]
move $t0, $s0 # change variable
move $s0, $v0
move $s0, $a1 # save 2nd argument
jal decodeFloat # decodeFloat(arg1) : [v0, v1, a1] <- [s, e, m]
move $t0, $s0 # $s0 change variable to $t0
move $s0, $v0 # load return values to variable regs
move $s1, $v1
move $s2, $a1
move $a0, $t0 # load argument 2
jal decodeFloat # [v0, v1, a1] <- [s, e, m]
move $a0, $t0 # load back argument 2
jal decodeFloat # decodeFloat(arg2) : [v0, v1, a1] <- [s, e, m]
xor $s0, $s0, $v0 # sign = s1 ^ s2
add $s1, $s1, $v1 # exp = e1 + e2
@@ -120,25 +120,25 @@ multFloat:
li $t9, 0x8000 # if (HI & (1<<15))
and $t8, $t9, $t4
beq $t8, $zero, _multf_l0
# not zero
# (true)not zero, 48-bits result, normalize
sll $s2, $t4, 8 # mant = HI << 8
srl $t9, $t3, 24 # mant |= LOW >> (32-8)
or $s2, $s2, $t9
addi $s1, $s1, 1 # ++exp
li $t9, 0x800000 # if (ml & (1<<23)), check to normalize
addi $s1, $s1, 1 # ++exp, normalize
li $t9, 0x800000 # if (ml & (1<<23)), rounding check
and $t8, $t9, $t3
beq $t8, $zero, _multf_l0_end
addi $s2, $s2, 1 # ++mant
addi $s2, $s2, 1 # ++mant, round-up
j _multf_l0_end
_multf_l0:
# zero
# (false)zero, 47-bits result
sll $s2, $t4, 9 # mant = HI << 9
srl $t9, $t3, 23 # mant |= LOW >> (32-9)
or $s2, $s2, $t9
li $t9, 0x400000 # if (ml & (1<<22)), check to normalize
li $t9, 0x400000 # if (ml & (1<<22)), rounding check
and $t8, $t9, $t3
beq $t8, $zero, _multf_l0_end
addi $s2, $s2, 1 # ++mant
addi $s2, $s2, 1 # ++mant, round-up
_multf_l0_end:

move $a0, $s0
@@ -157,9 +157,12 @@ multFloat:
#
# fprod(x,n) Calculates the product x[0]*x[1]*x[2]*...x[n-1]
# fprod(vector, size)
# Calculates the product x[0] * x[1] * x[2] * ... * x[n-1] as
# Left fold of product operator on a vector of numbers - foldl(*, x)
#
# Arguments
# $a0: Pointer to array x[] RAM
# $a0: Pointer to array x[] in RAM
# $a1: Number of elements
# Return
# $v0: The product


Loading…
Peruuta
Tallenna