mirror of
https://github.com/DoctorWkt/pdp7-unix.git
synced 2026-01-28 12:59:50 +00:00
Begin working on alternate B run-time library
This commit is contained in:
286
src/other/brt.s
Normal file
286
src/other/brt.s
Normal file
@@ -0,0 +1,286 @@
|
||||
" brt
|
||||
|
||||
jmp start
|
||||
|
||||
" syscalls:
|
||||
|
||||
" .save: .+1
|
||||
" .getuid: .+1
|
||||
|
||||
.open: .+1
|
||||
s 2
|
||||
n 8
|
||||
n 7
|
||||
lac sp i
|
||||
dac 1f
|
||||
isz sp
|
||||
lac sp i
|
||||
dac 2f
|
||||
lac sp
|
||||
tad d1
|
||||
dac sp i
|
||||
isz sp
|
||||
sys open; 1:0; 2:0
|
||||
dac sp i
|
||||
isz sp
|
||||
jmp fetch
|
||||
|
||||
.read: .+1
|
||||
s 2
|
||||
n 8
|
||||
n 7
|
||||
lac sp i
|
||||
dac t1
|
||||
isz sp
|
||||
lac sp i
|
||||
dac 1f
|
||||
isz sp
|
||||
lac sp i
|
||||
dac 2f
|
||||
lac sp
|
||||
tad d1
|
||||
dac sp i
|
||||
isz sp
|
||||
lac t1
|
||||
sys read; 1:0; 2:0
|
||||
dac sp i
|
||||
isz sp
|
||||
jmp fetch
|
||||
|
||||
.write: .+1
|
||||
s 2
|
||||
n 8
|
||||
n 7
|
||||
lac sp i
|
||||
dac t1
|
||||
isz sp
|
||||
lac sp i
|
||||
dac 1f
|
||||
isz sp
|
||||
lac sp i
|
||||
dac 2f
|
||||
lac sp
|
||||
tad d1
|
||||
dac sp i
|
||||
isz sp
|
||||
lac t1
|
||||
sys write; 1:0; 2:0
|
||||
dac sp i
|
||||
isz sp
|
||||
jmp fetch
|
||||
|
||||
" .creat: .+1
|
||||
" .seek: .+1
|
||||
" .tell: .+1
|
||||
" .close: .+1
|
||||
" .link: .+1
|
||||
" .unlink: .+1
|
||||
" .setuid: .+1
|
||||
" .rename: .+1
|
||||
" .exit: .+1
|
||||
" .time: .+1
|
||||
" .intrp: .+1
|
||||
" .chdir: .+1
|
||||
" .chmod: .+1
|
||||
" .chown: .+1
|
||||
" .sysloc: .+1
|
||||
" .capt: .+1
|
||||
" .rele: .+1
|
||||
" .status: .+1
|
||||
" .smes: .+1
|
||||
" .rmes: .+1
|
||||
" .fork: .+1
|
||||
|
||||
" library
|
||||
|
||||
.array: .+1
|
||||
s 2
|
||||
n 8
|
||||
n 7
|
||||
-1
|
||||
tad sp i
|
||||
cma
|
||||
tad lastv
|
||||
dac lastv
|
||||
lmq
|
||||
lac sp
|
||||
tad d1
|
||||
dac sp i
|
||||
isz sp
|
||||
lacq
|
||||
dac sp i
|
||||
isz sp
|
||||
jmp fetch
|
||||
|
||||
.getchr: .+1
|
||||
s 2
|
||||
n 8
|
||||
n 7
|
||||
lac sp
|
||||
tad d1
|
||||
dac sp i
|
||||
isz sp
|
||||
jms getc
|
||||
dac sp i
|
||||
isz sp
|
||||
jmp fetch
|
||||
|
||||
.putchr: .+1
|
||||
s 2
|
||||
n 8
|
||||
n 7
|
||||
lac sp i
|
||||
dac t1
|
||||
lrss 9
|
||||
jms putc
|
||||
lac t1
|
||||
jms putc
|
||||
jmp fetch
|
||||
|
||||
.flush: .+1
|
||||
n 8
|
||||
n 7
|
||||
jms flush
|
||||
jmp fetch
|
||||
|
||||
getc: 0
|
||||
lac iflg
|
||||
dzm iflg
|
||||
sza
|
||||
jmp getc i
|
||||
lac cibufp
|
||||
sad eibufp
|
||||
jmp 1f
|
||||
lac cibufp i
|
||||
and o777
|
||||
dac iflg
|
||||
lac cibufp i
|
||||
isz cibufp
|
||||
lrss 9
|
||||
jmp getc i
|
||||
1:
|
||||
lac .fin
|
||||
sys read; ibufp: ..; 64
|
||||
sna spa
|
||||
jmp 1f
|
||||
tad ibufp
|
||||
dac eibufp
|
||||
lac ibufp
|
||||
dac cibufp
|
||||
jmp getc+1
|
||||
1:
|
||||
lac o4
|
||||
jmp getc i
|
||||
|
||||
putc: 0
|
||||
and o777
|
||||
sna
|
||||
jmp putc i
|
||||
lmq
|
||||
lac oflg
|
||||
sza
|
||||
jmp 1f
|
||||
lacq
|
||||
alss 9
|
||||
dac cobufp i
|
||||
dac oflg
|
||||
jmp putc i
|
||||
1:
|
||||
lac cobufp i
|
||||
omq
|
||||
dac cobufp i
|
||||
dac cobufp i
|
||||
dzm oflg
|
||||
isz cobufp
|
||||
lac cobufp
|
||||
sad eobufp
|
||||
skp
|
||||
jmp putc i
|
||||
lac .fout
|
||||
sys write; obufp: ..; 64
|
||||
lac obufp
|
||||
dac cobufp
|
||||
jmp putc i
|
||||
|
||||
stop:
|
||||
jms flush
|
||||
las
|
||||
sma
|
||||
sys exit " sys save
|
||||
sys exit
|
||||
|
||||
flush: 0
|
||||
lac oflg
|
||||
sza
|
||||
isz cobufp
|
||||
lac cobufp
|
||||
cma
|
||||
tad obufp
|
||||
cma
|
||||
sna
|
||||
jmp flush i
|
||||
dac 1f+1
|
||||
lac obufp
|
||||
dac 1f
|
||||
lac .fout
|
||||
sys write; 1: ..; ..
|
||||
lac obufp
|
||||
dac cobufp
|
||||
dzm oflg
|
||||
jmp flush i
|
||||
|
||||
initio: 0
|
||||
lac 017777 i
|
||||
sad d4
|
||||
jmp 2f
|
||||
sad d8
|
||||
jmp 1f
|
||||
|
||||
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
|
||||
dac eibufp
|
||||
dac cibufp
|
||||
-64
|
||||
tad lastv
|
||||
dac lastv
|
||||
dac ibufp
|
||||
lac lastv
|
||||
dac eobufp
|
||||
-64
|
||||
tad lastv
|
||||
dac lastv
|
||||
dac obufp
|
||||
dac cobufp
|
||||
dzm oflg
|
||||
jmp initio i
|
||||
|
||||
.argv: 0
|
||||
.fin: 0
|
||||
.fout: 1
|
||||
eibufp: 0
|
||||
cibufp: 0
|
||||
iflg: 0
|
||||
eobufp: 0
|
||||
cobufp: 0
|
||||
oflg: 0
|
||||
lastv: 017770
|
||||
|
||||
o777: 0777
|
||||
d4:o4: 4
|
||||
d8: 8
|
||||
25
src/other/test.b
Normal file
25
src/other/test.b
Normal file
@@ -0,0 +1,25 @@
|
||||
/* test.b - test program for B run-time library brt.s
|
||||
|
||||
b test.b test.s
|
||||
echo abcABC > abc
|
||||
perl as7 --out test.out brt.s test.s bi.s
|
||||
perl a7out test.out
|
||||
*/
|
||||
|
||||
main {
|
||||
extrn fname, fin;
|
||||
auto ch;
|
||||
|
||||
fin = open(fname, 0);
|
||||
|
||||
goto loop;
|
||||
while (ch != 04) {
|
||||
putchr(ch);
|
||||
loop:
|
||||
ch = getchr();
|
||||
}
|
||||
|
||||
flush();
|
||||
}
|
||||
|
||||
fname [] 'ab','c ',' ',' ';
|
||||
Reference in New Issue
Block a user