Annotation of researchv9/libc/sun/Faints.s, revision 1.1.1.1

1.1       root        1:         .data
                      2:         .asciz  "@(#)Faints.s 1.1 86/02/03 Copyr 1985 Sun Micro"
                      3:         .even
                      4:         .text
                      5: 
                      6: |       Copyright (c) 1985 by Sun Microsystems, Inc.
                      7: 
                      8: #include "fpcrtdefs.h"
                      9: 
                     10: /*
                     11:        Faints: single precision round integral toward zero.
                     12: 
                     13: */
                     14: 
                     15: RTENTRY(Farints)
                     16:        movel   d0,d1           | d1 gets (x).
                     17:        bclr    #31,d1          | d1 gets (abs(x)).
                     18:        cmpl    #0x3f800000,d1
                     19:        bges    2f              | Branch if abs(x) >= 1.0.
                     20:        andl    #0x80000000,d0  | Isolate sign of x.
                     21:        cmpl    #0x3f000000,d1
                     22:        bles    6f              | Branch if abs(x) =< 0.5.
                     23:        orl     #0x3f800000,d0  | Make signed 1.0.
                     24: 6:
                     25:        jra     Farintsdone
                     26: 2:
                     27:        cmpl    #0x4b000000,d1
                     28:        blts    3f              | Branch if 1 <= |x| < 2**23.
                     29: Farintsbig:
                     30:        cmpl    #0x7f800000,d1
                     31:        bles    Farintsdone     | Branch if x is finite or infinity.
                     32:        bset    #22,d0          | Convert quiet to signalling.
                     33:        bras    Farintsdone
                     34: 3:
                     35:        roll    #8,d1
                     36:        roll    #1,d1
                     37:        andw    #0xff,d1        | d1 gets biased exponent.
                     38:        subw    #0x7f+22,d1     | d1 gets unbiased exponent - 22.
                     39:        negw    d1              | d1 gets 22-exp = bit number.
                     40:        movel   d2,a0
                     41:        clrl    d2
                     42:        bset    d1,d2           | Set round bit.
                     43:        addl    d2,d0           | Add round bit.
                     44:        lsll    #1,d2           | Make 2**0 bit.
                     45:        subql   #1,d2           | Fraction bit mask.
                     46:        andl    d0,d2           | d1 gets rounded fraction field.
                     47:        bnes    2f              | Branch if not ambiguous case.
                     48:        addqw   #1,d1           | Make bit number for 2**0.
                     49:        bclr    d1,d0           | Force round to even.
                     50: 2:
                     51:        eorl    d2,d0           | Clear fraction field.
                     52: Farintsrestored2:
                     53:        movel   a0,d2
                     54: Farintsdone:
                     55:        RET
                     56: 
                     57: RTENTRY(Fanints)
                     58:        movel   d0,d1           | d1 gets (x).
                     59:        bclr    #31,d1          | d1 gets (abs(x)).
                     60:        cmpl    #0x3f800000,d1
                     61:        bges    2f              | Branch if abs(x) >= 1.0.
                     62:        andl    #0x80000000,d0  | Isolate sign of x.
                     63:        cmpl    #0x3f000000,d1
                     64:        blts    6f              | Branch if abs(x) < 0.5.
                     65:        orl     #0x3f800000,d0  | Make signed 1.0.
                     66: 6:
                     67:        jra     Farintsdone
                     68: 2:
                     69:        cmpl    #0x4b000000,d1
                     70:        bges    Farintsbig      | Branch if 1 <= |x| < 2**23.
                     71:        roll    #8,d1
                     72:        roll    #1,d1
                     73:        andw    #0xff,d1        | d1 gets biased exponent.
                     74:        subw    #0x7f+22,d1     | d1 gets unbiased exponent - 22.
                     75:        negw    d1              | d1 gets 22-exp = bit number.
                     76:        movel   d2,a0
                     77:        clrl    d2
                     78:        bset    d1,d2           | Set round bit.
                     79:        addl    d2,d0           | Add round bit.
                     80:        lsll    #1,d2           | Make 2**0 bit.
                     81:        subql   #1,d2           | Fraction bit mask.
                     82:        notl    d2
                     83:        andl    d2,d0
                     84:        bras    Farintsrestored2
                     85: 
                     86: RTENTRY(Faints)
                     87:        movel   d0,d1           | d1 gets (x).
                     88:        bclr    #31,d1          | d1 gets (abs(x)).
                     89:        cmpl    #0x3f800000,d1
                     90:        bges    2f              | Branch if abs(x) >= 1.0.
                     91:        andl    #0x80000000,d0  | Isolate sign of x.
                     92:        jra     Farintsdone
                     93: 2:
                     94:        cmpl    #0x4b000000,d1
                     95:        jge     Farintsbig      | Branch if 1 <= |x| < 2**23.
                     96:        roll    #8,d1
                     97:        roll    #1,d1
                     98:        andw    #0xff,d1        | d1 gets biased exponent.
                     99:        subw    #0x7f+23,d1     | d1 gets unbiased exponent - 23.
                    100:        negw    d1              | d1 gets 23-exp = bit number.
                    101:        movel   d2,a0
                    102:        clrl    d2
                    103:        bset    d1,d2           | Set 2**0 bit.
                    104:        subql   #1,d2           | Fraction bit mask.
                    105:        notl    d2
                    106:        andl    d2,d0
                    107:        jra     Farintsrestored2
                    108: 
                    109: RTENTRY(Ffloors)
                    110:        movel   d0,sp@-         | Save x.
                    111:        jbsr    Faints          | d0 gets aint(x).
                    112:        movel   sp@+,d1         | d1 gets x.
                    113:        bpls    Ffloorsdone     | Branch if x is positive.
                    114:        cmpl    d0,d1
                    115:        beqs    Ffloorsdone     | Return x if x = aint(x).
                    116:        movel   #0xbf800000,d1  | d1 gets -1.
                    117:        jbsr    Fadds           | d0 gets aint(x)-1.
                    118: Ffloorsdone:
                    119:        RET
                    120: 
                    121: RTENTRY(Fceils)
                    122:        movel   d0,sp@-         | Save x.
                    123:        jbsr    Faints          | d0 gets aint(x).
                    124:        movel   sp@+,d1         | d1 gets x.
                    125:        bmis    Fceilsdone      | Branch if x is negative.
                    126:        cmpl    d0,d1
                    127:        beqs    Fceilsdone      | Return x if x = aint(x).
                    128:        movel   #0x3f800000,d1  | d1 gets +1.
                    129:        jbsr    Fadds           | d0 gets aint(x)+1.
                    130: Fceilsdone:
                    131:        RET

unix.superglobalmegacorp.com

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