Annotation of 43BSDReno/sys/tahoemath/Kcvtld.s, revision 1.1

1.1     ! root        1: /*     Kcvtld.s        1.3     86/01/05        */
        !             2: 
        !             3: #include "../tahoemath/fp.h"
        !             4: #include "../tahoemath/Kfp.h"
        !             5: #include "../tahoe/SYS.h"
        !             6: 
        !             7:        .text
        !             8: ENTRY(Kcvtld, R5|R4|R3|R2)
        !             9:        clrl    r4              # r4 - negative flag.
        !            10:        clrl    r2              # r2 - exponent.
        !            11:        movl    12(fp),r0       # fetch operand.
        !            12:        movl    r0,r5           # need another copy.
        !            13:        jeql    retzero         # return zero.
        !            14:        jgtr    positive
        !            15:        mnegl   r0,r0
        !            16:        jvs     retmin          # return minimum integer.
        !            17:        incl    r4              # remember it was negative.
        !            18:        movl    r0,r5           # remember the negated value.
        !            19:  #
        !            20:  #Compute exponent:
        !            21:  #
        !            22: positive:
        !            23:        ffs     r0,r1
        !            24:        incl    r1
        !            25:        addl2   r1,r2
        !            26:        shrl    r1,r0,r0
        !            27:        jneq    positive        # look for more set bits.
        !            28:  #
        !            29:  #we have the exponent in r2.
        !            30:  #
        !            31:        movl    r5,r0           # r0,r1 will hold the resulting f.p. number.
        !            32:        clrl    r1
        !            33:  #
        !            34:  #Shift the fraction part to its proper place:
        !            35:  #
        !            36:        subl3   r2,$HID_POS,r3
        !            37:        jlss    shiftr          # if less then zero we have to shift right.
        !            38:        shll    r3,r0,r0        # else we shift left.
        !            39:        jmp     shifted
        !            40: shiftr:
        !            41:        mnegl   r3,r3
        !            42:        shrq    r3,r0,r0
        !            43: shifted:
        !            44:        andl2   $CLEARHID,r0    # clear the hidden bit.
        !            45:        shal    $EXPSHIFT,r2,r2 # shift the exponent to its proper place.
        !            46:        orl2    $EXPSIGN,r2     # set the exponent sign bit(to bias it).
        !            47:        orl2    r2,r0           # combine exponent & fraction.
        !            48:        bbc     $0,r4,sign_ok   # do we  have to set the sign bit?
        !            49:        orl2    $SIGNBIT,r0     # yes...
        !            50: sign_ok:
        !            51:        ret
        !            52: 
        !            53: retzero:
        !            54:        clrl    r0
        !            55:        clrl    r1
        !            56:        ret
        !            57: 
        !            58: retmin:
        !            59:        movl    $0xd0000000,r0
        !            60:        clrl    r1
        !            61:        ret
        !            62: 
        !            63: 
        !            64:        

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.