Annotation of researchv10no/cmd/lcc/gen2/mips/decode.c, revision 1.1

1.1     ! root        1: /* C compiler: MIPS float/double decoding */
        !             2: 
        !             3: #include "c.h"
        !             4: 
        !             5: struct real decode(ty, x) double x; {
        !             6:        struct real r;
        !             7: 
        !             8:        if (ty == D) {
        !             9: #ifdef MIPSEL
        !            10:                struct d { unsigned fract2, fract1:20, exp:11, sign:1;  }
        !            11: #else
        !            12:                struct d { unsigned sign:1, exp:11, fract1:20, fract2; }
        !            13: #endif
        !            14:                        *p = (struct d *) &x;
        !            15:                r.sign = p->sign;
        !            16:                r.exp = x ? p->exp - 1023 : 0;
        !            17:                r.msb = (p->fract1<<12) | (p->fract2>>20);
        !            18:                r.lsb = p->fract2<<12;
        !            19:        } else {
        !            20:                float f = x;
        !            21: #ifdef MIPSEL
        !            22:                struct f { unsigned fract:23, exp:8, sign:1; }
        !            23: #else
        !            24:                struct f { unsigned sign:1, exp:8, fract:23; }
        !            25: #endif
        !            26:                        *p = (struct f *) &f;
        !            27:                r.sign = p->sign;
        !            28:                r.exp = f ? p->exp - 127 : 0;
        !            29:                r.msb = p->fract<<9;
        !            30:                r.lsb = 0;
        !            31:        }
        !            32:        return r;
        !            33: }

unix.superglobalmegacorp.com

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