Annotation of 43BSDReno/lib/libc/tahoe/fpe/divf.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 "@(#)divf.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(divf, R2|R3|R4|R5|R6|R7|R8|R9)
        !            33:        clrl    r1
        !            34:        clrl    r3              # r3 - sign: 0 for positive,1 for negative.
        !            35:        movl    4(fp),r0
        !            36:        jgeq    1f
        !            37:        movl    $1,r3
        !            38: 1:     movl    12(fp),r2
        !            39:        jgeq    2f
        !            40:        bbc     $0,r3,1f        # seconed operand is negative.
        !            41:        clrl    r3              # if first was negative, make result positive.
        !            42:        jmp     2f
        !            43: 1:     movl    $1,r3           # if first was positive, make result negative.
        !            44: 2:     andl2   $EXPMASK,r0     # compute first 'pure'exponent.
        !            45:        jeql    is_res1
        !            46:        shrl    $EXPSHIFT,r0,r0
        !            47:        subl2   $BIAS,r0        
        !            48:        andl2   $EXPMASK,r2     # compute seconed 'pure'exponent.
        !            49:        jeql    is_res2
        !            50:        shrl    $EXPSHIFT,r2,r2
        !            51:        subl2   $BIAS,r2
        !            52:        subl3   r2,r0,r2        # subtruct the exponents.
        !            53:        addl2   $BIAS,r2
        !            54:        jleq    underf
        !            55:                                # normalization can make the exp. smaller.
        !            56:  #
        !            57:  #     We have the sign in r3,the exponent in r2,now is the time to
        !            58:  #     perform the division...
        !            59:  #
        !            60:        # fetch dividend. (r0)
        !            61:        andl3   $(0!(EXPMASK | SIGNBIT)),4(fp),r0
        !            62:        orl2    $(0!CLEARHID),r0
        !            63:        clrl    r1
        !            64:  
        !            65:        # fetch divisor : (r6)
        !            66:        andl3   $(0!(EXPMASK | SIGNBIT)),12(fp),r6
        !            67:        orl2    $(0!CLEARHID),r6
        !            68: 
        !            69:        shll    $2,r6,r6        # make the divisor bigger so we will not
        !            70:                                # get overflow at the divission.
        !            71:        ediv    r6,r0,r0,r7     # quo to r0, rem to r7
        !            72:        subl2   $6,r2           # to compensate for: normalization (-24),
        !            73:                                # ediv (+32), shifting r6 (-2).
        !            74:        
        !            75: over:
        !            76:        callf   $4,fnorm        # we can use fnorm because we have data
        !            77:                                # at r1 as well.(sfnorm takes care only 
        !            78:                                # of r0).
        !            79: sign:
        !            80: 1:     bbc     $0,r3,done
        !            81:        orl2    $SIGNBIT,r0
        !            82: done:  ret
        !            83: 
        !            84: is_res1:
        !            85:        bbc     $31,4(fp),retz
        !            86:        callf   $4,sfpresop
        !            87:        ret
        !            88: is_res2:
        !            89:        bbc     $31,12(fp),z_div
        !            90:        callf   $4,sfpresop
        !            91:        ret
        !            92: retz:
        !            93:          clrl  r0
        !            94:          ret
        !            95: underf:
        !            96:        callf   $4,sfpunder
        !            97:        ret
        !            98: z_div:
        !            99:        callf   $4,sfpzdiv
        !           100:        ret

unix.superglobalmegacorp.com

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