Annotation of 43BSDReno/lib/libc/tahoe/fpe/divd.s, revision 1.1.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 "@(#)divd.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(divd, 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   $BIAS,r0        
                     47:        andl2   $EXPMASK,r2     # compute seconed 'pure'exponent.
                     48:        jeql    is_res2
                     49:        shrl    $EXPSHIFT,r2,r2
                     50:        subl2   $BIAS,r2
                     51:        subl3   r2,r0,r2        # subtruct the exponents.
                     52:        addl2   $BIAS,r2
                     53:        jleq    underf
                     54:                                # normalization can make the exp. smaller.
                     55:  #
                     56:  #     We have the sign in r3,the exponent in r2,now is the time to
                     57:  #     perform the division...
                     58:  #
                     59:        # fetch dividend. (r4,r5)
                     60:        andl3   $(0!(EXPMASK | SIGNBIT)),4(fp),r4
                     61:        orl2    $(0!CLEARHID),r4
                     62:        movl    8(fp),r5
                     63:  
                     64:        # fetch divisor : (r6,r7)
                     65:        andl3   $(0!(EXPMASK | SIGNBIT)),12(fp),r6
                     66:        orl2    $(0!CLEARHID),r6
                     67:        movl    16(fp),r7
                     68: 
                     69:        movl    $0,r0           # init r0,r1 to be zeros
                     70:        movl    $0,r1
                     71:        movl    $(0!CLEARHID),r8# r8 first bit to set (if).
                     72:        shll    $1,r8,r8        # to have one more bit,because we might
                     73:                                # have to shift left to normelize.
                     74:        movl    $0,r9
                     75: 
                     76: 2:
                     77:        subl2   r7,r5
                     78:        sbwc    r6,r4
                     79:        jgeq    1f
                     80:        addl2   r7,r5
                     81:        adwc    r6,r4
                     82:        shlq    $1,r4,r4
                     83:        shrq    $1,r8,r8
                     84:        jeql    over
                     85:        jmp     2b
                     86: 1:     
                     87:        orl2    r8,r0
                     88:        orl2    r9,r1
                     89:        shlq    $1,r4,r4
                     90:        shrq    $1,r8,r8
                     91:        jneq    2b
                     92:        
                     93: over:
                     94:        callf   $4,fnorm
                     95: sign:
                     96: 1:     bbc     $0,r3,done
                     97:        orl2    $SIGNBIT,r0
                     98: done:  ret
                     99: 
                    100: is_res1:
                    101:        bbc     $31,4(fp),retz
                    102:        callf   $4,fpresop
                    103:        ret
                    104: is_res2:
                    105:        bbc     $31,12(fp),z_div
                    106:        callf   $4,fpresop
                    107:        ret
                    108: retz:
                    109:          clrl  r0
                    110:          clrl  r1
                    111:          ret
                    112: underf:
                    113:        callf   $4,fpunder
                    114:        ret
                    115: z_div:
                    116:        callf   $4,fpzdiv
                    117:        ret

unix.superglobalmegacorp.com

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