~kris/9p

9hist

ref: 42b826e665601dd85f86d39b03aef8ae5ecec299 9hist/pc/main.c -rw-r--r-- 561 bytes
42b826e6 — David du Colombier Plan 9 from Bell Labs 1991-06-29 35 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <u.h>

#define	WIDTH	80
#define	HEIGHT	22
#define SCREEN	((char *)0xB8000)
int pos;

void
prchar(int x)
{
	if(x == '\n'){
		pos = pos/WIDTH;
		pos = (pos+1)*WIDTH;
	} else {
		SCREEN[pos++] = x;
		SCREEN[pos++] = 0x43;
	}
	if(pos >= WIDTH*HEIGHT)
		pos = 0;
}

void
prstr(char *s)
{
	while(*s)
		prchar(*s++);
}

void
prdig(ulong x)
{
	if(x < 0xA)
		prchar('0' + x);
	else
		prchar('A' + x);
}

void
prhex(ulong x)
{
	ulong y;

	if(x <= 0xF){
		prdig(x);
	} else {
		y = x&0xF;
		prhex(x>>4);
		prdig(y);
	}
}

main(void)
{
	prstr("hello world\n");
}