Annotation of 43BSDTahoe/lib/libc/tahoe/fpe/muld.s, revision 1.1.1.1

1.1       root        1: #ifdef LIBC_SCCS
                      2:        .asciz  "@(#)muld.s     1.1 (Berkeley/CCI) 7/2/86"
                      3: #endif LIBC_SCCS
                      4: 
                      5: #include <tahoemath/fp.h>
                      6: #include "DEFS.h"
                      7: 
                      8: #define        HIDDEN  23      /* here we count from 0 not from 1 as in fp.h */
                      9: 
                     10: XENTRY(muld, R2|R3|R4|R5|R6|R7|R8|R9)
                     11:        clrl    r3              /* r3 - sign: 0 for positive,1 for negative. */
                     12:        movl    4(fp),r0
                     13:        jgeq    1f
                     14:        movl    $1,r3
                     15: 1:     movl    12(fp),r2
                     16:        jgeq    2f
                     17:        bbc     $0,r3,1f        /* seconed operand is negative. */
                     18:        clrl    r3              /* if first was negative, make result positive. */
                     19:        jmp     2f
                     20: 1:     movl    $1,r3           /* if first was positive, make result negative. */
                     21: 2:     andl2   $EXPMASK,r0     /* compute first 'pure'exponent. */
                     22:        jeql    is_res1
                     23:        shrl    $EXPSHIFT,r0,r0
                     24:        subl2   $BIASP1,r0      
                     25:        andl2   $EXPMASK,r2     /* compute seconed 'pure'exponent. */
                     26:        jeql    is_res2
                     27:        shrl    $EXPSHIFT,r2,r2
                     28:        subl2   $BIASP1,r2
                     29:        addl2   r0,r2           /* add the exponents. */
                     30:        addl2   $(BIASP1+2),r2
                     31:        jleq    underflow
                     32:        cmpl    r2,$258         /* normalization can make the exp. smaller. */
                     33:        jgeq    overflow
                     34:  /*
                     35:  *     We have the sign in r3,the exponent in r2,now is the time to
                     36:  *     perform the multiplication...
                     37:  */
                     38:        /* fetch first fraction: (r0,r1) */
                     39:        andl3   $(0!(EXPMASK | SIGNBIT)),4(fp),r0
                     40:        orl2    $(0!CLEARHID),r0
                     41:        movl    8(fp),r1
                     42:        shlq    $7,r0,r0        /* leave the sign bit cleared. */
                     43:  
                     44:        /* fetch seconed fraction: (r4,r5) */
                     45:        andl3   $(0!(EXPMASK | SIGNBIT)),12(fp),r4
                     46:        orl2    $(0!CLEARHID),r4
                     47:        movl    16(fp),r5
                     48:        shlq    $7,r4,r4        /* leave the sign bit cleared. */
                     49: 
                     50:        /* in the following lp1 stands for least significant part of operand 1,
                     51:        *                  lp2 for least significant part of operand 2,
                     52:        *                  mp1 for most significant part of operand 1,
                     53:        *                  mp2 for most significant part of operand 2.
                     54:        */
                     55:  
                     56:        clrl    r6
                     57:        shrl    $1,r1,r1        /* clear the sign bit of the lp1. */
                     58:        jeql    1f
                     59:        emul    r1,r4,$0,r6     /* r6,r7 <-- lp1*mp2 */
                     60:        shlq    $1,r6,r6        /* to compensate for the shift we did to clear the sign bit. */
                     61: 1:     shrl    $1,r5,r5        /* clear the sign bit of the lp2. */
                     62:        jeql    1f
                     63:        emul    r0,r5,$0,r8     /* r8,r9 <-- mp1*lp2 */
                     64:        shlq    $1,r8,r8
                     65:        addl2   r9,r7           /* r6,r7 <-- the sum of the products. */
                     66:        adwc    r8,r6
                     67: 1:     emul    r0,r4,$0,r0     /* r0,r1 <-- mp1*mp2  */
                     68:        addl2   r6,r1           /* add the most sig. part of the sum. */
                     69:        adwc    $0,r0
                     70:        movl    r0,r4           /* to see how much we realy need to shift. */
                     71:        movl    $6,r5           /* r5 - shift counter. */
                     72:        shrl    $7,r4,r4        /* dummy shift. */
                     73: 1:     bbs     $HIDDEN,r4,realshift
                     74:        shll    $1,r4,r4
                     75:        decl    r2              /* update exponent. */
                     76:        jeql    underflow
                     77:        decl    r5              /* update shift counter. */
                     78:        jmp     1b
                     79: realshift:
                     80:        shrq    r5,r0,r0
                     81:        bbc     $0,r1,shiftmore
                     82:        incl    r1              /* rounding. */
                     83: shiftmore:
                     84:        shrq    $1,r0,r0
                     85: comb:
                     86:        andl2   $CLEARHID,r0
                     87:        shll    $EXPSHIFT,r2,r4
                     88:        orl2    r4,r0
                     89:        cmpl    r2,$256
                     90:        jlss    1f
                     91:        callf   $4,fpover
                     92: sign:
                     93: 1:     bbc     $0,r3,done
                     94:        orl2    $SIGNBIT,r0
                     95: done:  ret
                     96: 
                     97: 
                     98: 
                     99: is_res1:
                    100:        bbc     $31,4(fp),retzero
                    101:        callf   $4,fpresop
                    102:        ret
                    103: is_res2:
                    104:        bbc     $31,12(fp),retzero
                    105:        callf   $4,fpresop
                    106:        ret
                    107:   retzero:
                    108:          clrl  r0
                    109:          clrl  r1
                    110:          ret
                    111:   overflow:
                    112:        callf   $4,fpover
                    113:        jmp     sign
                    114:   underflow:
                    115:        callf   $4,fpunder
                    116:        ret

unix.superglobalmegacorp.com

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