mirror of
https://github.com/DoctorWkt/pdp7-unix.git
synced 2026-05-01 22:15:59 +00:00
Progress on B stuff
Setup argv array based on Phil Budne's assembly. Added string and ctype libraries (untested).
This commit is contained in:
@@ -230,29 +230,23 @@ flush: 0
|
|||||||
jmp flush i
|
jmp flush i
|
||||||
|
|
||||||
initio: 0
|
initio: 0
|
||||||
|
law .argv " build argument list
|
||||||
|
dac 8 " auto-inc pointer argvp = &argv[-1]
|
||||||
lac 017777 i
|
lac 017777 i
|
||||||
" sad d4
|
cll rtr
|
||||||
jmp 2f
|
dac 8 i " *++argvp = arg count
|
||||||
sad d8
|
cma
|
||||||
jmp 1f
|
tad d1
|
||||||
|
dac t1 " count = -argv[0]
|
||||||
|
lac 017777
|
||||||
|
dac lastv " set top of heap
|
||||||
|
tad d1 " ac = addr of arg0
|
||||||
|
1:
|
||||||
|
dac 8 i " *++argvp = ac
|
||||||
|
tad d4 " ac += 4
|
||||||
|
isz t1 " while ++count != 0
|
||||||
|
jmp 1b
|
||||||
|
|
||||||
law 9
|
|
||||||
tad 017777
|
|
||||||
dac .+3
|
|
||||||
law 017
|
|
||||||
sys creat; ..
|
|
||||||
spa
|
|
||||||
jmp stop
|
|
||||||
dac .fout
|
|
||||||
1:
|
|
||||||
law 5
|
|
||||||
tad 017777
|
|
||||||
dac .+2
|
|
||||||
sys open; ..; 0
|
|
||||||
spa
|
|
||||||
jmp stop
|
|
||||||
dac .fin
|
|
||||||
2:
|
|
||||||
lac lastv
|
lac lastv
|
||||||
dac eibufp
|
dac eibufp
|
||||||
dac cibufp
|
dac cibufp
|
||||||
@@ -280,7 +274,7 @@ iflg: 0
|
|||||||
eobufp: 0
|
eobufp: 0
|
||||||
cobufp: 0
|
cobufp: 0
|
||||||
oflg: 0
|
oflg: 0
|
||||||
lastv: 017770
|
lastv: 0
|
||||||
|
|
||||||
o777: 0777
|
o777: 0777
|
||||||
d4:o4: 4
|
d4:o4: 4
|
||||||
|
|||||||
@@ -2,12 +2,25 @@
|
|||||||
|
|
||||||
char(s, n) {
|
char(s, n) {
|
||||||
if (n & 1) return(s[n/2] & 0777);
|
if (n & 1) return(s[n/2] & 0777);
|
||||||
return ((s[n/2]/512) & 0777);
|
return((s[n/2]/512) & 0777);
|
||||||
}
|
}
|
||||||
|
|
||||||
lchar(s, n, c) {
|
lchar(s, n, c) {
|
||||||
if (n & 1) s[n/2] = (s[n/2] & 0777000) | c;
|
if (n & 1) s[n/2] = (s[n/2] & 0777000) | c;
|
||||||
else s[n/2] = (s[n/2] & 0777) | (c*512);
|
else s[n/2] = (s[n/2] & 0777) | (c*512);
|
||||||
|
return(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
getstr(s) {
|
||||||
|
auto c, i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while ((c = getchr()) != '*n') {
|
||||||
|
lchar(s,i,c);
|
||||||
|
i = i+1;
|
||||||
|
}
|
||||||
|
lchar(s,i,'*e');
|
||||||
|
return(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
putstr(s) {
|
putstr(s) {
|
||||||
|
|||||||
9
src/other/ctype.b
Normal file
9
src/other/ctype.b
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
/* ctype.b - character types */
|
||||||
|
|
||||||
|
isalpha(c) {
|
||||||
|
return((c >= 'a' & c <= 'z') | (c >= 'A' & c <= 'Z'));
|
||||||
|
}
|
||||||
|
|
||||||
|
isdigit(c) {
|
||||||
|
return(c >= '0' & c <= '9');
|
||||||
|
}
|
||||||
58
src/other/string.b
Normal file
58
src/other/string.b
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/* string.b - B string library
|
||||||
|
|
||||||
|
mostly from: https://www.bell-labs.com/usr/dmr/www/btut.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
strcopy(sl, s2) {
|
||||||
|
auto i;
|
||||||
|
i = 0;
|
||||||
|
while (lchar(sl,i,char(s2,i)) != '*e')
|
||||||
|
i = i+1;
|
||||||
|
return(s1);
|
||||||
|
}
|
||||||
|
|
||||||
|
strcat(s1, s2) {
|
||||||
|
auto i,j;
|
||||||
|
i = j = 0;
|
||||||
|
while (char(s1,i) != '*e')
|
||||||
|
i = i+1;
|
||||||
|
while(lchar(s1,i,char(s2,j)) != '*e') {
|
||||||
|
i = i+1;
|
||||||
|
j = j+1;
|
||||||
|
}
|
||||||
|
return(s1);
|
||||||
|
}
|
||||||
|
|
||||||
|
strlen(s) {
|
||||||
|
auto i;
|
||||||
|
i = 0;
|
||||||
|
while (char(s,i) != '*e')
|
||||||
|
i = i+1;
|
||||||
|
return(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
strcmp(s1, s2) {
|
||||||
|
auto c,i;
|
||||||
|
i = 0;
|
||||||
|
while ((c=char(s1,i)) == char(s2,i)) {
|
||||||
|
if (c == '*e')
|
||||||
|
return(0);
|
||||||
|
i = i+1;
|
||||||
|
}
|
||||||
|
return(c - char(s2,i));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* convert command line argument into a string */
|
||||||
|
strarg(s, a) {
|
||||||
|
auto i, c;
|
||||||
|
i = 0;
|
||||||
|
while (i < 8) {
|
||||||
|
if ((c = char(a,i)) == ' ')
|
||||||
|
goto done;
|
||||||
|
lchar(s,i,c);
|
||||||
|
i = i+1;
|
||||||
|
}
|
||||||
|
done:
|
||||||
|
lchar(s,i,'*e');
|
||||||
|
return(s);
|
||||||
|
}
|
||||||
@@ -7,14 +7,41 @@
|
|||||||
perl a7out test.out
|
perl a7out test.out
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* convert command line argument into a string */
|
||||||
|
strarg(s, a) {
|
||||||
|
auto i, c;
|
||||||
|
i = 0;
|
||||||
|
while (i < 8) {
|
||||||
|
if ((c = char(a,i)) == ' ')
|
||||||
|
goto done;
|
||||||
|
lchar(s,i,c);
|
||||||
|
i = i+1;
|
||||||
|
}
|
||||||
|
done:
|
||||||
|
lchar(s,i,'*e');
|
||||||
|
return(s);
|
||||||
|
}
|
||||||
|
|
||||||
main {
|
main {
|
||||||
extrn fname, fin;
|
extrn fname, fin, fout, argv;
|
||||||
auto ch,p;
|
auto ch,p,n,str 5;
|
||||||
|
|
||||||
p = 017777;
|
p = 017777;
|
||||||
printf("mem[0%o] = 0%o*n",p,*p);
|
printf("mem[0%o] = 0%o*n",p,*p);
|
||||||
printf("mem[0%o] = %d*n",*p,**p);
|
printf("mem[0%o] = %d*n",*p,**p);
|
||||||
|
|
||||||
|
printf("argv = %d*n",argv);
|
||||||
|
printf("**argv = %d*n",*argv);
|
||||||
|
printf("argv[0] = %d*n",argv[0]);
|
||||||
|
n = 0;
|
||||||
|
while (n < argv[0]) {
|
||||||
|
n = n+1;
|
||||||
|
printf("argv[%d] = 0%o *"%s*"*n",n,argv[n],strarg(str,argv[n]));
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("array(0) = 0%o*n",array(0));
|
||||||
|
printf("array(64) = 0%o*n",array(64));
|
||||||
|
printf("array(0) = 0%o*n",array(0));
|
||||||
|
|
||||||
/* fin = open(fname, 0); */
|
/* fin = open(fname, 0); */
|
||||||
fin = open("abc ", 0);
|
fin = open("abc ", 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user