1
0
mirror of https://github.com/DoctorWkt/pdp7-unix.git synced 2026-04-16 00:30:39 +00:00

Cleaned up B run-time

Pared down the B run-time to a minimal functionality.  This is based on
research decompiling the pdp-11 libb.a run-time.
This commit is contained in:
rswier
2016-04-13 05:09:24 -04:00
parent 22f0d2e99a
commit ce6b5c4887
2 changed files with 34 additions and 54 deletions

View File

@@ -112,7 +112,7 @@ jmp start
isz sp
jmp fetch
.getchr: .+1
.getchar: .+1
s 2
n 8
n 7
@@ -125,7 +125,7 @@ jmp start
isz sp
jmp fetch
.putchr: .+1
.putchar: .+1
s 2
n 8
n 7

View File

@@ -11,72 +11,52 @@ lchar(s, n, c) {
return(c);
}
getstr(s) {
auto c, i;
putnum(n, b) {
auto a, d;
i = 0;
while ((c = getchr()) != '*n') {
lchar(s,i,c);
i = i+1;
d = 0;
if (n < 0) {
n = -n;
if (n < 0) {
n = n-1;
d = 1;
} else
putchar('-');
}
lchar(s,i,'*e');
return(s);
}
putstr(s) {
auto c, i;
i = 0;
while ((c = char(s,i)) != '*e') {
putchr(c);
i = i+1;
}
}
putnum(n) {
if (n > 9) {
putnum(n / 10);
n = n % 10;
}
putchr(n + '0');
}
octal(n) {
if (n > 7) {
octal(n / 8);
n = n & 7;
}
putchr(n + '0');
if (a = n/b)
putnum(a, b);
putchar(n%b + '0' + d);
}
printf(fmt,x1,x2,x3,x4,x5,x6,x7,x8,x9) {
auto adx, c, i;
auto adx, a, c, i, n;
i = 0;
adx = &x1;
loop:
while ((c = char(fmt,i)) != '%') {
if (c=='*e')
while ((c = char(fmt, i)) != '%') {
if (c == '*e')
return;
putchr(c);
putchar(c);
i = i+1;
}
i = i+1;
c = char(fmt,i);
if (c=='d') {
if (*adx < 0) {
putchr('-');
*adx = -*adx;
}
putnum(*adx);
} else if (c=='o')
octal(*adx);
a = *adx;
c = char(fmt, i);
if (c=='d')
putnum(a, 10);
else if (c=='o')
putnum(a, 8);
else if (c=='c')
putchr(*adx);
else if (c=='s')
putstr(*adx);
else {
putchr('%');
putchar(a);
else if (c=='s') {
n = 0;
while ((c = char(a, n)) != '*e') {
putchar(c);
n = n+1;
}
} else {
putchar('%');
goto loop;
}
i = i+1;