|
|
Power 6/32 Unix version 1.2b
#include "definitions"
/* I/O ROUTINES TO CPU2 CONSOLE */
writec(c)
char c;
{
putchar(c);
}
writes(s)
char *s;
{
putstr(s);
}
writeh(ix) /* 32 bits HEX */
long ix;
{ register long count, mask, indx;
char c, str[9];
if (ix==0) { writes("0"); return; }
indx = 0; count = 28;
mask = 0xf0000000;
str[8]='\0';
while (mask) {
c = ( (ix&mask) >> count )&0xf;
count -= 4;
if (indx==0) mask = 0xf000000;
else mask = mask >> 4;
if ((c>=0)&&(c<=9)) c=c+'0';
else c=c+'7';
str[indx++] = c;
}
/* replace leading 0 with space */
for (indx=0; indx<8; indx++) {
if (str[indx]!='0') break;
/* esle str[indx]=' '; */
}
writes(&str[indx]);
}
/* Function to write a 32_bit decimal to Console
*/
writed(ix)
long ix;
{ char c;
register long div, lead0;
if (ix==0) { writec('0'); return; }
if (ix<0) { writec('-'); ix = (~ix)+1; }
lead0 = 1;
div = 1000000000;
while (div) {
c = (ix/div)+'0';
ix = ix%div; /* Mod */
div /= 10;
if ((c=='0')&&(lead0)) c=' ';
else lead0 = 0;
if (c != ' ') writec(c);
}
}
/* Function read 1 char from Console
*/
char readc()
{
return(rdchar());
}
/* This function read a string of characters.
calling sequence : nochar = reads(s);
input argument : char *s;
return value : no. of char read; excluding NULL or CR.
*/
reads(s)
char *s;
{ register long ix;
for(ix=0;;ix++) {
*s = readc();
if ((*s==NULL)||(*s==CR))
{ *s = NULL; break; }
else s++;
}
return(ix);
}
/* This function read a string of HEX digit and
convert it to integer value.
calling sequence : stat = readh(ix);
input parameter : long *ix;
return value : (stat < 0) if error else (stat = 0);
*/
/*
readh(ix)
long *ix;
{ char line[ALINE], *getnum(), *del;
int nochar;
if ( (nochar = reads(line)) > 8 ) return(-1);
if ( (del = getnum(line,ix,del,HEX)) < 0 ) return(-1);
else return(0);
}
*/
/* This function read a string of DEC digit and
convert it to integer value.
calling sequence : stat = readd(ix);
input parameter : long *ix;
return value : (stat < 0) if error else (stat = 0);
*/
/*
readd(ix)
long *ix;
{ char line[ALINE], *getnum(), *del;
int nochar;
if ( (nochar = reads(line)) > 11 ) return(-1);
if ( (del = getnum(line,ix,del,DEC)) < 0 ) return(-1);
else return(0);
}
*/
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.