Annotation of cci/sys/tahoe/Kldexpf.x, revision 1.1.1.1

1.1       root        1: 
                      2: /* @(*)Kldexpf.s       4.2 (Berkeley) 12/21/80
                      3: *      Tahoe           2/2/83
                      4: *
                      5: *      float Kldexpf (op_most, op_least, exp, hfs)
                      6: *
                      7: *      Ldexp returns value*2**exp, if that result is in range.
                      8: *      If underflow occurs, it returns zero.  If overflow occurs,
                      9: *      it returns a value of appropriate sign and largest
                     10: *      possible magnitude.  In case of either overflow or underflow,
                     11: *      the external int "errno" is set to ERANGE.  Note that errno is
                     12: *      not modified if no error occurs, so if you intend to test it
                     13: *      after you use Kldexpf, you had better set it to something
                     14: *      other than ERANGE first (zero is a reasonable value to use).
                     15: *
                     16: *      Constants
                     17: */
                     18: 
                     19: #include "../machine/fp_in_krnl.h"
                     20: 
                     21: /*     Constants to be in a flt.h file . (?) */
                     22: 
                     23:        .set            EXPMASK,        0x7f800000
                     24:        .set            SIGNBIT,        0x80000000
                     25:        .set            EXPSHIFT,       23
                     26:        .data
                     27: 
                     28: huge0: .word   0x7fff          /* The largest number that can */
                     29:        .word   0xffff          /*   be represented in a long floating */
                     30: huge1: .word   0xffff          /* The largest number that can */
                     31:        .word   0xffff          /*   be represented in a long floating */
                     32: /*
                     33: *      Entry point
                     34: */
                     35:        .text
                     36:        .globl  _Kldexpf
                     37: _Kldexpf:      .word   0x0004          /* We use r2  */
                     38: 
                     39:        movl    4(fp),r0        /* Fetch "value" */
                     40:        movl    8(fp),r1
                     41: 
                     42:        andl3   $EXPMASK,r0,r2  /* r2 := shifted biased exponent */
                     43:        jeql    ld1             /* If it's zero, we're done */
                     44:        shar    $EXPSHIFT,r2,r2 /* shift to get value of exponent  */
                     45: 
                     46:        addl2   12(fp),r2       /* r2 := new biased exponent */
                     47:        jleq    under           /* if it's <= 0, we have an underflow */
                     48:        cmpl    r2,$256         /* Otherwise check if it's too big */
                     49:        jgeq    over            /* jump if overflow */
                     50: /*
                     51: *      Construct the result and return
                     52: */
                     53:        andl2   $0!EXPMASK,r0   /* clear old exponent */
                     54:        shal    $EXPSHIFT,r2,r2 /* Put the exponent back in the result */
                     55:        orl2    r2,r0
                     56: ld1:   ret
                     57: /*
                     58: *      Underflow
                     59: */
                     60: under: clrl    r0              /* Result is zero */
                     61:        clrl    r1
                     62:        orl2    $HFS_UNDF,*16(fp)
                     63:        jmp     err             /* Join general error code */
                     64: /*
                     65: *      Overflow
                     66: */
                     67: over:  movl    huge0,r0        /* Largest possible floating magnitude */
                     68:        movl    huge1,r1
                     69:        orl2    $HFS_OVF,*16(fp)
                     70:        orl2    $SIGNBIT,r0     /* If arg < 0, make result negative */
                     71: 
                     72: err:   orl2    $HFS_RANGE,*16(fp)      /* Indicate range error */
                     73:        ret

unix.superglobalmegacorp.com

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