Annotation of cci/d/io/Lib/bio.c, revision 1.1

1.1     ! root        1: 
        !             2: #define NULL   '\0'
        !             3: #define CR     '\n'
        !             4: 
        !             5: 
        !             6: /*     I/O ROUTINES TO CPU2 CONSOLE    */
        !             7: 
        !             8: writec(c)
        !             9: char c;
        !            10: {
        !            11:        putchar(c);
        !            12: }
        !            13: 
        !            14: writes(s)
        !            15: char *s;
        !            16: {
        !            17:        putstr(s);
        !            18: }
        !            19: 
        !            20: writeh(ix)     /* 32 bits HEX */
        !            21: long ix;
        !            22: {      register long count, mask, indx;
        !            23:        char c, str[9];
        !            24: 
        !            25:        if (ix==0) { writec('0'); return; }
        !            26:        indx = 0; count = 28;
        !            27:        mask = 0xf0000000;
        !            28:        str[8]='\0';
        !            29:        while (mask)  {
        !            30:                c = ( (ix&mask) >> count )&0xf;
        !            31:                count -= 4;
        !            32:                if (indx==0) mask = 0xf000000;
        !            33:                        else mask = mask >> 4;
        !            34:                if ((c>=0)&&(c<=9)) c=c+'0';
        !            35:                        else c=c+'7';
        !            36:                str[indx++] = c;
        !            37:                }
        !            38:        /* replace leading 0 with space */
        !            39:        for (indx=0; indx<8; indx++) {
        !            40:                if (str[indx]!='0') break;
        !            41:                        /* esle str[indx]=' '; */
        !            42:                }
        !            43:        writes(&str[indx]);
        !            44: }
        !            45: 
        !            46: /*     Function to write a 32_bit decimal to Console
        !            47: */
        !            48: writed(ix)
        !            49: long ix;
        !            50: {      char c;
        !            51:        register long div, lead0;
        !            52: 
        !            53:        if (ix==0) { writec('0'); return; }
        !            54:        if (ix<0) { writec('-'); ix = (~ix)+1; }
        !            55:        lead0 = 1;
        !            56:        div = 1000000000;
        !            57:        while (div) {
        !            58:                c = (ix/div)+'0';
        !            59:                ix = ix%div;            /* Mod */
        !            60:                div /= 10;
        !            61:                if ((c=='0')&&(lead0)) c=' ';
        !            62:                        else lead0 = 0;
        !            63:                if (c != ' ') writec(c);
        !            64:                }
        !            65: }
        !            66: 
        !            67: /*     Function read 1 char from Console
        !            68: */
        !            69: char readc()
        !            70: {
        !            71:        return(rdchar());
        !            72: }
        !            73: 
        !            74: /*     This function read a string of characters.
        !            75:        calling sequence : nochar = reads(s);
        !            76:        input argument   : char *s;
        !            77:        return value     : no. of char read; excluding NULL or CR.
        !            78: */
        !            79: reads(s)
        !            80: char *s;
        !            81: {      register long ix;
        !            82: 
        !            83:        for(ix=0;;ix++) {
        !            84:                *s = readc();
        !            85:                if ((*s==NULL)||(*s==CR)) 
        !            86:                        { *s = NULL; break; }
        !            87:                     else s++;
        !            88:                }
        !            89:        return(ix);
        !            90: }
        !            91: 

unix.superglobalmegacorp.com

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