Annotation of cci/d/dmp4/bio.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

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