Annotation of cci/d/ether/bio.c, revision 1.1

1.1     ! root        1: 
        !             2: #include "definitions"
        !             3: 
        !             4: /*     I/O ROUTINES TO CPU2 CONSOLE    */
        !             5: 
        !             6: writec(c)
        !             7: char c;
        !             8: {
        !             9:        putchar(c);
        !            10: }
        !            11: 
        !            12: writes(s)
        !            13: char *s;
        !            14: {
        !            15:        putstr(s);
        !            16: }
        !            17: 
        !            18: writeh(ix)     /* 32 bits HEX */
        !            19: long ix;
        !            20: {      register long count, mask, indx;
        !            21:        char c, str[9];
        !            22: 
        !            23:        if (ix==0) { writes("0"); return; }
        !            24:        indx = 0; count = 28;
        !            25:        mask = 0xf0000000;
        !            26:        str[8]='\0';
        !            27:        while (mask)  {
        !            28:                c = ( (ix&mask) >> count )&0xf;
        !            29:                count -= 4;
        !            30:                if (indx==0) mask = 0xf000000;
        !            31:                        else mask = mask >> 4;
        !            32:                if ((c>=0)&&(c<=9)) c=c+'0';
        !            33:                        else c=c+'7';
        !            34:                str[indx++] = c;
        !            35:                }
        !            36:        /* replace leading 0 with space */
        !            37:        for (indx=0; indx<8; indx++) {
        !            38:                if (str[indx]!='0') break;
        !            39:                        /* esle str[indx]=' '; */
        !            40:                }
        !            41:        writes(&str[indx]);
        !            42: }
        !            43: 
        !            44: /*     Function to write a 32_bit decimal to Console
        !            45: */
        !            46: writed(ix)
        !            47: long ix;
        !            48: {      char c;
        !            49:        register long div, lead0;
        !            50: 
        !            51:        if (ix==0) { writec('0'); return; }
        !            52:        if (ix<0) { writec('-'); ix = (~ix)+1; }
        !            53:        lead0 = 1;
        !            54:        div = 1000000000;
        !            55:        while (div) {
        !            56:                c = (ix/div)+'0';
        !            57:                ix = ix%div;            /* Mod */
        !            58:                div /= 10;
        !            59:                if ((c=='0')&&(lead0)) c=' ';
        !            60:                        else lead0 = 0;
        !            61:                if (c != ' ') writec(c);
        !            62:                }
        !            63: }
        !            64: 
        !            65: /*     Function read 1 char from Console
        !            66: */
        !            67: char readc()
        !            68: {
        !            69:        return(rdchar());
        !            70: }
        !            71: 
        !            72: /*     This function read a string of characters.
        !            73:        calling sequence : nochar = reads(s);
        !            74:        input argument   : char *s;
        !            75:        return value     : no. of char read; excluding NULL or CR.
        !            76: */
        !            77: reads(s)
        !            78: char *s;
        !            79: {      register long ix;
        !            80: 
        !            81:        for(ix=0;;ix++) {
        !            82:                *s = readc();
        !            83:                if ((*s==NULL)||(*s==CR)) 
        !            84:                        { *s = NULL; break; }
        !            85:                     else s++;
        !            86:                }
        !            87:        return(ix);
        !            88: }
        !            89: 
        !            90: 
        !            91: /*     This function read a string of HEX digit and
        !            92:        convert it to integer value.
        !            93:        calling sequence : stat = readh(ix);
        !            94:        input parameter  : long *ix;
        !            95:        return value     : (stat < 0) if error else (stat = 0);
        !            96: */
        !            97: 
        !            98: /*
        !            99: readh(ix)      
        !           100: long *ix;
        !           101: {      char line[ALINE], *getnum(), *del;
        !           102:        int nochar;
        !           103: 
        !           104:        if ( (nochar = reads(line)) > 8 ) return(-1);
        !           105:        if ( (del = getnum(line,ix,del,HEX)) < 0 ) return(-1);
        !           106:                else return(0);
        !           107: }
        !           108: 
        !           109: */
        !           110: 
        !           111: 
        !           112: 
        !           113: 
        !           114: /*     This function read a string of DEC digit and
        !           115:        convert it to integer value.
        !           116:        calling sequence : stat = readd(ix);
        !           117:        input parameter  : long *ix;
        !           118:        return value     : (stat < 0) if error else (stat = 0);
        !           119: */
        !           120: 
        !           121: /*
        !           122: readd(ix)      
        !           123: long *ix;
        !           124: {      char line[ALINE], *getnum(), *del;
        !           125:        int nochar;
        !           126: 
        !           127:        if ( (nochar = reads(line)) > 11 ) return(-1);
        !           128:        if ( (del = getnum(line,ix,del,DEC)) < 0 ) return(-1);
        !           129:                else return(0);
        !           130: }
        !           131: */
        !           132: 

unix.superglobalmegacorp.com

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