Annotation of Net2/arch/tahoe/math/kdivd.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:  *     @(#)Kdivd.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:        .text
        !            46: ENTRY(Kdivd, R9|R8|R7|R6|R5|R4|R3|R2)
        !            47:        clrl    r3              # r3 - sign: 0 for positive,1 for negative.
        !            48:        movl    4(fp),r0
        !            49:        jgeq    1f
        !            50:        movl    $1,r3
        !            51: 1:     movl    12(fp),r2
        !            52:        jgeq    2f
        !            53:        bbc     $0,r3,1f        # seconed operand is negative.
        !            54:        clrl    r3              # if first was negative, make result positive.
        !            55:        jmp     2f
        !            56: 1:     movl    $1,r3           # if first was positive, make result negative.
        !            57: 2:     andl2   $EXPMASK,r0     # compute first 'pure'exponent.
        !            58:        jeql    retz
        !            59:        shrl    $EXPSHIFT,r0,r0
        !            60:        subl2   $BIAS,r0        
        !            61:        andl2   $EXPMASK,r2     # compute seconed 'pure'exponent.
        !            62:        jeql    retz2
        !            63:        shrl    $EXPSHIFT,r2,r2
        !            64:        subl2   $BIAS,r2
        !            65:        subl3   r2,r0,r2        # subtruct the exponents.
        !            66:        addl2   $BIAS,r2
        !            67:        jleq    underf
        !            68:                                # normalization can make the exp. smaller.
        !            69:  #
        !            70:  #     We have the sign in r3,the exponent in r2,now is the time to
        !            71:  #     perform the division...
        !            72:  #
        !            73:        # fetch dividend. (r4,r5)
        !            74:        andl3   $(0!(EXPMASK | SIGNBIT)),4(fp),r4
        !            75:        orl2    $(0!CLEARHID),r4
        !            76:        movl    8(fp),r5
        !            77:  
        !            78:        # fetch divisor : (r6,r7)
        !            79:        andl3   $(0!(EXPMASK | SIGNBIT)),12(fp),r6
        !            80:        orl2    $(0!CLEARHID),r6
        !            81:        movl    16(fp),r7
        !            82: 
        !            83:        movl    $0,r0           # init r0,r1 to be zeros
        !            84:        movl    $0,r1
        !            85:        movl    $(0!CLEARHID),r8# r8 first bit to set (if).
        !            86:        shll    $1,r8,r8        # to have one more bit,because we might
        !            87:                                # have to shift left to normelize.
        !            88:        movl    $0,r9
        !            89: 
        !            90: 2:
        !            91:        subl2   r7,r5
        !            92:        sbwc    r6,r4
        !            93:        jgeq    1f
        !            94:        addl2   r7,r5
        !            95:        adwc    r6,r4
        !            96:        shlq    $1,r4,r4
        !            97:        shrq    $1,r8,r8
        !            98:        jeql    over
        !            99:        jmp     2b
        !           100: 1:     
        !           101:        orl2    r8,r0
        !           102:        orl2    r9,r1
        !           103:        shlq    $1,r4,r4
        !           104:        shrq    $1,r8,r8
        !           105:        jneq    2b
        !           106:        
        !           107: over:
        !           108:        pushl   20(fp)
        !           109:        callf   $8,_Kfnorm
        !           110: sign:
        !           111: 1:     bbc     $0,r3,done
        !           112:        orl2    $SIGNBIT,r0
        !           113: done:  ret
        !           114: 
        !           115: retz:
        !           116:          clrl  r0
        !           117:          clrl  r1
        !           118:          ret
        !           119: 
        !           120: retz2: bbc     $31,12(fp),z_div
        !           121:          clrl  r0
        !           122:          clrl  r1
        !           123:          ret
        !           124: underf:
        !           125:        orl2    $HFS_UNDF,*20(fp)       
        !           126:        ret
        !           127: z_div:
        !           128:        orl2    $HFS_DIVZ,*20(fp)
        !           129:        ret

unix.superglobalmegacorp.com

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