plan 9 kernel history: overview | file list | diff list

1991/0702/pc/main.c (diff list | history)

1991/0629/sys/src/9/pc/main.c:1,561991/0702/sys/src/9/pc/main.c:1,39 (short | long | prev | next)
1991/0629    
#include <u.h> 
1991/0702    
#include	"u.h" 
#include	"lib.h" 
#include	"dat.h" 
#include	"fns.h" 
1991/0629    
 
#define	WIDTH	80 
#define	HEIGHT	22 
#define SCREEN	((char *)0xB8000) 
int pos; 
                 
void 
prchar(int x) 
1991/0702    
main(void) 
1991/0625    
{ 
1991/0629    
	if(x == '\n'){ 
		pos = pos/WIDTH; 
		pos = (pos+1)*WIDTH; 
	} else { 
		SCREEN[pos++] = x; 
		SCREEN[pos++] = 0x43; 
1991/0702    
	for(;;){ 
		print("%x ", kbdc()); 
1991/0629    
	} 
	if(pos >= WIDTH*HEIGHT) 
		pos = 0; 
1991/0625    
} 
 
1991/0629    
void 
prstr(char *s) 
1991/0702    
delay(int l) 
1991/0625    
{ 
1991/0629    
	while(*s) 
		prchar(*s++); 
1991/0625    
} 
1991/0702    
	int i; 
1991/0625    
 
1991/0629    
void 
prdig(ulong x) 
1991/0625    
{ 
1991/0629    
	if(x < 0xA) 
		prchar('0' + x); 
	else 
		prchar('A' + x); 
1991/0702    
	while(--l){ 
		for(i=0; i < 10000; i++) 
			; 
	} 
1991/0625    
} 
 
1991/0629    
void 
prhex(ulong x) 
1991/0702    
int 
sprint(char *s, char *fmt, ...) 
1991/0625    
{ 
1991/0629    
	ulong y; 
                 
	if(x <= 0xF){ 
		prdig(x); 
	} else { 
		y = x&0xF; 
		prhex(x>>4); 
		prdig(y); 
	} 
1991/0702    
	return doprint(s, s+PRINTSIZE, fmt, (&fmt+1)) - s; 
1991/0625    
} 
1991/0629    
 
main(void) 
1991/0702    
int 
print(char *fmt, ...) 
1991/0629    
{ 
	prstr("hello world\n"); 
} 
1991/0702    
	char buf[PRINTSIZE]; 
	int n; 
1991/0629    
 
1991/0702    
	n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf; 
	screenputs(buf, n); 
	return n; 
} 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)