Annotation of 43BSDReno/lib/libc/tahoe/fpe/mulf.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 "@(#)mulf.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(mulf, 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) */
        !            61:        andl3   $(0!(EXPMASK | SIGNBIT)),4(fp),r0
        !            62:        orl2    $(0!CLEARHID),r0
        !            63:        shll    $7,r0,r0        /* leave the sign bit cleared. */
        !            64:  
        !            65:        /* fetch seconed fraction: (r4) */
        !            66:        andl3   $(0!(EXPMASK | SIGNBIT)),12(fp),r4
        !            67:        orl2    $(0!CLEARHID),r4
        !            68:        shll    $7,r4,r4        /* leave the sign bit cleared. */
        !            69: 
        !            70:  
        !            71:        emul    r4,r0,$0,r0
        !            72:        movl    r0,r4           /* to see how much we realy need to shift. */
        !            73:        movl    $6,r5           /* r5 - shift counter. */
        !            74:        shrl    $7,r4,r4        /* dummy shift. */
        !            75: 1:     bbs     $HIDDEN,r4,realshift
        !            76:        shll    $1,r4,r4
        !            77:        decl    r2              /* update exponent. */
        !            78:        jeql    underflow
        !            79:        decl    r5              /* update shift counter. */
        !            80:        jmp     1b
        !            81: realshift:
        !            82:        shrl    r5,r0,r0
        !            83:        bbc     $0,r1,shiftmore
        !            84:        incl    r1              /* rounding. */
        !            85: shiftmore:
        !            86:        shrl    $1,r0,r0
        !            87: comb:
        !            88:        andl2   $CLEARHID,r0
        !            89:        shll    $EXPSHIFT,r2,r4
        !            90:        orl2    r4,r0
        !            91:        cmpl    r2,$256
        !            92:        jlss    1f
        !            93:        callf   $4,sfpover
        !            94: sign:
        !            95: 1:     bbc     $0,r3,done
        !            96:        orl2    $SIGNBIT,r0
        !            97: done:  ret
        !            98: 
        !            99: 
        !           100: 
        !           101: is_res1:
        !           102:        bbc     $31,4(fp),retzero
        !           103:        callf   $4,sfpresop
        !           104:        ret
        !           105: is_res2:
        !           106:        bbc     $31,12(fp),retzero
        !           107:        callf   $4,sfpresop
        !           108:        ret
        !           109:   retzero:
        !           110:          clrl  r0
        !           111:          ret
        !           112:   overflow:
        !           113:        callf   $4,sfpover
        !           114:        jmp     sign
        !           115:   underflow:
        !           116:        callf   $4,sfpunder
        !           117:        ret
        !           118: 
        !           119: 
        !           120:        

unix.superglobalmegacorp.com

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