Annotation of 43BSDReno/lib/libc/tahoe/fpe/muld.s, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1986 Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * This code is derived from software contributed to Berkeley by
        !             6:  * Computer Consoles Inc.
        !             7:  *
        !             8:  * Redistribution and use in source and binary forms are permitted
        !             9:  * provided that: (1) source distributions retain this entire copyright
        !            10:  * notice and comment, and (2) distributions including binaries display
        !            11:  * the following acknowledgement:  ``This product includes software
        !            12:  * developed by the University of California, Berkeley and its contributors''
        !            13:  * in the documentation or other materials provided with the distribution
        !            14:  * and in all advertising materials mentioning features or use of this
        !            15:  * software. Neither the name of the University nor the names of its
        !            16:  * contributors may be used to endorse or promote products derived
        !            17:  * from this software without specific prior written permission.
        !            18:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
        !            19:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
        !            20:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            21:  */
        !            22: 
        !            23: #if defined(SYSLIBC_SCCS) && !defined(lint)
        !            24:        .asciz "@(#)muld.s      1.3 (Berkeley) 6/1/90"
        !            25: #endif /* SYSLIBC_SCCS and not lint */
        !            26: 
        !            27: #include <tahoemath/fp.h>
        !            28: #include "DEFS.h"
        !            29: 
        !            30: #define        HIDDEN  23      /* here we count from 0 not from 1 as in fp.h */
        !            31: 
        !            32: XENTRY(muld, R2|R3|R4|R5|R6|R7|R8|R9)
        !            33:        clrl    r3              /* r3 - sign: 0 for positive,1 for negative. */
        !            34:        movl    4(fp),r0
        !            35:        jgeq    1f
        !            36:        movl    $1,r3
        !            37: 1:     movl    12(fp),r2
        !            38:        jgeq    2f
        !            39:        bbc     $0,r3,1f        /* seconed operand is negative. */
        !            40:        clrl    r3              /* if first was negative, make result positive. */
        !            41:        jmp     2f
        !            42: 1:     movl    $1,r3           /* if first was positive, make result negative. */
        !            43: 2:     andl2   $EXPMASK,r0     /* compute first 'pure'exponent. */
        !            44:        jeql    is_res1
        !            45:        shrl    $EXPSHIFT,r0,r0
        !            46:        subl2   $BIASP1,r0      
        !            47:        andl2   $EXPMASK,r2     /* compute seconed 'pure'exponent. */
        !            48:        jeql    is_res2
        !            49:        shrl    $EXPSHIFT,r2,r2
        !            50:        subl2   $BIASP1,r2
        !            51:        addl2   r0,r2           /* add the exponents. */
        !            52:        addl2   $(BIASP1+2),r2
        !            53:        jleq    underflow
        !            54:        cmpl    r2,$258         /* normalization can make the exp. smaller. */
        !            55:        jgeq    overflow
        !            56:  /*
        !            57:  *     We have the sign in r3,the exponent in r2,now is the time to
        !            58:  *     perform the multiplication...
        !            59:  */
        !            60:        /* fetch first fraction: (r0,r1) */
        !            61:        andl3   $(0!(EXPMASK | SIGNBIT)),4(fp),r0
        !            62:        orl2    $(0!CLEARHID),r0
        !            63:        movl    8(fp),r1
        !            64:        shlq    $7,r0,r0        /* leave the sign bit cleared. */
        !            65:  
        !            66:        /* fetch seconed fraction: (r4,r5) */
        !            67:        andl3   $(0!(EXPMASK | SIGNBIT)),12(fp),r4
        !            68:        orl2    $(0!CLEARHID),r4
        !            69:        movl    16(fp),r5
        !            70:        shlq    $7,r4,r4        /* leave the sign bit cleared. */
        !            71: 
        !            72:        /* in the following lp1 stands for least significant part of operand 1,
        !            73:        *                  lp2 for least significant part of operand 2,
        !            74:        *                  mp1 for most significant part of operand 1,
        !            75:        *                  mp2 for most significant part of operand 2.
        !            76:        */
        !            77:  
        !            78:        clrl    r6
        !            79:        shrl    $1,r1,r1        /* clear the sign bit of the lp1. */
        !            80:        jeql    1f
        !            81:        emul    r1,r4,$0,r6     /* r6,r7 <-- lp1*mp2 */
        !            82:        shlq    $1,r6,r6        /* to compensate for the shift we did to clear the sign bit. */
        !            83: 1:     shrl    $1,r5,r5        /* clear the sign bit of the lp2. */
        !            84:        jeql    1f
        !            85:        emul    r0,r5,$0,r8     /* r8,r9 <-- mp1*lp2 */
        !            86:        shlq    $1,r8,r8
        !            87:        addl2   r9,r7           /* r6,r7 <-- the sum of the products. */
        !            88:        adwc    r8,r6
        !            89: 1:     emul    r0,r4,$0,r0     /* r0,r1 <-- mp1*mp2  */
        !            90:        addl2   r6,r1           /* add the most sig. part of the sum. */
        !            91:        adwc    $0,r0
        !            92:        movl    r0,r4           /* to see how much we realy need to shift. */
        !            93:        movl    $6,r5           /* r5 - shift counter. */
        !            94:        shrl    $7,r4,r4        /* dummy shift. */
        !            95: 1:     bbs     $HIDDEN,r4,realshift
        !            96:        shll    $1,r4,r4
        !            97:        decl    r2              /* update exponent. */
        !            98:        jeql    underflow
        !            99:        decl    r5              /* update shift counter. */
        !           100:        jmp     1b
        !           101: realshift:
        !           102:        shrq    r5,r0,r0
        !           103:        bbc     $0,r1,shiftmore
        !           104:        incl    r1              /* rounding. */
        !           105: shiftmore:
        !           106:        shrq    $1,r0,r0
        !           107: comb:
        !           108:        andl2   $CLEARHID,r0
        !           109:        shll    $EXPSHIFT,r2,r4
        !           110:        orl2    r4,r0
        !           111:        cmpl    r2,$256
        !           112:        jlss    1f
        !           113:        callf   $4,fpover
        !           114: sign:
        !           115: 1:     bbc     $0,r3,done
        !           116:        orl2    $SIGNBIT,r0
        !           117: done:  ret
        !           118: 
        !           119: 
        !           120: 
        !           121: is_res1:
        !           122:        bbc     $31,4(fp),retzero
        !           123:        callf   $4,fpresop
        !           124:        ret
        !           125: is_res2:
        !           126:        bbc     $31,12(fp),retzero
        !           127:        callf   $4,fpresop
        !           128:        ret
        !           129:   retzero:
        !           130:          clrl  r0
        !           131:          clrl  r1
        !           132:          ret
        !           133:   overflow:
        !           134:        callf   $4,fpover
        !           135:        jmp     sign
        !           136:   underflow:
        !           137:        callf   $4,fpunder
        !           138:        ret

unix.superglobalmegacorp.com

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