-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.c
79 lines (68 loc) · 835 Bytes
/
lib.c
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
static int testvar = 0x689a;
void selftest()
{
int* t = &testvar;
if(*t != 0x689a) {
printcharadv('E', 0x4);
while(1);
} else {
(*t)++;
if(*t != 0x689b) {
printcharadv('E', 0x2);
while(1);
}
}
}
int min(x,y)
int x;
int y;
{
return (x<y)?x:y;
}
void printstr(str, cur, attr)
char * str;
int cur;
int attr;
{
setcur(cur);
while(*str)
{
printcharadv(*str,attr);
str++;
}
}
int max(x,y)
int x;
int y;
{
return (x>y)?x:y;
}
int myabs(x)
int x;
{
return (x>0)?x:(-x);
}
static long s = 34534;
int myrand()
{
s = s * 23523 + 12311;
return (s % 7919) & 0xff;
}
int printlong(n, attr, minlen)
unsigned long n;
char attr;
int minlen;
{
char st[140];
int i = 0;
do {
st[i] = n%10;
n = n/10;
i++;
} while (n != 0 || i<minlen);
i--;
while(i>=0) {
printcharadv(st[i]+'0', attr);
i--;
}
}