Annotation of Net2/arch/tahoe/math/kmulf.s, revision 1.1

1.1     ! root        1: /*-
        !             2:  * Copyright (c) 1985 The 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, with or without
        !             9:  * modification, are permitted provided that the following conditions
        !            10:  * are met:
        !            11:  * 1. Redistributions of source code must retain the above copyright
        !            12:  *    notice, this list of conditions and the following disclaimer.
        !            13:  * 2. Redistributions in binary form must reproduce the above copyright
        !            14:  *    notice, this list of conditions and the following disclaimer in the
        !            15:  *    documentation and/or other materials provided with the distribution.
        !            16:  * 3. All advertising materials mentioning features or use of this software
        !            17:  *    must display the following acknowledgement:
        !            18:  *     This product includes software developed by the University of
        !            19:  *     California, Berkeley and its contributors.
        !            20:  * 4. Neither the name of the University nor the names of its contributors
        !            21:  *    may be used to endorse or promote products derived from this software
        !            22:  *    without specific prior written permission.
        !            23:  *
        !            24:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            25:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            26:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            27:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            28:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            29:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            30:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            31:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            32:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            33:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            34:  * SUCH DAMAGE.
        !            35:  *
        !            36:  *     @(#)Kmulf.s     7.1 (Berkeley) 12/6/90
        !            37:  */
        !            38: 
        !            39: #include "../math/fp.h"
        !            40: #include "../math/Kfp.h"
        !            41: #include "../tahoe/SYS.h"
        !            42: 
        !            43: #define        HIDDEN  23      /* here we count from 0 not from 1 as in fp.h */
        !            44: 
        !            45: /* 
        !            46:  * _Kmulf(acc_most,acc_least,op_most,op_least,hfs)
        !            47:  */
        !            48:        .text
        !            49: ENTRY(Kmulf, R5|R4|R3|R2)
        !            50:        clrl    r3              /* r3 - sign: 0 for positive,1 for negative. */
        !            51:        movl    4(fp),r0
        !            52:        jgeq    1f
        !            53:        movl    $1,r3
        !            54: 1:     movl    12(fp),r2
        !            55:        jgeq    2f
        !            56:        bbc     $0,r3,1f        /* seconed operand is negative. */
        !            57:        clrl    r3              /* if first was negative, make result positive. */
        !            58:        jmp     2f
        !            59: 1:     movl    $1,r3           /* if first was positive, make result negative. */
        !            60: 2:     andl2   $EXPMASK,r0     /* compute first 'pure'exponent. */
        !            61:        jeql    retzero
        !            62:        shrl    $EXPSHIFT,r0,r0
        !            63:        subl2   $BIASP1,r0      
        !            64:        andl2   $EXPMASK,r2     /* compute seconed 'pure'exponent. */
        !            65:        jeql    retzero
        !            66:        shrl    $EXPSHIFT,r2,r2
        !            67:        subl2   $BIASP1,r2
        !            68:        addl2   r0,r2           /* add the exponents. */
        !            69:        addl2   $(BIASP1+2),r2
        !            70:        jleq    underflow
        !            71:        cmpl    r2,$258         /* normalization can make the exp. smaller. */
        !            72:        jgeq    overflow
        !            73:  /*
        !            74:  *     We have the sign in r3,the exponent in r2,now is the time to
        !            75:  *     perform the multiplication...
        !            76:  */
        !            77:        /* fetch first fraction: (r0) */
        !            78:        andl3   $(0!(EXPMASK | SIGNBIT)),4(fp),r0
        !            79:        orl2    $(0!CLEARHID),r0
        !            80:        shll    $7,r0,r0        /* leave the sign bit cleared. */
        !            81:  
        !            82:        /* fetch seconed fraction: (r4) */
        !            83:        andl3   $(0!(EXPMASK | SIGNBIT)),12(fp),r4
        !            84:        orl2    $(0!CLEARHID),r4
        !            85:        shll    $7,r4,r4        /* leave the sign bit cleared. */
        !            86: 
        !            87:  
        !            88:        emul    r4,r0,$0,r0
        !            89:        movl    r0,r4           /* to see how much we realy need to shift. */
        !            90:        movl    $6,r5           /* r5 - shift counter. */
        !            91:        shrl    $7,r4,r4        /* dummy shift. */
        !            92: 1:     bbs     $HIDDEN,r4,realshift
        !            93:        shll    $1,r4,r4
        !            94:        decl    r2              /* update exponent. */
        !            95:        jeql    underflow
        !            96:        decl    r5              /* update shift counter. */
        !            97:        jmp     1b
        !            98: realshift:
        !            99:        shrl    r5,r0,r0
        !           100:        bbc     $0,r1,shiftmore
        !           101:        incl    r1              /* rounding. */
        !           102: shiftmore:
        !           103:        shrl    $1,r0,r0
        !           104: comb:
        !           105:        andl2   $CLEARHID,r0
        !           106:        shll    $EXPSHIFT,r2,r4
        !           107:        orl2    r4,r0
        !           108:        cmpl    r2,$256
        !           109:        jlss    1f
        !           110:        orl2    $HFS_OVF,*20(fp)        
        !           111: sign:
        !           112: 1:     bbc     $0,r3,done
        !           113:        orl2    $SIGNBIT,r0
        !           114: done:  ret
        !           115: 
        !           116: 
        !           117: 
        !           118:   retzero:
        !           119:          clrl  r0
        !           120:          ret
        !           121:   overflow:
        !           122:        orl2    $HFS_OVF,*20(fp)        
        !           123:        jmp     sign
        !           124:   underflow:
        !           125:        orl2    $HFS_UNDF,*20(fp)       
        !           126:        ret
        !           127: 
        !           128: 
        !           129:        

unix.superglobalmegacorp.com

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