Annotation of researchv10no/cmd/adb/11v/mchio.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * read or print machine-dependent data structures
        !             3:  * this version for a vax running on a vax
        !             4:  */
        !             5: 
        !             6: #include "defs.h"
        !             7: 
        !             8: /*
        !             9:  * read an ASCII expression
        !            10:  */
        !            11: 
        !            12: char lastc;
        !            13: 
        !            14: WORD
        !            15: ascval()
        !            16: {
        !            17:        long l;
        !            18:        register char *p;
        !            19:        register int i;
        !            20: 
        !            21:        l = 0;
        !            22:        p = (char *)&l;
        !            23:        i = sizeof(l);
        !            24:        while (quotchar()) {
        !            25:                if (--i >= 0)
        !            26:                        *p++ = lastc;
        !            27:        }
        !            28:        return ((WORD)swal(l));
        !            29: }
        !            30: 
        !            31: /*
        !            32:  * read a floating point number in VAX format
        !            33:  * the result must fit in a WORD
        !            34:  */
        !            35: 
        !            36: WORD
        !            37: fpin(buf)
        !            38: char *buf;
        !            39: {
        !            40:        union {
        !            41:                WORD w;
        !            42:                float f;
        !            43:        } x;
        !            44:        double atof();
        !            45: 
        !            46:        x.f = atof(buf);
        !            47:        return (x.w);
        !            48: }
        !            49: 
        !            50: /*
        !            51:  * print a floating point number in VAX format
        !            52:  */
        !            53: 
        !            54: fpout(flag, va)
        !            55: char flag;
        !            56: char *va;
        !            57: {
        !            58:        double d;
        !            59:        char buf[20];
        !            60:        char *gcvt();
        !            61: 
        !            62:        if (*(int *)va == 0x00008000) {
        !            63:                prints("illegal float   ");
        !            64:                return;
        !            65:        }
        !            66:        if (flag == 'f')
        !            67:                d = *(float *)va;
        !            68:        else
        !            69:                d = *(double *)va;
        !            70:        prints(gcvt(d, 16, buf));
        !            71: }
        !            72: 
        !            73: /*
        !            74:  * print a date
        !            75:  */
        !            76: 
        !            77: printdate(tvec)
        !            78: WORD tvec;
        !            79: {
        !            80:        char *p;
        !            81:        char *ctime();
        !            82: 
        !            83:        p = ctime((long *)&tvec);
        !            84:        p[strlen(p)-1] = 0;             /* stomp on newline */
        !            85:        printf("%-25s", p);
        !            86: }
        !            87: 
        !            88: /*
        !            89:  * swap words in a longword
        !            90:  */
        !            91: 
        !            92: long
        !            93: swal(l)
        !            94: {
        !            95: 
        !            96:        return (((l >> 16) & 0xffff) | ((l & 0xffff) << 16));
        !            97: }

unix.superglobalmegacorp.com

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