diff --git a/misc/git_notes.txt b/misc/git_notes.txt index efeaa83..0c7dec8 100644 --- a/misc/git_notes.txt +++ b/misc/git_notes.txt @@ -3,3 +3,7 @@ to cache my Github username git config --global user.name "Warren Toomey" git config --global user.email wkt@tuhs.org + +To bring your own ocal repository up to date with Github: + git fetch origin + git merge origin/master diff --git a/scans/Makefile b/scans/Makefile new file mode 100644 index 0000000..8d6b259 --- /dev/null +++ b/scans/Makefile @@ -0,0 +1,4 @@ +AS7=../tools/as7 + +system: + $(AS7) s?.s sop.s > output diff --git a/scans/Readme b/scans/Readme index 2a67a55..08dc3e8 100644 --- a/scans/Readme +++ b/scans/Readme @@ -1,4 +1,4 @@ -This area contains the OCR'd version of the PDP-7 scans that are at +This area contains the OCR'd versions of the PDP-7 scans that are at http://www.tuhs.org/Archive/PDP-11/Distributions/research/McIlroy_v0/0*.pdf The files should be unaltered versions of the scanned pages. @@ -6,5 +6,30 @@ For modified versions of these files, look in src/cmds and src/sys. Details of the files: -s1.s: pages 2-3 of 01-s1.pdf, incomplete and with some cruft at the end +s1.s: pages 2-5 of 01-s1.pdf +s2.s: pages 7-12 of 01-s1.pdf +s3.s: pages 14-19 of 01-s1.pdf +s4.s: pages 21-26 of 01-s1.pdf +s5.s: pages 28-32 of 01-s1.pdf +s6.s: pages 34-38 of 01-s1.pdf +s7.s: pages 41-46 of 01-s1.pdf +s8.s: pages 48-51 of 01-s1.pdf +s9.s: pages 53-54 of 01-s1.pdf +sop.s pages 62-63 of 01-s1.pdf +sx.s: temp additional symbol defns +maksys.s: page 64 of 01-s1.pdf +trysys.s: page 65 of 01-s1.pdf + +bc.s: pages 7-11 of 06-5-12.pdf +bi.s: pages 12-19 of 06-5-12.pdf +bl.s: pages 3-6 of 06-5-12.pdf +cas.s: pages 1-17 of 04-cas.pdf cat.c: pages 21-23 of 06-5-12.pdf + +ind.b: page 2 of 08-rest.pdf +lease.b: page 4 of 08-rest.pdf + +as.s: pages 32-48 of 05-1-4.pdf + +ed1.s: pages 7-20 of 08-rest.pdf +ed2.s: pages 21-29 of 08-rest.pdf diff --git a/scans/as.s b/scans/as.s new file mode 100644 index 0000000..42a6c1b --- /dev/null +++ b/scans/as.s @@ -0,0 +1,980 @@ +" as + + jms init1 + +assm1: + lac eofflg + sza + jmp assm2 + lac passno + sza + jmp finis + jms init2 + +assm2: + jms gchar + sad d4 + jmp assm1 + sad d5 + jmp assm1 + lac char + dac savchr + jms gpair + lac rator + jms betwen; d1; d6 + jmp assm3 + jms expr + lac passno + sza + jms process + isz dot+1 + nop + lac dot+1 + and o17777 + sad dot+1 + jmp assm1 + jms error; >> + dzm dot+1 + jmp assm1 + +assm3: + lac rand + sad d2 + jmp assm4 + sza + jmp assm6 + lac rator + sza + jmp assm6 + lac rand+1 + jms betwen; dm1; d10 + jmp assm6 + dac name + tad fbxp + dac lvrand + lac i lvrand + dac name+1 + isz i lvrand + lac o146 + dac name+2 + dzm name+3 + jms tlookup + -1 + dac fbflg +assm4: + lac rand+1 + tad d4 + dac lvrand + lac rator + sza + jmp assm5 + lac dot + dac r + lac dot+1 + dac r+1 + jmp 1f + +assm5: + jms gpair + jms expr +1: + lac r + dac i lvrand + isz lvrand + lac r+1 + dac i lvrand + lac fbflg + sna + jmp assm1 + dzm fbflg + dzm name+1 + lac o142 + dac name+2 + jms lookup + jmp assm4 + +assm6: + jms error; x> + jmp assm1 + +init1: 0 + lac d1 + sys write; 1f; 2f-1f + dzm passno + lac o56040 + dac dot-4 + lac o56056 + dac cmflx-4 + lac o40040 + dac dot-3 + dac dot-2 + dac dot-1 + dac cmflx-3 + dac cmflx-2 + dac cmflx-1 + dzm iof + jms init + jmp i init1 +1: + 0111012 +2: + +init2: 0 + lac d1 + dac passno + sys write; 1f; 2f-1f + jms init + lac o17 + sys creat; 2f + dac bfo + sys open; 2f; 0 + dac bfi + dzm bufadd + jms copyz; buf; 64 + jmp i init2 +1: + 0111111;012000 +2: + 0141056;0157165;0164040;040040 + +init: 0 + lac i 017777 + dac narg + lac 017777 + tad d1 + dac fname + -1 + dac eofflg + jms ioinit + dzm savchr + dzm comflg + lac d1 + dac dot + dzm dot+1 + dzm cmflx + lac d4096 + dac cmflx+1 + dzm fbflg + jms copyz; fbxp: fbx; 10 + jmp i init + +finis: + lac iof + sys close + jms bufwr + lac bfi + sys close + lac bfo + sys close + -1 + tad namsiz + cma + rcl + dac char + rcl + tad char + dac 1f + lac o17 + sys creat; n.out + dac bfi + sys write; namlst; 1: 0 + lac bfi + sys close + sys exit + +n.out: + 0156056;0157165;0164040;040040 + +process: 0 + lac dot+1 + dac lvrand + lac dot + sad d3 + jmp proc4 + sza + jmp proc1 + -1 + tad cmflx+1 + cma + tad lvrand + dac lvrand + +proc1: + lac lvrand + spa + jmp proc4 + and o17700 + sad bufadd + jmp proc2 + jms bufwr + jms copyz; buf; 64 + lac lyrand + and o17700 + dac bufadd + dac 1f + lac bfi + sys seek; 1: 0; 0 + spa + jmp proc2 + lac bfi + sys read; buf; 64 + +proc2: + lac lyrand + and o77 + jms betwen; dm1; maxsto + dac maxsto + tad bufp + dac lvrand + lac r + sna + jmp proc3 + sad d3 + jmp proc5 + lac cmflx+1 + tad r+1 + dac r+1 + +proc3: + lac r+1 + dac i lvrand + jmp i process + +proc4: + jms error; .> + lac d1 + dac dot + dzm dot+1 + jmp skip + +proc5: + jms error; u> + jmp proc3 + +bufwr: 0 + lac bfo + sys seek; bufadd: 0; 0 + isz maxsto + lac bfo + sys write; bufp: buf; maxstp: -1 + -1 + dac maxsto + jmp i bufwr + +Xnumber: 0 + dac 3f + lac d1000 + dac 2f +1: + lac 3f + cll + idiv; 2: 0 + dac 3f + lacq + tad o60 + dac i 8 + iac 2b + cll + idiv; 10 + lacq + dac 2b + sza + jmp 1b + jmp i number +3: 0 + +getsc: 0 + lac i getsc + dac sctalp + isz getsc + lac i sctalp + dac sctal + add o400000 + dac i sctalp + ral + lac i sctal + szl + lrss 9 + and o177 + jmp i getsc + +putsc: 0 + and o177 + lmq + lac i putsc + dac sctalp + isz putsc + lac i sctalp + dac sctal + add o400000 + dac i sctalp + sma cla + jmp 1f + llss 27 + dac i sctal + lrss 9 + jmp i putsc + +1: + lac i sctal + omq + dac i sctal + lacq + jmp i putsc + +sctalp: 0 +sctal: 0 + +betwen: 0 + dac 2f + lac i betwen + dac 3f + isz betwen + lac i 3f + cma + tad 2f + spa + jmp 2f + lac i betwen + dac 3f + isz betwen + lac i 3f + cma + tad d1 + tad 2f + spa +1: + isz betwen + lac 2f + jmp i betwen +2: 0 +3: 0 + +copyz: 0 + -1 + tad i copyz + dac 8 + isz copyz + lac i copyz + cma + tad d1 + dac 2f + isz copyz +1: + dzm i 8 + isz 2f + jmp 1b + jmp i copyz +2: 0 + +error: 0 + lac passno + sza + jmp 1f + isz error + jmp i error +1: + -1 + tad mesp + dac 8 + lac i error + dac i 8 + lac o40 + dac i 8 + lac rator + sad d5 + jmp 1f + lac savchr + sad o12 + jmp 1f + lac lineno + jmp 2f +1: + -1 + tad lineno +2: + jms number + lac o12 + dac i 8 + -2 + tad mesp + cma + tad 8 + dac 1f + lac d1 + sys write; mesp: mes; 1: 0 + isz error + jmp i error + +skip: + lac rator + sad d5 + jmp assm1 +1: + jms gchar + sad d5 + jmp assm1 + jmp 1b + +ioinit: 0 + jms copyz; iobuf; 64 + lac iof + sys read; iobufp: iobuf; 64 + sna + jms nextfil + lac iobufp + dac tal + -129 + dac talc + jmp i ioinit + +nextfil: 0 + lac d1 + dac lineno + lac iof + sza + sys close +nf1: + lac narg + sad d4 + skp + jmp 1f + dzm eofflg + jmp i nextfil +1: + tad dm4 + dac narg + lac fname + tad d4 + dac fname + sys open; frame: 0; 0 + dac iof + sma + lac passno + sna + jmp nextfil i + lac fname + dac 1f + lac d1 + sys write; 1; 0; 4 + lac iof + sma + jmp 1f + lac d1 + sys write; emes; 2 + sys exit +1: + lac d1 + sys write; emes+1; 1 + jmp i nextfil +emes: + 040077;012000 + +gchar: 0 + lac savchr + dzm savchr + sza + jmp gch3 + lac eofflg + sza + jmp 1f + lac o12 + jmp gch3 +1: + isz talc + skp + jms ioinit + jms getsc; tal + sna + jmp gchar+1 + sad o177 + jmp gchar+1 + sad o12 + skp + jmp 1f + dzm comflc + isz lineno +1: + sad o42 + dac comflc + dac char + lac comflc + sza + jmp gchar+1 + lac char + +gch3: + dac char + jms betwn; d0; o200 + cla + tad lactab + dac .+1 + lac 0 + jmp i gchar + +gsymb: 0 + jms gchar + dac rator + tad jmpsw1 + dac 1f + lac char + sad o74 + jmp lqot + dac namc + jms gchar + lac char + sad o76 + jmp rqot + dac savchr + lac namc + dac char +1: + jmp 0 + +jmpsw1: + jmp .+1 + jmp i gsymb + jmp i gsymb + jmp i gsymb + jmp i gsymb + jmp gs1 + jmp i gsymb + jmp gs2 + jmp gs3 + +badchr: + jms error; g> +1: + jms gchar + lac char + sad o12 + skp + jmp 1b + dac savchr + jmp gsymb+1 + +lqot: + jms gchar + lac o40 + dac savchr + lac char + alss 9 + jmp 1f + +rqot: + lac namc +1: + dac rand+1 + lac d7 + dac rator + jmp i gsymb + +gs1: + jms gchar + sad d4 + jmp gs1 + lac char + dac savchr + jmp i gsymb + +gs2: + lac namep + dac tal1 + -7 + dac tal1c + lac char + jms putsc; tal1 + +gnam1: + jms gchar + jms betwen; d5; d8 + jmp gnam3 + lac char + jms putsc; tal1 + isz tal1c + jmp gnam1 + +gnam2: + jms gchar + jms betwen; d5; d8 + skp + jmp gnam2 + lac char + dac savchr + jms lookup + jmp i gsymb + +gnam3: + lac char + dac savchr +1: + lac o40 + jms putsc; tal1 + isz tal1c + jmp 1b + jms lookup + jmp i gsymb + +gs3: + dzm rand+1 + lac char + sad o60 + jmp 1f + lac d10 + jmp 2f +1: + lac d8 +2: + dac num2 + +num1: + lac rand+1 + cll + mul +num2: 0 + lacq + tad char + tad dm48 + dac rand+1 + jms gchar + sad d7 + jmp num1 + lac char + dac savchr + lac rand+1 + jms betwen; dm1; d10 + jmp i gsymb + dac name + tad fbxp + dac name+1 + lac i name+1 + dac name+1 + lac savchr + sad o146 + jmp 1f + sad o142 + skp + jmp i gsymb + dzm name+1 +1: + dac name+2 + dzm name+3 + lac d6 + dac rator + jms lookup + dzm savchr + jmp i gsymb + +tlookup: 0 + jmp 1f +lookup: 0 + dzm tlookup +1: + -1 + tad namlstp + dac 8 + lac namsiz + dac namc +lu1: + lac i 8 + sad name + jmp 1f + lac d5 +lu2: + tad 8 + dac 8 + isz namc + jmp lu1 + lac tlookup + sna + jmp 2f + lac fnamep + dac rand+1 + jmp i tlookup +2: + lac name + dac i 8 + lac 8 + dac rand+1 + lac name+1 + dac i 8 + lac name+2 + dac i 8 + lac name+3 + dac i 8 + lac d3 + dac i 8 + dzm i 8 + -1 + tad namsiz + dac namsiz + jmp i lookup +1: + lac i 8 + sad name+1 + jmp 1f + lac d4 + jmp lu2 +1: + lac i 8 + sad name+2 + jmp 1f + lac d3 + jmp lu2 +1: + lac i 8 + sad name+3 + jmp 1f + lac d2 + jmp lu2 +1: + -3 + tad 8 + dac rand+1 + lac tlookup + sza + jmp i tlookup + jmp i lookup +namep: name + +gpair: 0 + jms gsymb + lac rator + sad d4 + jmp gpair+1 + jms betwen; dm1; d6 + jmp gp1 + dzm rand + dzm rand+1 + jmp i gpair +gp1: + sad d7 + lac d4 + tad dm4 + dac rand + jms gsymb + lac rator + sad d4 + jmp gp2 + jms betwen; dm1; d6 + skp + jmp i gpair + jms error; x> + jmp skip +gp2: + jms gchar + jms betwen; d5; d8 + jmp gp3 + lac char + dac savchr + jmp i gpair +gp3: + lac char + dac savchr + jms gsymb + jmp i gpair + +expr: 0 + jms grand + -1 + dac srand +exp5: + lac rand + dac r + lac rand+1 + dac r+1 +exp1: + lac rator + jms betwen; d1; d5 + jmp exp3 + dac orator + jms gpair + jms grand + lac orator + sad d4 + jmp exp2 + jms oper; rand + jmp exp1 +exp2: + jms pickup + lac r + dac srand + lac r+1 + dac srand+1 + jmp expb +exp3: + sad d5 + jmp exp4 + jms error; x> + smp skip +exp4: + jms pickup + jmp i expr + +pickup: 0 + lac srand + spa + jmp i pickup + lac d4 + jms oper; srand + jmp i pickup + +grand: 0 + lac rand + sad d2 + skp + jmp i grand + lac rand+1 + tad d4 + dac rand+1 + lac i rand+1 + dac rand + isz rand+1 + lac i rand+1 + dac rand+1 + jmp i grand + +oper: 0 + tad opsw + dac oper1 + -1 + tad i oper + dac 8 + isz oper + lac r + sad d3 + jmp oper2 + lac i 8 + sad d3 + jmp oper2 +oper1: + jmp 0 +opsw: + jmp .-1 + jmp oplus + jmp ominus + tad r + dac r + lac r+1 + lmq + lac i 8 + omq + jmp oret +oplus: + tad r + dac r + lac r+1 + tad i 8 + jmp oret +ominus: + cma + tad d1 + tad r + dac r + -1 + tad i 8 + cma + tad r+1 +oret: + dac r+1 + lac r + jms betwen; dm1; d2 + skp + jmp i oper + jms error; r> + lac d1 + dac r + jmp i oper +oper2: + dac r + dzm r+1 + jmp i oper + +d0: 0 +d1: 1 +d4096: 4096 +d2: 2 +d3: 3 +d4: 4 +d5: 5 +d6: 6 +d7: 7 +d8: 8 +o12: d10: 10 +dm1: -1 +o40: 040 +o60: 060 +dm48: -48 +o400000: 0400000 +o177: 0177 +dm4: -4 +o200: 0200 +o42: 042 +o142: 0142 +o40040: 040040 +o56056: 056056 +o56040: 056040 +o146: 0146 +o17777: 017777 +d1000: 1000 +o17: 017 +o17700: 017700 +o77: 077 +o74: 074 +o76: 076 + +namsiz: -2 +namistp: namlst +fnamep: fakename +lactab: lac .+1 +8;8;8;8;8;8;8;8 +8;4;5;8;8;8;8;8 +8;8;8;8;8;8;8;8 +8;8;8;8;8;8;8;8 +4;8;8;8;8;8;8;8 +8;8;6;2;4;3;6;8 +7;7;7;7;7;7;7;7 +7;7;0;5;8;1;8;8 +8;6;6;6;6;6;6;6 +6;6;6;6;6;6;6;6 +6;6;6;6;6;6;6;6 +6;6;6;8;8;8;8;8 +8;6;6;6;6;6;6;6 +6;6;6;6;6;6;6;6 +6;6;6;6;6;6;6;6 +6;6;6;8;8;8;8;8 + +fbflg: .=.+1 +tal: .=.+1 +talc: .=.+1 +tal1: .=.+1 +tal1c: .=.+1 +narg: .=.+1 +lvrand: .=.+1 +eofflg: .=.+1 +namc: .=.+1 +passno: .=.+1 +char: .=.+1 +savchr: .=.+1 +comflg: .=.+1 +rator: .=.+1 +orator: .=.+1 +rand: .=.+2 +srand: .=.+2 +r: .=.+2 +name: .=.+4 +buf: .=.+64 +iobuf: .=.+64 +fbx: .=.+10 +mes: .=.+20 +iof: .=.+1 +bfi: .=.+1 +bfo: .=.+1 +lineno: .=.+1 + +fakename: .=.+6 +namlst: +.=.+4 +dot: +.=.+6 +cmflx: \ No newline at end of file diff --git a/scans/bc.s b/scans/bc.s new file mode 100644 index 0000000..b176f2b --- /dev/null +++ b/scans/bc.s @@ -0,0 +1,288 @@ +" bc + + jmp start +rinit: + jms initio + jmp .+1 i +initio: 0 + lac inter-1 + dac fetch + jmp rinit + jms inter +inter: 0 + las + and o17 + sza + jms trace + lac pc i + dac instr + lac pc + and o10000 + sna + jmp badpc + lac sp + and o17700 + sad o17700 + jmp badsp + and o10000 + sna + jmp badsp + lac instr + sad insasg + skp + jmp inter i + -4 + tad sp + dac t1 + lac t1 i + and o10000 + sna + jmp badasgn + lac instr + jmp inter i + +trace: 0 + and d1 + sza + jms dtrace + las + and d2 + sza + jms ddisp + las + and d4 + sza + jms histog + las + and d8 + sza + jmp stop + jmp trace i + +itrace: 0 + lac pc + dac 8 + lac 8 i + dac instr + lac 8 + jms octal; -4 + law 040 + jms putc + lac instr + cll; lrs 14 + tad lacop + dac .+1 + lac .. + jms putc + law 040 + jms putc + lac instr + jms octal; -4 + + lac instr + sad inslitr + skp + jmp 1f + law 040 + jms putc + lac 8 i + jms octal; -6 +1: + law 012 + jms putc + jms flush + jmp dtrace i + +ddisp: 0 + jms dspinit + lac dspbp + dac 8 + lac dp + sad olddp + skp + jms dspblk + lac pc + jms dspnt + lac sp + jms dspnt + lac lastv + jms dspnt + -1 + dac B i + lac pbs i + sza + jmp .-2 + jmp ddisp i + +dspblk: 0 + lac dspbuf + dac 8 + lac dp + dac t1 + dzm t2 +1: + lac t1 + sna + jmp 1f + lac o216000 " dx -20 + dac 8 i + lac t2 + tad o20 + dac t2 + lac t1 + tad d1 + dac t3 + lac t3 i + jms dspnt + lac t1 i + dac t1 + jmp 1b +1: + lac o160020 " sx 20 + tad t2 + dac dspbuf i + dac 8 i + lac 8 + dac dspbp + jmp dspblk i + +dspnt: 0 + and o7777 + lrss 2 + xor o164000 " sy 0 + dac 8 i + lac o17010 + dac 8 i + jmp dspnt i + +dspinit: 0 + -1 + tad dspinit + dac dspinit + -300 + tad lastv + dac lastv + dac dspbuf + -1 + dac dspinit i + dac dspbuf i + dzm olddp + lac dspbuf + sys capt + law 13 + sys sysloc + dac pbs + jmp dspinit i + +histog: 0 + jms hisinit + lac pc + lrs 6 + and o77 + tad histbuf + dac t1 + isz t1 i + jmp histog i + jmp . + +hisinit: 0 + -1 + tad hisinit + dac hisinit + -1 + dac hisinit i + -64 + dac t1 + tad lastv + dac lastv + dac histbuf + tad dm1 + dac 8 +1: + dsm 8 i + isz t1 + jmp 1b + jmp hisinit i + +histbuf: 0 +olddp: 0 +dspbuf: 0 +dspbp: 0 +instr: 0 +obs: 0 +inslitr: n 5 +insasg: b 1 +o17: 017 +d8: 8 +o77: 077 +o10000: 010000 +d5: 5 +o60: 060 +o7777: 07777 +o216000: 0216000 +o160020: 0160020 +o20: 020 +o164000: 0164000 +o17010: 017010 +o17700: 017700 +d2: 2 + +lacop: lac . + a>;b>;c>;f>;n>;s>;t>;u>;x>;y> + +badpc: + jms flush + lac d1 + sys write; mpc; mpcs + jmp stop +badsp: + jms flush + lac d1 + sys write; msp; msps + jmp stop +badasgn: + jms flush + lac d1 + sys write; mas; mass + jmp stop +mpc: + 012;;012 +mpcs = .-mpc +msp: + 012;;012 +msps = .-msp +mas: + 012;;012 +mass = .-mas + +octal: 0 + lmq + lac d5 + tad octal i + cma + dac 2f + sna + jmp 3f +1: + llss 3 + isz 2f + jmp 1b +3: + lac octal i + dac 2f + lacq + dac 2f+1 +1: + lac 2f+1 + lmq + ecla llss 3 + tad o60 + jms putc + lac 2f+1 + alss 3 + dac 2f+1 + isz 2f + jmp 1b + isz octal + jmp octal i +2: 0;0 diff --git a/scans/bi.s b/scans/bi.s new file mode 100644 index 0000000..322163f --- /dev/null +++ b/scans/bi.s @@ -0,0 +1,433 @@ +" bi + +start: + jms initio + -1 + tad .main + dac pc + +fetch: + lac pc i + imq + and o17777 + dac addr + ecla lls 4 + tad .+3 + dac .+1 + jmp .. i + jmp . i + autop; binop; consop; ifop; etcop; setop; traop + unaop; extop; aryop + + +ifop: + -2 + tad sp + dac sp + lac sp i + dac t1 + lac t1 i + sza + jmp fetch + -1 + tad addr i + dac pc + jmp fetch + +autop: + lac addr + tad dp + dac sp i + isz sp + isz sp + jmp fetch + +binop: + -2 + tad sp + dac sp + tad dm1 + dac t4 + tad dm1 + dac t3 + lac t3 i + dac t1 + lac sp i + dac t2 + lac t4 + dac t3 i + lac addr + tad .+3 + dac .+1 + jmp .. i + jmp . i + basg; bor; band; beq; bne; ble; blt; bge; bgt; brsh; blsh + badd; bmin; bmod; bmul; bdiv + +basg: + lac t2 i + dac t1 i + dac t4 i + jmp fetch + +bor: + lac t1 i + lmq + lac t2 i + omq + dac t4 i + jmp fetch + +band: + lac t2 i + and t2 i + dac t4 i + jmp fetch + +beq: + lac t1 i + xor t2 i + sna cla + lac d1 + dac t4 i + jmp fetch + +bne: + lac t1 i + xor t2 i + sza + lac d1 + dac t4 i + jmp fetch + +ble: + lac t2 i + cma + tad t1 i + spa cla + lac d1 + dac t4 i + jmp fetch + +blt: + lac t1 i + cma + tad t2 i + sma cla + lac d1 + dac t4 i + jmp fetch + +bge: + lac t1 i + cma + tad t2 i + spa cla + lac d1 + dac t4 i + jmp fetch + +bgt: + lac t2 i + cma + tad t1 i + sma cla + lac d1 + dac t4 i + jmp fetch + +brsh: +blsh: + hlt + +badd: + lac t1 i + tad t2 i + dac t4 i + jmp fetch + +bmin: + lac t1 i + cma + tad t2 i + cma + dac t4 i + jmp fetch + +bmod: + lac t2 i + dac .+4 + lac t1 i + cll; idiv; .. + dac t4 i + jmp fetch + +bmul: + lac t2 i + dac .+4 + lac t1 i + cll; mul; .. + lacq + dac t4 i + jmp fetch + +bdiv: + lac t2 i + dac .+4 + lac t1 i + cll; idiv; .. + lacq + dac t4 i + jmp fetch + +consop: + lac sp + tad d1 + dac sp i + isz sp + iac addr + dac sp i + isz sp + jmp fetch + +etcop: + lac addr + tad .+3 + dac .+1 + jmp .. i + jmp . i + mcall; mark; call; vector; litrl; goto; retrn; escp + +mcall: + -2 + tad sp + dac t1 + lac t1 i + dac t2 + -1 + tad t2 i + imq + lac dp + dac t1 i + lac t1 + dac dp + isz t1 + iac pc + dac t1 i + lacq + dac pc + jmp fetch + +mark: + -1 + tad sp + dac t2 + tad dm1 + dac t1 + lac t1 i + dac t3 + lac t3 i + dac t2 i + lac ap + dac t1 i + lac t1 + dac ap + jmp fetch + +call: + lac ap + tad d1 + dac 8 + dac 9 +1: + lac 8 i + dac t1 + lac t1 i + dac 9 i + isz 8 + -1 + tad sp + sad B + skp + jmp 1b + lac ap i + img + lac dp + dac ap i + lac ap + dac dp + isz ap + -1 + tad ap i + dac t1 + lac pc + dac ap i + lacq + dac ap + lac t1 + dac pc + jmp fetch + +vector: + -2 + tad sp + dac sp + tad dm2 + dac t1 + lac sp i + dac t2 + lac t1 i + dac t3 + lac t3 i + tad t2 i + dac t1 i + jmp fetch + +litrl: + lac sp + tad d1 + dac sp i + isz sp + lac pc i + dac sp i + isz sp + jmp fetch + +goto: + -2 + tad sp + dac sp + lac sp i + dac t1 + -1 + tad t1 i + dac pc + jmp fetch + +retrn: + -2 + tad sp + dac sp + lac sp i + dac t1 + lac t1 i + lmq + lac dp + dac sp + dac t1 + lac sp i + sna + jmp stop + dac dp + isz sp + lac sp + dac t1 i + lac sp i + dac pc + lacq + dac sp i + isz sp + jmp fetch + +escp: + law 2 + tad pc + dac t1 + jmp t1 i + +setop: + lac addr + tad dp + dac sp + jmp fetch + +traop: + -1 + tad addr + dac pc + jmp fetch + +unaop: + -1 + tad sp + dac t3 + tad dm1 + dac t2 + lac t2 i + dac t1 + lac t3 + dac t2 i + lac addr + tad .+3 + dac .+1 + jmp .. i + jmp . i + uadr; umin; uind; unot + +badr: + lac t1 + dac t3 i + jmp fetch + +bmin: + -1 + tad t1 i + cma + dac t3 i + jmp fetch + +bind: + lac t1 i + dac t2 i + jmp fetch + +bnot: + lac t1 i + sna cla + lac d1 + dac t3 i + jmp fetch + +extop: + lac addr + dac sp i + isz sp + isz sp + jmp fetch + +aryop: + lac addr + tad dp + dac t1 + tad d1 + dac t1 i + jmp fetch + +a = 040000 +b = a+a +c = b+a +f = c+a +n = f+a +s = n+a +t = s+a +u = t+a +x = u+a +f = x+a + +d1: 1 +dm1: -1 +dm2: -2 +o17777: 017777 + +:1: 0 +:2: 0 +:3: 0 +:4: 0 +:ddr: 0 + +pc = 017 + +sp: stack +dp: stack +ip: stack +stack: 0 \ No newline at end of file diff --git a/scans/bl.s b/scans/bl.s new file mode 100644 index 0000000..95111f1 --- /dev/null +++ b/scans/bl.s @@ -0,0 +1,194 @@ +" bl + +jmp start + +.array: .+1 + s 2 + n 8 + n 7 + -1 + tad sp i + cma + tad lastv + dac lastv + imq + lac sp + tad d1 + dac sp i + isz sp + lacq + dac sp i + isz sp + jmp fetch + +.read: .+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 + +.write: .+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 0o4 + jmp getc i + +putc: 0 + and 0777 + sna + jmp putc i + imq + 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 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 + +.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 \ No newline at end of file diff --git a/scans/cas.s b/scans/cas.s new file mode 100644 index 0000000..f4e61fc --- /dev/null +++ b/scans/cas.s @@ -0,0 +1,1059 @@ +"** 04-cas.pdf page 1 +" cas + + narg = i 017777 + + lac 017777 + tad d5 + dac name1 + tad d4 + dac name 2 + lac narg + sad d4 + jmp 1f + sad d8 + jmp 2f + jmp 3f +1: + law ttyout + dac name1 +2: + law ttyin + dac name2 +3: + sys open; name2: 0; 0 + sma + jmp 1f + lac name2 + dac 2f + lac d1 + sys write; 2: 0; 4 + lac d1 + sys write; mes; 2 + sys exit +1: + sys open; name1: 0; 1 + sma + jmp 1f + lac name1 + dac 2f + lac o17 + sys creat; 2: 0 + sma + jmp 1f + lac name1 + dac 2f + lac d1 + sys write; 2: 0; 4 + lac d1 + sys write; mes; 2 + sys exit +mes: + 040077;012 +1: + dzm nchar + dzm x + dzm y + dzm parflg + dzm nins + dzm nwds + lac bufp + dac 10 + +advanc: +"** 04-cas.pdf page 2 + lac nchar + dzm nchar + sza + jmp adv1 + lac d2 + sys read; char; 1 + sna + jmp done + lac char + and o777 + dac nchar + lac char + lrss 9 + +adv1: + sna + jmp advanc + dac char + lac labflg + sna + jmp 2f + lac char + sad o12 + skp + jmp 1f + dzm labflg + dac i 11 + jmp advanc +1: + dac i 11 + jmp advanc +2: + lac parflg + sza + jmp atoz + lac char + sad o12 + jmp advanc + sad o72 + skp + jmp 1f + -4 + dac labflg + dac mod3 + jms wbuf "??? + lac lbufp + dac 11 + lac o170072 + dac i 10 + lac o12 + dac i 10 + lac o60 + dac i 10 + isz nwds + isz nwds + isz nwds + jmp advanc +1: + sad o170 + skp + jmp 1f +"** 04-cas.pdf page 3 + dzm vis + jmp advanc +1: + sad o166 + skp + jmp 1f + lac visbit + dac vis + jmp advanc +1: + sad 0162 + skp + jmp letr + isz mod3 + skp + jmp 2f + lac o60060 +1: + dac i 10 + isz nwds + isz mod3 + jmp 1b +2: + lac o12 + dac i 10 + isz nwds + lac lbufp + dac 11 + 1: "??? + lac i 11 + sad o12 + jmp 1f + dac i 10 + isz nwds + jmp 1b +1: + lac o75170 + dac i 10 + isz nwds + lac ob1 + dac i 10 + isz nwds + lac sp + dac i 10 + isz nwds + lac nins + dzm nins + tad o100 + lmq + llss 10 + cla + llss 3 + alss 6 + llss 3 + tad o60060 + dac i 10 + cla + llss 3 + alss 6 + llss 3 + tad o60060 +"** 04-cas.pdf page 4 + dac i 10 + cla + llss 3 + alss 6 + llss 3 + tad o60060 + dac i 10 + lac nwds + tad d4 + dac nwds + lac o12012 + dac i 10 + dzm x + dzm y + jmp advanc +letr: + tad om141 "??? + spa + jmp error + tad dm16 + sma "??? + jmp error + cma "??? + tad dm3 + dac ny + -1 + dac parflg + jmp advanc + +atoz: + lac char + tad om141 + spa + jmp error + tad dm14 + sma + jmp error + tad d14 + dac nx + +loop: + -1 + tad x + cma + tad nx + dac delx + -1 + tad y + cma + tad ny + dac dely + " generate direction + + lac delx + sna + jmp c1 + spa + jmp c2 + lac dely ;"dx ,gr, 0 + sna + jmp c3 +"** 04-cas.pdf page 5 + spa + jmp c4 + lac d1 + jmp b +c3: + lac d2 + jmp a +c4: + lac d3 + jmp b + +c1: + lac dely + sna + jmp out + spa + jmp c5 + cla + jmp a +c5: + lac d4 + jmp a +c2: + lac dely + sna + jmp c6 + spa + jmp c7 + lac d7 + jmp b +c6: + lac d6 + jmp a +c7: + lac d5 + jmp b + " + " +a: + dac direc + lac delx + sma + jmp 1f + cma + tad d1 + dac delx +1: + lac dely + sma + jmp 1f + cma + tad d1 +1: + tad dlex + tad dm4 + sma + cla + tad d3 + dac dist + tad incxp + dac tmp +"** 04-cas.pdf page 6 + lac i tmp + dac incx + lac dist + tad incyp + dac tmp + lac i tmp + dac incy + jmp com + " +b: + dzm dist + dac direc + lac incxt + dac incx + lac incyt + dac incy + " +com: + isz nins + lac dist + alss 4 + xor vis + xor direc + isz mod3 + skp + jmp 1f +2: + lmq + llss 12 + cla + llss 3 + alss 6 + llss 3 + tad o60060 + dac i 10 + isz nwds + jmp 3f +1: + dac tmp + lac o12060 + dac i 10 + isz nwds + -3 + dac mod3 + lac tmp + jmp 2b +3: + lac direc + tad incx + dac tmp + lac i tmp + tad x + dac x + lac direc + tad incy + dac tmp + lac i tmp + tad y + dac y + jmp loop +"** 04-cas.pdf page 7 +out: + lac nx + dac x + lac ny + dac y + dzm parflg + jmp advanc + +done: + lac d2 + sys close + jms wbuf + lac d3 + sys close + sys exit + +error: + lac d1 + sys write; char; 1 + lac d1 + sys write; mes; 2 + dzm parflg + dzm labflg + jmp advanc + +wbuf: 0 + lac nwds + dac 1f + lac d3 + sys write; buf; 1f: 0; "??? + dzm nwds + lac bufp + dac 10 + jmp i wbuf + +d1: 1 +d2: 2 +d3: 3 +d4: 4 +d5: 5 +d6: 6 +d7: 7 +d8: 8 +o12: 012 +o75170: 075170 +ob1: 055142 + +sp: 053060 +o60: 060 +o60060: 060060 +o73: 073 +d6: 6 "seems like a dupe +d14: 14 +dm14: -14 +dm16: -16 +om141: -0141 "??? +dm3: -3 +dm4: -4 +o162: 0162 +o166: 0166 +"** 04-cas.pdf page 8 +o17: 017 +o777: 0777 +o72: 072 +o170: 0170 +o10000: 010000 +o20000: 020000 +o200000: 0200000 +o41: 041 +ttyin: + 0164164;0171151;0156040;040040 +ttyout: + 0164164;0171157;0165164;040040 + +char: .=.+1 +parflg: .=.+1 +labflg: .=.+1 +obuf: .=.+8 +x: .=.+1 +y: .=.+1 +nx: .=.+1 +ny: .=.+1 +vis: .=.+1 +nchar: .=.+1 + " +incxp:incxt +incyp:incyt +incxt: x1;x2;x3;x4 +incyt: y1;y2;y3;y4 + " +x1: 0;1;1;1;0;-1;-1;-1 +x2: 0;2;2;2;0;-2;-2;-2 +x3: 0;3;3;3;0;-3;-3;-3 +x4: 0;4;4;4;0;-4;-4;-4 +y1: 1;1;0;-1;-1;-1;0;1 +y2: 2;2;0;-2;-2;-2;0;2 +y3: 3;3;0;-3;-3;-3;0;3 +y4: 4;4;0;-4;-4;-4;0;4 +delx: .=.+1 +dely: .=.+1 +incx: .=.+1 +incy: .=.+1 +direc: .=.+1 +dist: .=.+1 +visbit: 010 +mod3: .=.+1 +tmp: .=.+1 +buf: .=.+500 +bufp: buf-1 +lbuf: .=.+10 +lpbufp: lbuf-1 +nwds: .=.+1 +o1770072: 0170072 +nins: .=.+1 +o100: 0100 +o12012: 012012 +o12060: 012060 + + + + + +"** 04-cas.pdf page 9 +:ca +v +af +nl "??? +x +hd +v +hi +x +mn +r + +:cb +x +ga +v +gi +ik +kk +mi "??? +ma +aa +ai +ck +ek +gi +x +mn +r + +:cc +x +kk +v +mi "??? +mc +ka +ca +ac +ai +dl +x +mn +r + +:cd +v +aa +ai +ck +kk +mi +ma +x +mn +r + +:ce +x +mk +v +ma +"** 04-cas.pdf page 10 +aa +ak +x +gh +v +ga +x +mn +r + +:cf +v +aa +ak +x +gh +v +ga +x +mn +r + +:cg +x +gf +v +gk +nk +x +kk +v +mi +mc +ka +ca +ac +ai +dl +x +mn +r + +:ch +x +aa +v +na +x +gb "??? +v +gk +x +ak +v +nk +x +mn +r + +:ci +x +"** 04-cas.pdf page 11 +md +v +mi +x +lf +v +af +x +ad +v +ai +x +mn +r + +:cj +x +ka +v +mc +mg +ki +ai "??? +x +ag +v +al "??? +x +mn +r + +:ck +x +aa +v +na +x +ak +v +ia +x +mk +v +fe +x +mn +r + +:cl +x +aa +v +ma +mk +x +mn +r + +:cm +v +aa +"** 04-cas.pdf page 12 +hf +ak +nk +x +mn +r + +:cn +x +ak +v +mk +aa +na +x +mn +r + +:co +x "??? +ai +v +ch +ei +ck +ai +ac +ca +ka +mc "??? +mi +kk +ck +x +mn +r + +:cp +v +aa +ai +ck +ek +gi +ga +x +mn +r + +:cq +x +mc +v +ka +ca +ac +ai +ck +kk +mi +mc +"** 04-cas.pdf page 13 +x +jh +v +nl +x +mn +r + +:cr +v +aa +ai +ck +ek +gi +ga +x +mk +v +gf +x +mn +r + +:cs +x +ka +v +mc +mi +kk +ik +gi +gc +ea +ca +ac +ai +dl +x +mn +r + +:ct +x +aa +v +al +x +mf +v +af +x +mn +r + +:cu +x +aa +v +ka +"** 04-cas.pdf page 14 +mc +ml "??? +kk +x +ak +v +lk +x +mn +r + +:cv +x +aa +v +mf +x +ak +v +mf +x +mn +r + +:cw +x +aa +v +mc +af +x +ak +v +mi +af +x +mn +r + +:cx +v +gf +x +ak +v +gf +x +aa +v +nl +x +mn +r + +:cy +x +aa +v +if +x +ak +"** 04-cas.pdf page 15 +v +if +nf +x +mn +r + +:cz +x +aa +v +ak +ma +ml +x +mn +r + +:c0 +x +ck +v +ai +ac +ca +ka +mc +mi +kk +ck +x +mn +r + +:c1 +x +ce +v +af +mf +x +md +v +mi +x +mn +r + +:c2 +x +ca +v +ac +ai +ck +ek +gi +gc +ia +ma +ml "??? +"** 04-cas.pdf page 16 +mc +mi +kk +hk +fi +fc +ha +x +mn +r + +:c7 +x +aa +v +ak +nb +x +mn +r + +:c8 +x +gc +v +ea +ca +ac +ai +ck +ek +gi +gc +ia +ka +mc +mi +kk +ik +gi +x +mn +r + +:c9 +x +ka +v +mc +mi +kk +ck +ai +ac +ca +fa +hc +hi +fk +x +mn +"** 04-cas.pdf page 17 +x +mn +r + +:c3 +x +aa +v +ak +fe +fi +hk +kk +mi +mc +x +ka +v +nd +x +mn +r + +:c4 +x +mh +v +ah +ia +ll +x +mn +r + +:c5 +x +ak +v +aa +fa +fi +hk +kk +mi +mc +x +ka +v +nd +x +mn +r + +:c6 +x +ck +v +ai +ac +ca +ka + +" The end of file seems abrupt, every other :cX section ends with: +" x +" mn +" r diff --git a/scans/ed1.s b/scans/ed1.s new file mode 100644 index 0000000..20bde48 --- /dev/null +++ b/scans/ed1.s @@ -0,0 +1,771 @@ +"** 08-rest.pdf page 8 +"[handwritten page number top right of scan - 1] +" ed1 + lac d1 + sys write; 1f; 3 + lac o17 + sys creat; tname + spa + sys save + dac sfo + sys open; tname; 0 + spa + sys save + dac sfi + -1 + tad lnodp + dac zermp + tad d1 + dac zerop + dac dot + tad d1 + dac eofp + dzm i eofp + dzm i zerop + dzm lastre + dzm fbuf + lac d1 + dac dskadr + dac wrlfg + dzm diskin + "o------------> [scan markup] + jmp advanc +1: + ; ; 012 +advanc: + jms rline + lac linep + dac tal + dzm adrflg + jms addres + jmp comand + -1 + dac adrflg + lac addr + dac addr1 + dac addr2 +1: + lac char + sad o54 + jmp 2f + sad o73 + skp + jmp chkwrp + lac addr + dac dot +2: + jms addres + jmp error + lac addr2 + dac addr1 + lac addr + dac addr2 + jmp 1b +"** 08-rest.pdf page 9 +"[handwritten page number top right of scan - 2] +chkwrp: + -1 + tad addr1 + jms betwen; d1; addr2 + jmp error + +comand: + lac char + sad o141 + jmp ca + sad o143 + jmp cc + sad o144 + jmp cd + sad o160 + jmp cp + sad o161 + jmp cq + sad o162 + jmp cr + sad o163 + jmp cs + sad o167 + jmp cw + sad o12 + jmp cnl + sad o75 + jmp ceq + jmp error +ca: + jms newline + jms setfl + lac addr2 + dac dot +ca1: + jms rline + lac line + sad o56012 + jmp advanc + jms append + jmp ca1 + +cc: cd: + jms newline + jms setdd + lac addr1 + sad zerop + jmp error + dac dot + tad dm1 + dac 9 + lac addr2 + dac 8 +2: + lac i 8 + dac i 9 + sza + jmp 2b +"??? illegible line cut off - dac 0, lac 0, something else??? +"** 08-rest.pdf page 10 +"[handwritten page number top right of scan - 3] + dac eofp + lac char + sad o144 + jmp advanc + -1 + tad dot + dac dot + jmp ca1 + +cp: + jms newline +cp1: + jms setdd + lac addr1 + sad zerop + jmp error +1: + lac addr1 + dac dot + lac i addr1 + jms gline + dac 2f + lac d1 + sys write; line; 2: 0 + lac addr1 + sad addr1 + jmp advanc + tad d1 + dac addr1 + jmp 1b + +cq: + jms newline + lac adrflg + sza + jmp error + sys exit + +cr: + jms setfl + lac addr2 + dac dot + jms rname + "------------> [scan markup] + sys open; fbuf; 0 + spa + jmp error + dac tfi + lac linep + dac tal + dzm num +1: + lac tfi + sys read; tbuf; 64 + sza + jmp 2f + lac tfi + sys close + jms number + jmp advanc +2: +"??? illegible line cut off - cma, sma, something else? +"** 08-rest.pdf page 11 +"[handwritten page number top right of scan - 4] + tad d1 + rcl + dac c1 + lac tbufp + dac tal1 +2: + jms getsc; tal1 + sna + jmp 3f + jms putsc; tal + isz num + sad o12 + skp + jmp 3f + lac tal + add o400000 + and o17777 + cma + tad linep + cma + dac linsiz + jms append + lac linep + dac tal +3: + isz c1 + jmp 2b + jmp 1b +cw: + jms setfl + lac i addr1 + sna + jmp error + jms rname + lac o17 + sys creat; fbuf + spa + jmp error + dac tfi + -128 + dac c2 + lac tbufp + dac tal1 + dzm num +1: + lac i addr1 + jms gline + rcl + cma + tad d1 + dac c1 + lac linep + dac tal +2: + jms getsc; tal + sna + jmp 3f + isz num + jmp putsc; tal1 + isz c2 "??? +"** 08-rest.pdf page 12 +"[handwritten page number top right of scan - 5] + jmp 3f + lac tfi + sys write; tbuf; 64 + -128 + dac c2 + lac tbufp + dac tal1 +3: + isz c1 + jmp 2b + lac addr1 + sad addr2 + jmp 1f + isz addr1 + jmp 1b +1: + lac tal1 + sma cla + jmp 1f + jms putsc; tal1 +1: + -1 + tad tufp + cma + tad tal1 + dac 1f + lac tfi + sys write; tbuf; 1: 0 + lac tfi + sys close + jms number + jmp advanc + +cn1: + lac adrflg + sna + jmp 1f + lac addr2 + dac addr1 + jmp cp1 +1: + lac dot + tad d1 + sad eofp + jmp error + dac dot + jmp cp1 + +ceq: + jms newline + jms setfl + lac addr2 + dac dot + cma + tad zerop + cma + dac num + jms number + jmp advanc + +setdd: 0 +"** 08-rest.pdf page 13 +"[handwritten page number top right of scan - 6] + lac adrflg + sza + jmp i setdd + lac dot + dac addr1 + dac addr2 + jmp i setdd + +setfl: 0 + lac adrflg + sza + jmp i setfl + lac zerop + tad d1 + dac addr1 + -1 + tad eofp + dac addr2 + jmp i setfl + +newline: 0 + jms getsc; tal + sad o12 + jmp i newline + jmp error + +addres: 0 + dzm minflg "..) [stray scan mark?] + -1 + dac addr +ad1: + jms getsc; tal +ad2: + jms betwen; d47; d56 + skp + jmp numb + sad o40 "[o40 circled in scan] + jmp ad1 "[hand drawn check mark follows operand in scan] + sad o11 + jmp ad1 "[hand drawn check mark follows operand in scan] + "[check mark underlined in scan] + sad o55 + jmp amin "[hand drawn check mark follows operand in scan] + sad o56 + jmp adot "[hand drawn check mark follows operand in scan] + sad o53 + jmp ad1 "[hand drawn check mark follows operand in scan] + sad o44 + jmp adol "[hand drawn check mark follows operand in scan] + sad o57 + jmp fsrch "[hand drawn check mark follows operand in scan] + sad o77 + jmp bsrch "[hand drawn check mark follows operand in scan] + dac char + lac minflg + sza + jmp error + lac addr + sma + isz addres + jmp i addres +"** 08-rest.pdf page 14 +"[handwritten page number top right of scan - 7] +adot: + lac minflg + sza + jmp error + lac addr + sma + jmp error + lac dot + dac addr + jmp ad1 + +adol: + lac minflg + sza + jmp error + lac addr + sma + jmp error + -1 + tad eofp + dac addr + jmp ad1 + +amin: + -1 + dac minflg + jmp ad1 + +numb: + dac char + sad o60 + jmp 1f + lac d10 + jmp 2f +1: + lac d8 +2: + dac 2f + dzm num +1: + lac num + cll; mul; 2: 0 + lacq + tad char + tad dm48 + dac num + jms getsc; tal + dac char + jms betwen; d47; d58 + skp + jmp 1b + lac minflg + sna + jmp 1f + -1 + tad num + cma + dac num + dzm minflg +1: + lac addr +"** 08-rest.pdf page 15 +"[handwritten page number top right of scan - 8] + spa + lac zerop + tad num + dac addr + jms betwen; zermp; eofp + jmp error + lac char + jmp ad2 + +number: 0 + lac d100000 + dac n1 + law tbuf-1 + dac 8 +n0: + lac num + cll; idiv; n1: 0 + dac num + lacq + tad d48 + dac i 8 + lac n1 + cll; idiv; 10 + lacq + dac n1 + sza + jmp n0 + lac o12 + dac i 8 + law tbuf-1 + dac 8 + dac 9 + -5 + dac n1 +n2: + lac i 8 + sad d48 + skp + jmp n3 + dzm i 9 + isz n1 + jmp n2 +n3: + lac d1 + sys write; tbuf; 7 + jmp i number + +rname: 0 + lac fbufp + dac tal1 + -8 + dac c1 +1: + jms getsc; tal + sad o40 + jmp 1b + sad o12 + jmp 1f + jms putsc; tal1 + isz c1 + jmp 1b +"** 08-rest.pdf page 16 +"[handwritten page number top right of scan - 9] + jmp i rname +1: + lac tal1 + sad fbufp + skp + jmp 1f + lac fbuf + sna + jmp error + jmp i rname +1: + lac o40 + jms putsc; tal1 + isz c1 + jmp 1b + jmp i rname + +gline: 0 + dac glint1 + jms getdsk + lac glint1 " [these 6 lines were surrounded by a box + adn o17777 " that was Xed out with an arrow pointing to it]: + tad dskbfp " -- + dac ital "|\/| + lac linep "|/\|<--- + dac otal " -- +1: + lac ital + sad edskbfp + skp + jmp 2f + lac diskin + tad d1024 + jms getdsk + lac dskbfp + dac ital +2: + jms getsc; ital + jms putsc; otal + sad o12 + skp + jmp 1b + lac otal + sma + jmp 1f + cla + jms putsc; otal +1: + lac linpm1 + cma + tad otal + jmp i gline + +rline: 0 + lac linep + dac tal + +1: + cla + sys read; char; 1 + lac char +"** 08-rest.pdf page 17 +"[handwritten page number top right of scan - 10] + lrss 9 + jms esc + lac char + and o777 + jms esc + jmp 1b + +esc: 0 + sna + jmp i esc + jms putsc; tal + sad o12 + jmp 2f + sad o100 + jmp 1f + sad o43 + skp + jmp i esc + -1 + tad tal + dac tal + and o17777 + sad linpm1 + jmp 1f + jmp i esc + +1: + lac linep + dac tal + jmp i esc + +2: + lac tal + sma cla + jmp 1f + jms putsc; tal +1: + -1 + tad linep + cma + tad tal + dac linsiz + jmp i rline + +getsc: 0 + lac i getsc + dac sctalp + isz getsc + lac i sctalp + dac sctal + add o400000 + dac i sctal + ral + lac i sctal + szl + lrss 9 + and o777 + jmp i getsc + +putsc: 0 + and o777 +"** 08-rest.pdf page 18 +"[handwritten page number top right of scan - 11] + lmq + lac i putsc + dac sctalp + isz putsc + lac i sctalp + dac sctal + add o400000 + dac i sctalp + sma cla + jmp 1f + llss 27 + dac i sctal + lrss 9 + jmp i putsc + +1: + lac i sctal + and o777000 + omq + dac i sctal + lacq + jmp i putsc + +append: 0 + -1 + tad eofp + dac 8 + cma + tad dot + dac apt1 +1: + lac i 8 + dac i 8 + -3 + tad 8 + dac 8 + isz apt1 + jmp 1b + isz eofp + dzm i eofp + isz dot + jms addline + jmp i append + +addline: 0 + lac dskadr + dac i dot + jms getdsk "[line crossed out - scan markup] + -1 + tad linsiz + cma + dac apt1 + law line-1 + dac 8 + lac dskadr "[line crossed out - scan markup] + and o1777 "[line crossed out - scan markup] + tad dskbfp "[line crossed out - scan markup] + dac otal "[line crossed out - scan markup] + lac dskadr "[line crossed out - scan markup] + tad linsiz "[line crossed out - scan markup] + dac dskadr "[line crossed out - scan markup] +"** 08-rest.pdf page 19 +"[handwritten page number top right of scan - 12] +1: + lac otal " [these 9 lines were surrounded by a box + sad edskbfp " that was Xed out]: + skp " -- + jmp 2f "|\/| + lac diskin "|/\| + tad d1024 " -- + jms getdsk " + lac dskbfp " + dac otal " +2: "[line crossed out - scan markup] + lac i 8 + dac i otal "[line crossed out and a note that looks like *jous prtwrd*] + isz otal + dzm wrflg "[line crossed out - scan markup] + isz apt1 + jmp 1b + jmp i addline + + +getdsk: 0 "[the entire getdsk procedure was surrounded + and o776000 " by a box that was Xed out]: + sad diskin " -- + jmp i getdsk "|\/| + dac 2f "|/\| + lac wrflg " -- + sza " + jmp 3f " + lac diskin " + dac 1f " + lac sfo " + sys seek; 1: 0; 0 " + lac sfo " + sys write; dskbuf; 1024 " + lac d1 " + dac wrflg " +3: " + lac 2f " + dac diskin " + lac sfi " + sys seek; 2: 0; 0 " + spa " + jmp i getdsk " + lac sfi " + sys read; dskbuf; 1024 " + jmp i getdsk " + +betwen: 0 + dac bett1 + lac i betwen + dac bett2 + isz betwen + lac i bett2 + cma + tad bett1 + spa + jmp 1f + lac i betwen + dac bett2 + isz betwen + -1 + tad i bett2 +"** 08-rest.pdf page 20 +"[handwritten page number top right of scan - 13] + cma + tad bett1 + spa +1: + isz betwen + lac bett1 + jmp i betwen + +error: + lac d1 + sys write; 1f; 1 + jmp advanc +1: + 077012 \ No newline at end of file diff --git a/scans/ed2.s b/scans/ed2.s new file mode 100644 index 0000000..3345e98 --- /dev/null +++ b/scans/ed2.s @@ -0,0 +1,519 @@ +"** 08-rest.pdf page 21 +"[handwritten page number top right of scan - 14] +" ed2 + +cs: + jsm getsc; tal + sad o40 + jmp cs + sad o12 + jmp error + dac delim + jms compile + lac tbufp + dac tal1 +1: + jms getsc; tal + sad delim + jmp 1f + sad o12 + jmp error + jms putsc; tal1 + jmp 1b +1: + lac o12 + jms putsc; tal1 + jms newline + jms setdd + lac addr1 + sad zerop + jmp error +1: + dac addr1 + lac i addr1 + jms execute + jmp 2f + lac addr1 + dac dot + law line-1 + dac 8 + law nlist-1 + dac 9 + -64 + dac c1 +3: + lac i 8 + dac i 9 + isz c1 + jmp 3b + -1 + tad fchrno + dac linsiz + rcr + szl + xor o400000 + tad linep + dac tal1 "??? + lac tbufp + dac tal +3: + jms getsc; tal + sad o12 + jmp 3f + jms putsc; tal1 + isz linsiz "??? +"** 08-rest.pdf page 22 +"[handwritten page number top right of scan - 15] + jmp 3b +3: + -1 + tad lcrhno + rcr + szl + xor o400000 + tad nlistp + dac tal +3: + jms getsc; tal + jms putsc; tal1 + isz linsiz + sad o12 + skp + jmp 3b + jms addline +2: + lac addr1 + sad addr2 + jmp advanc + tad d1 + jmp 1b + +fsrch: + dac delim + jms compile + jms srcsav + lac dot +floop: + tad d1 + dac addr + lac i addr + sza + jmp 1f + lac zerop + dac addr + jmp 2f +1: + jms execute + jmp 2f + jms srcres + jmp ad1 +2: + lac addr + sad dot + jmp error + jmp floop + +bsrch: + dac delim + jms compile + jms srcsav + lac dot + dad zerop + lac eofp +bloop: + tad dm1 + dac addr + lac i addr +"** 08-rest.pdf page 23 +"[handwritten page number top right of scan - 16] + sza + jmp 1f + lac eofp + dac addr + jmp 2f +1: + jms execute + jmp 2f + jms srcres + jmp ad1 +2: + lac addr + sad dot + jmp error + jmp bloop + +srcsav: 0 + lac minflg + sza + jmp error + lac addr + sma + jmp error + law line-1 + dac 8 + law tbuf-1 + dac 9 + -64 + dac c1 +1: + lac i 8 + dac i 9 + isz c1 + jmp 1b + jmp i srcsav + +srcres: 0 + law tbuf-1 + dac 8 + law line-1 + dac 9 + -64 + dac c1 +1: + lac i 8 + dac i 9 + isz c1 + jmp 1b + jmp i srcres + +compile: 0 + law compbuf-1 + dac 8 + dzm prev + dzm compflg + +cadvanc: + jms getsc; tal + sad delim + jmp cdone + dac compflg "??? +"** 08-rest.pdf page 24 +"[handwritten page number top right of scan - 17] + dzm lastre + sad o12 + jmp error + "sad o133 + "jmp chrcls + sad o136 "??? + jmp beglin + sad o44 + jmp endlin + "sad o52 + "jmp clsure + dac 1f + jmp comp + 1; jms matchar; 1: 0; 0 + jmp cadvanc + +cdone: + lac compflg + sna + jmp 1f + dac lastre + jms comp + 1; jms found; 0 + jmp i compile +1: "??? + lac lastre + sna + jmp error + jmp i compile + +chrcls: + jmp error + +beglin: "??? + jms comp + 1; jms matbol; 0 + dzm prev + jmp cadvanc + +endlin: "??? + jms comp + 1; jms mateol; 0 + dzm prev + jmp cadvanc + +clsure: + lac prev + sna + jmp error + tad d1 + dac 1f + jms comp + 1; jms matclo; 1: 0; 0 + dzm prev + jmp cadvanc + +comp: 0 "??? + -1 + tad comp + dac 9 + lac 8 "??? +"** 08-rest.pdf page 25 +"[handwritten page number top right of scan - 18] + dac prev +1: "??? + lac i 9 + sna + jmp i 9 + dac i 8 + jmp 1b + +execute: 0 + jms gline + lac linep + dac tal1 + dzm charno + dzm fchrno + dzm lchrno + lac jmpclist + dac trvect + lac jmpnlist + dac trvect+1 + lac jmpxchg + dac i trvect+1 + jmp 1f + +exchg: "??? + lacq + sad o12 + jmp i execute + lac jmpxchg + dac i 8 +1: "??? + lac trvect + lmq + lac trvect+1 + dac trvect + lacq + dac trvect+1 + tad dm1 + dac 8 + jms getsc; tal1 + lmq + isz charno + jms compbuf +charno: + 0 +trvect: + 0;0 + +matchar: 0 "??? + -2 + tad matchar + dac exret + lac i exret + dac exret + lacq + sad i matchar + skp + jmp 1f + lac matchar + adn o17777 + tad jms1 + dac i 8 "??? [unreadable page cutoff] +"** 08-rest.pdf page 26 +"[handwritten page number top right of scan - 19] + lac i exret + dac i 8 +1: "??? + isz exret + jmp i exret + +found: 0 + -2 + tad found + dac exret + lac i exret + dac exret + lac fchrno + sza + jmp 1f + isz execute + jmp 2f +1: "??? + sad i exret + jmp 1f + cma + tad i exret + spa + jmp 2f + jmp 3f +1: "??? + lac charno + cma + tad charno + spa + jmp 3f +2: "??? + lac i exret + dac fchrno + lac charno + dac lchrno +3: "??? + isz exret + jmp i exret + +matbol: 0 "??? + lac charno + sad d1 + jmp 1f + lac matbol + jmp 2f +1: "??? + lac matbol + jmp 3f + +mateol: 0 "??? + lacq + sad o12 + jmp 1f + lac mateol +2: "??? + tad dm2 + dac exret + lac i exret + dac 9 + "??? [line is cut off in scan, maybe lac i 8 or jmp i 9] +"** 08-rest.pdf page 27 +"[handwritten page number top right of scan - 20] +1: "??? + lac mateol +3: "??? + tad dm3 + dac 9 + lac i 9 + isz 9 + dac i 9 + jmp i 9 + +matclo: 0 "??? + -2 + tad matclo + dac exret + lac i exret + dac cloret + lac i cloret + dac 1f + dac 2f + lac i matclo + dac exret + jms i exret; 1: 0 + isz matclo + jms i matclo; 2: 0 + isz cloret + jmp i cloret + +"??? the remainder of this scan had an unreadable first character +"??? I did the best I could to recreate the characters appropriately +o1: 1 +o133: 0133 +dm3: -3 +o136: 0136 +dm2: -2 +o52: 052 +o57: 057 +o77: 077 +o40: 040 +o12: 012 +d47: 47 +d58: 58 +dm48: -48 +d10: 10 +d8: 8 +d48: o60: 060 +d100000: 100000 +o44: 044 +o53: 053 +o56: 056 +o55: 055 +o11: 011 +o400000: 0400000 +o17777: 017777 +o144: 0144 +dm1: -1 +o56012: 056012 +o777: 0777 +o100: 0100 +o43: 043 +o777000: 0777000 +o75: 075 +o167: 0167 +o161: 0161 +"** 08-rest.pdf page 28 +"[handwritten page number top right of scan - 21] +o160: 0160 +o143: 0143 +o141: 0141 +o1777: 01777 +d1024: 1024 +o776000: 0776000 +o162: 0162 +o163: 0163 +o73: 073 +o54: 054 +o17: 017 + +tname: + 0145056;0164155;0160040;040040 +tbufp: tbuf +linep: line +nlistp: nlist +fbufp: fbuf +dskbfp: dskbuf "[line crossed out - scan markup] +edskbfp: dskbuf+1024 "[line crossed out - scan markup] +lnodp: lnodes +linpm1: line-1 +jmpclist: jmp clist +jmpnlist: jmp nlist +jmpxchg: jmp xchg +jms1: jms 1 +tal: .=.+1 +exret: .=.+1 +cloret: .=.+1 +delim: .=.+1 +prev: .=.+1 +compflg: .=.+1 +tal1: .=.+1 +c1: .=.+1 +ital: .=.+1 +otal: .=.+1 +diskin: .=.+1 +glint: .=.+1 +c2: .=.+1 +num: .=.+1 +zermp: .=.+1 +minflg: .=.+1 +adrflg: .=.+1 +dot: .=.+1 +addr: .=.+1 +addr1: .=.+1 +addr2: .=.+1 +eofp: .=.+1 +zerop: .=.+1 +dskadr: .=.+1 +linsiz: .=.+1 +tfi: .=.+1 +fchrno: .=.+1 +lchrno: .=.+1 +lastre: .=.+1 +bett1: .=.+1 +bett2: .=.+1 +wrflg: .=.+1 +apt1: .=.+1 +"[page cuts off one label] +"** 08-rest.pdf page 29 +"[handwritten page number top right of scan - 22] +sfo: .=.+1 +sctal: .=.+1 +sctalp: .=.+1 +char: .=.+1 +fbuf: .=.+4 "not sure if this is fbuf, but +tbuf: .=.+64 "there is a write; tbuf; 64 call +line: .=.+64 +nlist: .=.+50 +"??? ?list: .=.+50, unable to determine label +compbuf: .=.+100 +dskbuf: .=.+1 "[line crossed out - scan markup] +lnodes: .=.+1000 diff --git a/scans/ind.b b/scans/ind.b new file mode 100644 index 0000000..151be09 --- /dev/null +++ b/scans/ind.b @@ -0,0 +1,26 @@ +main $( + extrn read, write; + auto i, c, state, line 100; + +loop: + state = i = 0; +loop1: + c = read(); + if(c==4) return; + if(c==';' & state==0) state = 2; + if((c<'0' ^ c>'9'&c<'a' ^ c>'z') & state==0) state = 1; + line[i] = c; + i = i+1; + if(c!=012) goto loop1; + if(state==2 ^ i==1) goto noi; + write(' '); + write(' '); +noi: + i = 0; +loop3: + c = line[i]; + write(c); + i = i+1; + if(c!=012) goto loop3; + goto loop; +$) diff --git a/scans/lease.b b/scans/lease.b new file mode 100644 index 0000000..df6c6df --- /dev/null +++ b/scans/lease.b @@ -0,0 +1,20 @@ +main $( + auto ch; + extrn read, write; + + goto loop; + while (ch != 04) + $( if (ch > 0100 & ch < 0133) + ch = ch + 040; + if (ch==015) goto loop; + if (ch==014) goto loop; + if (ch==011) + $( ch = 040040; + write(040040); + write(040040); + $) + write(ch); + loop: + ch = read()&0177; + $) + $) \ No newline at end of file diff --git a/scans/maksys.s b/scans/maksys.s new file mode 100644 index 0000000..e04585a --- /dev/null +++ b/scans/maksys.s @@ -0,0 +1,52 @@ +"** 01-s1.pdf page 64 -- handwritten maksys +" copy a.out to disk track 18x +" where x is the argument + + lac 017777 i; sad d8; skp; jmp error + lac 017777; tad d5; dac track + lac i track; lrss 9; tad om60 + spa; jmp error; dac track + tad dm10; sma; jmp error + + sysopen; a.out; 0 + spa; jmp error + sys read; bufp; buf; 3072 + sad .-1 + jmp error + + dscs + -3072; dslw + lac bufp; dslm + lac track; alss 8; xor o300000; dsld + lac o30000; dsls + dssf; jmp .-1 + dsrs; spa; jmp error + -1024; dslw + lac d3072; dslm + lac track; alss 8; xor o300110; dsld + lac o3000; dsls + dssf; jmp .-1 + dsrs; spa; jmp error + sys exit + +error: + lac d1; sys write; 1f; 2 + sys exit +1: 077077;012 + +dm10: -10 +dm5: 5 +om60: -060 +o300000: 0300000 +o300100: 0300110 +d8: 8 +d3072: 3072 +o3000: 03000 +d1: 1 +a.out: + ;; ttyd1 + "** written: ttyrestart -> ttyres1 +cnop: + nop + -1 + dac 7 + clon + lac ttydelay + spa + isz ttydelay + skp + jms ttyrestart + lac .dspb "** START CROSSED OUT: written: lac tty + sna + jmp piret + isz .dsptm + skp + jmp dsprestart + sad d3 + jmp piret + isz .dspb + jmp piret + jmp dsprestart "** END CROSSED OUT + +1: dssf + jmp 1f + + -1 + dac .dskb + +"** 01-s1.pdf page 42 + + dsrs + dac .dske + dscs + jmp piret + +1: lds "** BEGIN CROSSED OUT + sma ral + jmp 1f + cdf + lac .dspb + sna + jmp piret + tad dm3 + sna + jmp dsprestart + dac .dspb + jmp piret +dsprestart: + lac d1 + dac .dspb + lac dspbufp + beg "** ??? + -10 + dac .dsptm + jmp piret + +1: sna ral + jmp .+3 + racf + jmp piret + sma + jmp 1f + lda + dac .lpba + rlpd + jmp piret + +1: ksf + jmp 1f + + lac ttydelay + sma + isz ttydelay + krb + dac char + sad o375 + jmp intrp1 + lac d1 + jms putchar + dzm char + lac sfiles+0 + jms wakeup + dac sfiles+0 + lac char + sad o212 + skp + jmp piret + lac sfiles+1 + sma + xor o400000 + dac sfiles+1 + +"** 01-s1.pdf page 43 + + jms putcr + jms ttyrestart + jmp piret + +1: tsf + jmp 1f + + tcf + jms ttyrestart + jmp piret + +ttyrestart: 0 + lac ttydelay + spa + jmp ttyrestart i + lac nttychar + dzm nttychar + sza + jmp 3f + isz ttydelay + lac d2 + jms getchar + jmp 2f +3: + tls + sad o12 + jms putcr + sad o15 + skp + jmp ttyrestart i + lac ttydelay + tad o20 + rcr + cma + dac ttydelay + jmp ttyrestart i +2: + lac sfiles+1 + jms wakeup + dac sfiles+1 + jmp ttyrestart i "** written arrow up 2 copies + +1: sck "** BEGIN CROSSED OUT + jmp 1f + + cck + lck + dac char + sad o33 + jmp intrp2 + lac d3 + jms putchar + nop + lac sfiles+2 + jms wakeup + dac sfiles+2 + jmp piret + +1: rsf + jmp 1f + + +"** 01-s1.pdf page 44 + + lac npptchar + sna + jmp .+5 + dac char + rrb + dac npptchar + jmp .+3 + rrb + dac char +3: + lac char + sna + jmp 2f + lac d4 + jms putchar + jmp 3f + lac char + sad d4 + jmp 4f +2: + lac npptchar + sna + jmp .+4 + dac char + dzm npptchar + jmp 3b + rsa + lac sfiles+3 + jms wakeup + xor o400000 + dac sfiles+3 + jmp piret +3: + lac char + dac npptchar +4: + lac sfiles+3 + jms wakeup + dac sfiles+3 + jmp piret + +1: psf + jmp 1f + + pcf + lac d5 + jms getchar + jmp .+3 + psa + jmp piret + lac sfiles+4 + jms wakeup + dac sfiles+4 + jmp piret + +1: spb "** BEGIN CROSSED OUT + jmp 1f + + cpb + lpb + dac pbsflgs+1 + +"** 01-s1.pdf page 45 + + and o2000 + sna + jmp piret + jms dspinit + lac sfiles+6 + jms wakeup + dac sfiles+6 + cla + wbl + jmp piret "** END CROSSED OUT + +1: crsf + jmp 1f + + crrb + dac crchar + -1 + dac crread + jmp piret + +1: crrb + +piret: + lac 0 + ral + lac .ac + ion + jmp 0 i + +wakeup: 0 + dac 9f+t + -mnproc + dac 9f+t+1 + lac tadu + dac 2f + lac dacu + dac 2f+1 +1: + lac 9f+t + ral + dac 9f+t + sma + jmp 2f+2 + lac o700000 +2: tad .. + dac .. + lac 2b + tad d4 + dac 2b + lac 2b+1 + tad d4 + dac 2b+1 + isz 9f+t+1 + jmp 1b + cla + jmp wakeup i + +t = t+2 + +putcr: 0 + lac o15 + dac nttychar + +"** 01-s1.pdf page 46 + + cla + jmp putcr i + +intrp1: + lac d5 + dac .int1 + lac d1 + jms getchar + skp + jmp .-3 + lac d2 + jms getchar + skp + jmp .-3 + lac sfiles+0 + jms wakeup + dac sfiles+0 + lac sfiles+1 + jms wakeup + dac sfiles+1 + jms chkint + jmp piret + jmp 1f +intrp2: + lac d7 + dac .int2 + lac d3 + jms getchar + skp + jmp .-3 + lac sfiles+2 + jms wakeup + dac sfiles+2 + lac sfiles+6 + jms wakeup + dac sfiles+6 + jms chkint + jmp piret +1: + lac 0 + dac 020 + lac .ac + jmp 021 diff --git a/scans/s8.s b/scans/s8.s new file mode 100644 index 0000000..88ad5f4 --- /dev/null +++ b/scans/s8.s @@ -0,0 +1,213 @@ +"** 01-s1.pdf page 48 + +" s8 + +" manifests +mnproc = 10 +dspbsz = 270 +ndskbs = 4 + +" flags +.insys: 0 +.int1: 0 +.int2: 0 +.ac: 0 +.savblk: 0 +.dsptm: 0 +.dskb: 0 +.dske: 0 + +" pointers +tadu: tad ulist +dacu: dac ulist +maxquant: 30 +ofilesp: u.ofiles +idskpp: i.dskps +dskbufp: dskbuf +edspbuf: dspbuf+dspbsz +fblksp: s.fblks +dacq1: dac q1 +lacq1: lac q1 +q2p: q2 + +" strings +initf: + n;t;< > ;< > " + +" constants +d0: 0 +d1: 1 +d2: 2 +d3: 3 +d4: 4 +d5: 5 +d6: 6 +d7: o7: 07 +d8: 8 +d9: 9 +o12: d10: 10 +o14: 014 +o15: 015 +o17: 017 +o20: 020 +o33: 033 +o40: 040 +o55: 055 +o77: 077 +d65:o101: 0101 +d33: 33 +o132: 0132 +o134: 0134 +o137: 0137 +o155: 0155 +o177: 0177 +"** 01-s1.pdf page 49 +o212: 0212 +o375: 0375 +o777: 0777 +o2000: 02000 +o4000: 04000 +d7999: 7999 +o10000: 010000 +o17762: 017762 +o17777: 017777 +o20001: 020001 +o40000: 040000 +o40001: 040001 +o70000: 070000 +o77777: 077777 +o100000: 0100000 +o140000: 0140000 +o200000: 0200000 +o200001: 0200001 +o300000: 0300000 +o400000: 0400000 +o500000: 0500000 +o577777: 0577777 +o600000: 0600000 +o640000: 0640000 +o700000: 0700000 +o777700: 0777700 +o777760: 0777760 +dm3: -3 +dm1: -1 + +9: .=.+t +c1: .=.+1 +q1: q2;q2+90 + .=.+14 +q2: + .+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0 + .+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0 + .+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0 + .+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0 + .+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0 +dsploc: .=.+1 +dsplno: .=.+1 +dspbuf: + 0065057;0147740;0160000 + .=.+30 +coldentry: + dzm 0100 " not re-entrant + caf + ion + clon + law 3072 + wcga + jms dspinit + law dspbuf + jms movdsp + cla + jms dskio; 06000 + jms copy; dskbuf; sysdata; ulist-sysdata + lac d3 + jms namei; initf + jms halt +"** 01-s1.pdf page 50 + jms iget + cla + jms iread; 4096; 4096 + jmp 4096 + . = dspbuf+dspbsz+3 +dskbuf = 07700 +dskbs: .=.+65+65+65+65 +edskbsp: . +uquant: .=.+1 +dspbufp: .=.+1 +pbsflgs: .=.+2 +mode: .=.+1 +nttychar: .=.+1 +npptchar: .=.+1 +ttydelay: .=.+1 +name: .=.+4 +lnkaddr: .=.+1 +char: .=.+1 +dskaddr: .=.+1 +uniqpid: 1 +lu: .=.+4 +sfiles: .=.+10 +dpdata: + dpstat: .=.+1 + dpread: .=.+1 + dpwrite: .=.+1 + dpchar: .=.+1 +dspdata: + .dspb: .=.+1 + .lpba: .=.+1 "** 4 written on listing +crdata: + crread: .=.+1 + crchar: .=.+1 +sysdata: + s.nxfblk: .=.+1 + s.nfblks: .=.+1 + s.fblks: .=.+10 + s.uniq: .=.+1 + s.tim: .=.+2 +ulist: + 0131000;1;0;0 + 0031040;0;0;0 + 0031100;0;0;0 + 0031140;0;0;0 + 0031200;0;0;0 + 0031240;0;0;0 + 0031300;0;0;0 + 0031340;0;0;0 + 0031400;0;0;0 + 0031440;0;0;0 +userdata: + u.ac: 0 + u.mq: 0 + u.rq: .=.+9 + u.uid: -1 + u.pid: 1 + u.cdir: 3 + u.ulistp: ulist + u.swapret: 0 + u.base: 0 + u.count: 0 +"** 01-s1.pdf page 51 + u.limit: 0 + u.ofiles: .=.+30 + u.dspbuf: 0 + u.intflg: 1 + .=userdata+64 +ii: .=.+1 +inode: + i.flags: .=.+1 + i.dskps: .=.+7 + i.uid: .=.+1 + i.nlks: .=.+1 + i.size: .=.+1 + i.uniq: .=.+1 + .= inode+12 +di: .=.+1 +dnode: + d.i: .=.+1 + d.name: .=.+4 + d.uniq: .=.+1 + . = dnode+8 +fnode: + f.flags: .=.+1 + f.badd: .=.+1 + f.i: 0 + diff --git a/scans/s9.s b/scans/s9.s new file mode 100644 index 0000000..b308170 --- /dev/null +++ b/scans/s9.s @@ -0,0 +1,117 @@ +"** 01-s1.pdf page 53 +" s9 -- cold boot + +. = coldentry+4 + +" zero i-list + + dzm ii + jms copyz; dskbuf; 64 +1: + lac ii + jms dskio; 0700 + isz ii + -710 + tad ii + jmp 1b + +" free rest of disk + +1: + lac ii + jms free + isz ii + -6400 + tad ii + sza + jmp 1b + +" read in tapes + + dzm ii +1: + dzm sum + jms getw " count + sza + jmp .+3 + hlt + jmp 1b " 0 count means pause + dac xx + isz ii + lac ii + jms iget + jms copyz; inode; 12 + jms getw " flags + dac i.flags + -1 + dac i.uid + jms getw " number links + dac i.nlks + -2 + tad xx + dac i.size + lac ii + dac i.uniq + law 4096-1 + dac 8 + -1 + tad i.size + cma + sna + jmp 3f + dac xx + +"** 01-s1.pdf page 54 +2: + jms getw + dac 8 i + isz xx + jmp 2b +3: + lac sum + dac xx + jms getw " checksum + sad xx + skp + jms halt + lac i.size + dac .+4 + cla + jms iwrite; 4096; .. + jms iput + cla + jms dskio + + + +; 07000 "** writing on listing + jmp 1b + +getw: 0 + jms getc + alss 12 + lmq + jms getc + omq + lmq + jms getc + omq + lmq + add sum + dac sum + lacq + jmp getw i + +getc: 0 + iof + rsa + rsf + jmp .-1 + rrb + sna + jmp getc+1 + and o77 + ion + jmp getc i +xx: 0 +sum: 0 diff --git a/scans/sop.s b/scans/sop.s new file mode 100644 index 0000000..22ca2a4 --- /dev/null +++ b/scans/sop.s @@ -0,0 +1,97 @@ +"** 01-s1.pdf page 62 +" sop + +dac = 0040000 +jms = 0100000 +dzm = 0140000 +lac = 0200000 +xor = 0240000 +add = 0300000 +tad = 0340000 +xct = 0400000 +isz = 0440000 +and = 0500000 +sad = 0540000 +jmp = 0600000 +nop = 0740000 +i = 020000 +law = 0760000 +cma = 0740001 +las = 0750004 +ral = 0740010 +rar = 0740020 +hlt = 0740040 +sma = 0740100 +sza = 0740200 +snl = 0740400 +skp = 0741000 +sna = 0741200 +szl = 0741400 +rtl = 0742010 +rtr = 0742020 +cil = 0744000 +rcl = 0744010 +rcr = 0744020 +cia = 0750000 +lrs = 0640500 +lrss = 0660500 +lls = 0640600 +llss = 0660600 +als = 0640700 +alss = 0660700 +mul = 0653323 +idiv = 0653323 +lacq = 0641002 +clq = 0650000 +omq = 0650002 +cmq = 0650004 +lmq = 0652000 + +dscs = 0707141 +dslw = 0707124 +dslm = 0707142 +dsld = 0707104 +dsls = 0707144 +dssf = 0707121 +dsrs = 0707132 + +iof = 0700002 +ion = 0700042 +caf = 0703302 +clon = 0700044 +clsf = 0700001 + +"** 01-s1.pdf page 63 +clof = 0700004 +ksf = 0700301 +krb = 0700312 +tsf = 0700401 +tcf = 0700402 +tls = 0700406 +sck = 0704301 +cck = 0704304 +lck = 0704312 +rsf = 0700101 +rsa = 0700104 +rrb = 0700112 +psf = 0700201 +pcf = 0700202 +psa = 0700204 +cdf = 0700501 +lds = 0701052 +lda = 0701012 +wcga = 0704206 +raef = 0700742 +rlpd = 0700723 +beg = 0700547 +spb = 0704401 +cpb = 0704404 +lpb = 0704412 +wbl = 0704424 +dprs = 0704752 +dpsf = 0704741 +dpcf = 0704761 +dprc = 0704712 +crsf = 0706701 +crrb = 0706712 + diff --git a/scans/sx.s b/scans/sx.s new file mode 100644 index 0000000..6b08758 --- /dev/null +++ b/scans/sx.s @@ -0,0 +1,4 @@ +" For now, this stuff is defined so that +" the assembler doesn't complain about it + +o7000: 07000 diff --git a/scans/trysys.s b/scans/trysys.s new file mode 100644 index 0000000..db45d59 --- /dev/null +++ b/scans/trysys.s @@ -0,0 +1,40 @@ +"** 01-s1.pdf page 65 +" trysys + + sys open; a.out; 0 + spa + jmp error + sys read; buf; 3072 + sad .-1 + jmp error + iof + caf + cdf + clof + law buf + dac t1 + dzm t2 + -3072 + dac c1 +1: + lac t1 i + dac r2 i + isz t1 + isz r2 + isz c1 + jmp 1b + jmp 0100 + +error: + lac d1 + sys write; 1f; 1 + sys exit +1: 077012 + +a.out: + ; 0 ) && ( $ARGV[0] eq "-d" ) ) { } # Check the arguments -die("Usage: $0 [-d] a.outfile\n") if ( @ARGV != 1 ); +die("Usage: $0 [-d] a.outfile [arg1 arg2 ...]\n") if ( @ARGV < 1 ); # Load the a.out file into memory # and simulate it -load_code( $ARGV[0] ); +load_code( shift(@ARGV) ); +set_arguments(@ARGV); +#dump_memory(); +#exit(0); simulate(); exit(0); @@ -47,6 +50,7 @@ sub load_code { # Set up two file open filehandles $FD[0] = \*STDIN; $FD[1] = \*STDOUT; + $FD[8] = \*STDERR; # According to cat.s (uses d8 == 8) # Open up the file open( my $IN, "<", $filename ) || die("Unable to open $filename: $!\n"); @@ -67,6 +71,62 @@ sub load_code { close($IN); } +### Copy the arguments into the PDP-7 memory space, and build +### an array of pointers to these arguments. Build a pointer +### at 017777 that points at the array. +### +### At the moment, this is NOT what PDP-7 Unix uses, but it's +### a start and it will help us to grok the real thing. +### +### For now, assume abc, def and ghi are stored in memory. +### The layout of the pointers and strings would be: +### +### +-------+ +### | | +### | +-----|---------+ +### | | | | +### | | +---|---------|---------+ +### | | | | | | +### | | | V V V +### |o|o|o|0|||| \&dac, oct("020") => \&lac, + oct("034") => \&tad, + oct("060") => \&jmp, oct("070") => \&iot, oct("074") => \&special, ); @@ -86,18 +148,19 @@ sub simulate { my $opcode = ( $instruction >> 12 ) & 074; my $indirect = ( $instruction >> 13 ) & 1; my $addr = $instruction & 017777; - #printf( "PC %06o: instruction %08o, op %03o, ind %o, addr %06o\n", - # $PC, $instruction, $opcode, $indirect, $addr ) - # if ($debug); + + # Work out what any indirect address would be + my $indaddr= ($indirect) ? $Mem[$addr] & 017777 : $addr; + dprintf( "PC %06o: instr %06o, op %03o, ind %o, addr %06o ind %06o\n", + $PC, $instruction, $opcode, $indirect, $addr, $indaddr ); # Simulate the instruction. Each subroutine updates the $PC if ( defined( $Oplist{$opcode} ) ) { - $Oplist{$opcode}->( $instruction, $indirect, $addr ); - } - else { - printf( "Unknown instruction 0%o at location 0%o\n", + $Oplist{$opcode}->( $instruction, $addr, $indaddr ); + } else { + printf( STDERR "Unknown instruction 0%o at location 0%o\n", $instruction, $PC ); - die("\n"); + exit(1); } } } @@ -105,34 +168,44 @@ sub simulate { # Debug code: dump memory contents sub dump_memory { foreach my $i ( 0 .. 017777 ) { - printf( "%06o: %08o\n", $i, $Mem[$i] ) if ( $Mem[$i] != 0 ); + printf( STDERR "%06o: %06o\n", $i, $Mem[$i] ) if ( $Mem[$i] != 0 ); } } # Load AC sub lac { - my ( $instruction, $indirect, $addr ) = @_; - printf( "PC %06o: lac %05o (value %08o) into AC\n", - $PC, $addr, $Mem[$addr] ) - if ($debug); - $AC = ($indirect) ? $Mem[ $Mem[$addr] & 017777 ]: $Mem[$addr]; + my ( $instruction, $addr, $indaddr ) = @_; + dprintf( "PC %06o: lac %05o (value %06o) into AC\n", + $PC, $indaddr, $Mem[$indaddr] ); + $AC = $Mem[$indaddr]; $PC++; } # Deposit AC sub dac { - my ( $instruction, $indirect, $addr ) = @_; - printf( "PC %06o: dac AC (value %08o) into %05o into AC\n", - $PC, $AC, $addr ) - if ($debug); - if ($indirect) { - $Mem[ $Mem[$addr] & 017777 ] = $PC; - } else { - $Mem[$addr] = $AC; - } + my ( $instruction, $addr, $indaddr ) = @_; + dprintf( "PC %06o: dac AC (value %06o) into %05o\n", + $PC, $AC, $indaddr ); + $Mem[$indaddr] = $AC; $PC++; } +# Add to AC +sub tad { + my ( $instruction, $addr, $indaddr ) = @_; + dprintf( "PC %06o: tac AC (value %06o) from addr %05o\n", + $PC, $AC, $indaddr ); + $AC+= $Mem[$indaddr]; + $PC++; +} + +# Jump +sub jmp { + my ( $instruction, $addr, $indaddr ) = @_; + dprintf( "PC %06o: jmp %06o\n", $PC, $indaddr ); + $PC = $indaddr; +} + # Special instructions sub special { my $instruction = shift; @@ -140,15 +213,33 @@ sub special { # Deal with each one in turn # hlt if ( $instruction == 0740040 ) { - printf( "PC %06o: program halted\n", $PC ); + printf( STDERR "PC %06o: program halted\n", $PC ); dump_memory() if ($debug); exit(1); } + if ( $instruction == 0741100 ) { # spa: skip on positive AC + dprintf( "PC %06o: spa AC %06o\n", $PC, $AC ); + # Because we are dealing with 18 bits, compare the range + $PC += ( ($AC >= 0) && ($AC < 0400000) ) ? 2 : 1; + return; + } + if ( $instruction == 0741200 ) { # sna: skip on non-zero AC + dprintf( "PC %06o: sna AC %06o\n", $PC, $AC ); + $PC += ( $AC != 0 ) ? 2 : 1; + return; + } + if ( $instruction == 0740200 ) { # sza: skip on zero AC + dprintf( "PC %06o: sza AC %06o\n", $PC, $AC ); + $PC += ( $AC == 0 ) ? 2 : 1; + return; + } + printf( STDERR "PC %06o: unknown instruction %06o\n", $PC, $instruction ); + exit(1); } # I/O transfer: used for system calls sub iot { - my ( $instruction, $indirect, $addr ) = @_; + my ( $instruction, $addr, $indaddr ) = @_; # Syscalls that we can simulate my %Syscallist = ( @@ -163,190 +254,236 @@ sub iot { if ( defined( $Syscallist{$addr} ) ) { $Syscallist{$addr}->(); } else { - printf( "PC %06o: Unknown syscall %d\n", $PC, $addr ); - die("\n"); + printf( STDERR "PC %06o: Unknown syscall %d\n", $PC, $addr ); + exit(1); } } # Exit system call sub sys_exit { - printf("PC %06o: exit system call\n", $PC) if ($debug); - exit(0); + dprintf( "PC %06o: exit system call\n", $PC ); + exit(0); } # Close system call sub sys_close { - # AC is the file descriptor - my $fd= $AC; - printf("PC %06o: close: closing fd %d\n", $PC, $fd) if ($debug); - # Bump up the PC - $PC += 1; + # AC is the file descriptor + my $fd = $AC; + dprintf( "PC %06o: close: closing fd %d\n", $PC, $fd ); - # That filehandle is not open, set an error -1 in octal - if (!defined($FD[$fd])) { - print("close: fd $fd is not open\n") if ($debug); - $AC= 0777777; return; - } - close($FD[$fd]); - $FD[$fd]= undef; - $AC=0; return; + # Bump up the PC + $PC += 1; + + # That filehandle is not open, set an error -1 in octal + if ( !defined( $FD[$fd] ) ) { + dprint( "close: fd $fd is not open\n"); + $AC = 0777777; + return; + } + close( $FD[$fd] ); + $FD[$fd] = undef; + $AC = 0; + return; } # Open system call sub sys_open { - # Open seems to have arguments: PC+1 has a pointer to the filename, - # PC+2 and PC+3 I don't know yet, probably read/write and mask? - # AC is the opened fd on success, or -1 on error - # Get the start address of the string - my $start= $Mem[$PC+1]; + # Open seems to have arguments: PC+1 has a pointer to the filename, + # PC+2 and PC+3 I don't know yet, probably read/write and mask? + # AC is the opened fd on success, or -1 on error - # Bump up the PC - $PC += 4; + # Get the start address of the string + my $start = $Mem[ $PC + 1 ]; - # Convert this to a sensible ASCII filename - my $filename= mem2string($start); - printf("PC %06o: open: file %s\n", $PC, $filename) if ($debug); + # Bump up the PC + $PC += 4; - # Open the file - if (open(my $FH, "<", $filename)) { - # Find a place in the @FD array to store this filehandle. 99 is arbitrary - my $fd; - foreach $fd (0 .. 99) { - if (!defined($FD[$fd])) { - $FD[$fd]= $FH; last; - } + # Convert this to a sensible ASCII filename + my $filename = mem2string($start); + dprintf( "PC %06o: open: file %s\n", $PC, $filename ); + + # Open the file + if ( open( my $FH, "<", $filename ) ) { + + # Find a place in the @FD array to store this filehandle. 99 is arbitrary + foreach my $fd ( 0 .. 99 ) { + if ( !defined( $FD[$fd] ) ) { + $FD[$fd] = $FH; + $AC = $fd; + last; + } + } + return; + } else { + # No filehandle, so it's an error + dprintf( "open failed: $!\n"); + $AC = 0777777; + return; } - $AC=$fd; return; - } else { - # No filehandle, so it's an error - print("open failed: $!\n") if ($debug); - $AC= 0777777; return; - } } # Read system call sub sys_read { - # Read seems to have arguments: AC is the file descriptor, PC+1 is - # the pointer to the buffer and PC+2 is the number of words to read. - # Return the number of words read in AC on success, or -1 on error. - # Get the file descriptor, start address and end address - my $fd= $AC; - my $start= $Mem[$PC+1]; - my $count= $Mem[$PC+2]; - my $end= $start + $count -1; - printf("PC %06o: read: %d words from %o from fd %d\n", $PC, $count, $start, $fd) if ($debug); + # Read seems to have arguments: AC is the file descriptor, PC+1 is + # the pointer to the buffer and PC+2 is the number of words to read. + # Return the number of words read in AC on success, or -1 on error. - # Bump up the PC - $PC += 3; + # Get the file descriptor, start address and end address + my $fd = $AC; + my $start = $Mem[ $PC + 1 ]; + my $count = $Mem[ $PC + 2 ]; + my $end = ($start + $count - 1) & 017777; + die("sys_read: bad start/end addresses $start $end\n") if ($end < $start); + dprintf( "PC %06o: read: %d words into %o from fd %d\n", + $PC, $count, $start, $fd ); - # That filehandle is not open, set an error -1 in octal - if (!defined($FD[$fd])) { - print("read: fd $fd is not open\n") if ($debug); - $AC= 0777777; return; - } + # Bump up the PC + $PC += 3; - # Read each word in - my $FH= $FD[$fd]; - $count=0; - foreach my $addr ($start .. $end) { - # It's a terminal, so convert from ASCII - if (-t $FH) { - my $c1= getc($FH); - last if (!defined($c1)); # No character, leave the loop - my $c2= getc($FH) || ""; # No character, make it a NUL - $Mem[$addr]= (ord($c1) << 9) | ord($c2); # Pack both into one word - $count++; - } else { - # otherwise (for now) read in one line and convert to octal - my $line= <$FH>; - chomp($line); - last if (!defined($line)); # No line, leave the loop - $Mem[$addr]= oct($line) & 0777777; - $count++; + # That filehandle is not open, set an error -1 in octal + if ( !defined( $FD[$fd] ) ) { + dprint( "read: fd $fd is not open\n"); + $AC = 0777777; + return; } - } - # No error - $AC= $count; return; + + # Read each word in + my $FH = $FD[$fd]; + $count = 0; + foreach my $addr ( $start .. $end ) { + + # It's a terminal, so convert from ASCII + if ( -t $FH ) { + my $c1 = getc($FH); + last if ( !defined($c1) ); # No character, leave the loop + my $c2 = getc($FH) || ""; # No character, make it a NUL + $Mem[$addr] = + ( ord($c1) << 9 ) | ord($c2); # Pack both into one word + $count++; + } else { + # otherwise (for now) read in one line and convert to octal + my $line = <$FH>; + last if ( !defined($line) ); # No line, leave the loop + chomp($line); + $Mem[$addr] = oct($line) & 0777777; + $count++; + } + } + + # No error + $AC = $count; + return; } # Write system call sub sys_write { - # Write seems to have arguments: AC is the file descriptor, PC+1 is - # the pointer to the buffer and PC+2 is the number of words to write + # Write seems to have arguments: AC is the file descriptor, PC+1 is + # the pointer to the buffer and PC+2 is the number of words to write - # Get the file descriptor, start address and end address - my $fd= $AC; - my $start= $Mem[$PC+1]; - my $count= $Mem[$PC+2]; - my $end= $start + $count -1; - printf("PC %06o: write: %d words from %o to fd %d\n", $PC, $count, $start, $fd) if ($debug); + # Get the file descriptor, start address and end address + my $fd = $AC; + my $start = $Mem[ $PC + 1 ]; + my $count = $Mem[ $PC + 2 ]; + my $end = ($start + $count - 1) & 017777; + die("sys_write: bad start/end addresses $start $end\n") if ($end < $start); + dprintf( "PC %06o: write: %d words from %o to fd %d\n", + $PC, $count, $start, $fd ); - # Bump up the PC - $PC += 3; + # Bump up the PC + $PC += 3; - # That filehandle is not open, set an error -1 in octal - if (!defined($FD[$fd])) { - print("write: fd $fd is not open\n") if ($debug); - $AC= 0777777; return; - } - - # Write each word out - my $FH= $FD[$fd]; - foreach my $addr ($start .. $end) { - # It's a terminal, so convert to ASCII - # otherwise (for now) print in octal - if (-t $FH) { - print($FH word2ascii($Mem[$addr])); - } else { - printf($FH "%06o\n", $Mem[$addr]); + # That filehandle is not open, set an error -1 in octal + if ( !defined( $FD[$fd] ) ) { + dprint( "write: fd $fd is not open\n"); + $AC = 0777777; + return; } - } - # No error - $AC= 0; return; + + # Write each word out + my $FH = $FD[$fd]; + foreach my $addr ( $start .. $end ) { + + # It's a terminal, so convert to ASCII + # otherwise (for now) print in octal + if ( -t $FH ) { + print( $FH word2ascii( $Mem[$addr] ) ); + } else { + printf( $FH "%06o\n", $Mem[$addr] ); + } + } + + # No error + $AC = 0; + return; } # Convert an 18-bit word into two ASCII characters and return them. # Don't return NUL characters sub word2ascii { - my $word= shift; - my $c1= ($word >> 9) & 0177; - my $c2= $word & 0177; - my $result= ""; - $result .= chr($c1) if ($c1); - $result .= chr($c2) if ($c2); - return($result); + my $word = shift; + my $c1 = ( $word >> 9 ) & 0177; + my $c2 = $word & 0177; + my $result = ""; + $result .= chr($c1) if ($c1); + $result .= chr($c2) if ($c2); + return ($result); } # Given the address of a word in memory, interpret that location # and those following as a NUL-terminated ASCII string and return # a copy of this string sub mem2string { - my $addr= shift; - my $result= ""; + my $addr = shift; + my $result = ""; - while (1) { - # Stop when the address leave the 8K word address space - return($result) if ($addr > 017777); + while (1) { - # Stop when the value there is zero - my $word= $Mem[$addr]; - return($result) if ($word==0); + # Stop when the address leave the 8K word address space + return ($result) if ( $addr > 017777 ); - # Get the top ASCII character, return if NUL - my $c1= ($word >> 9) & 0177; - return($result) if ($c1==0); - $result .= chr($c1); + # Stop when the value there is zero + my $word = $Mem[$addr]; + return ($result) if ( $word == 0 ); - # Get the bottom ASCII character, return if NUL - my $c2= $word & 0177; - return($result) if ($c2==0); - $result .= chr($c2); + # Get the top ASCII character, return if NUL + my $c1 = ( $word >> 9 ) & 0177; + return ($result) if ( $c1 == 0 ); + $result .= chr($c1); - # Move up to the next address - $addr++; - } + # Get the bottom ASCII character, return if NUL + my $c2 = $word & 0177; + return ($result) if ( $c2 == 0 ); + $result .= chr($c2); + + # Move up to the next address + $addr++; + } +} + +# Given a string and the address of a word in memory, copy +# the string into memory starting at that address and NUL +# terminate the string. Return the first address after the string. +# +# We will go off the end of the string: suppress warnings +no warnings ('substr'); +sub string2mem { + my ($str, $base)= @_; + + # <= length so we go off the end and insert a NUL + for (my $i=0; $i <= length($str); $i += 2) { + my $c1= substr($str, $i, 1) || ""; + my $c2= substr($str, $i+1, 1) || ""; + #printf("Saving %06o to %05o\n", (ord($c1) << 9 ) | ord($c2), $base); + $Mem[$base++]= (ord($c1) << 9 ) | ord($c2); + } + return($base); +} + +# Print out debug messages +sub dprintf { + printf( STDERR @_) if ($debug); } diff --git a/tools/as7 b/tools/as7 index 1d235b0..433cfd2 100755 --- a/tools/as7 +++ b/tools/as7 @@ -21,6 +21,8 @@ my $origline; # The current input line of code my $stage = 1; # Pass one or pass two my $debug = 0; # Run in debug mode +my $errors = 0; # set to non-zero on error +my %Undef; # undefined symbols: only complain once ### Main program ### @@ -87,13 +89,25 @@ for my $i ( 0 .. $#Mem ) { } } -exit(0); +exit($errors); + +my $file; # global for error messages +my $lineno; + +sub err { + my $msg = shift; + $errors = 1; # exit status + print STDERR "$file:$lineno: $msg\n"; + return 0; +} # Open and parse the given file sub parse_file { - my $file = shift; + $file = shift; open( my $IN, "<", $file ) || die("Cannot read $file: $!\n"); + $lineno = 0; while ( my $line = <$IN> ) { + $lineno++; # Lose the end of line and any leading/trailing whitespace # Discard any comments and preceding comment whitespace @@ -116,7 +130,7 @@ sub parse_file { my $labelsect = $1; my $statement = $2; - #print(">$labelsect< >$statement<\n"); + #print(">$labelsect< >$statement<\n"); # Split $labelsect into labels using the : character my @labellist = split( /:\s*/, $labelsect ); @@ -147,9 +161,9 @@ sub parse_label { } # It's a textual label, check if it's been defined before - die("Label $label defined multiple times\n") - if ( defined( $Label{$label} ) ); - + if ( defined( $Label{$label} ) ) { + err("Label $label defined multiple times\n") if ( $stage == 1 ); + } # Otherwise, save its value $Label{$label} = $Var{'.'}; #printf( "Set absolute label %s to 0%o\n", $label, $Label{$label} ); @@ -426,7 +440,11 @@ sub parse_expression { #print("Did a subtraction and got $diff\n"); return ($diff); } - die("I have no idea what $expression is in pass two\n") if ( $stage == 2 ); + if ( $stage == 2 ) { + err("undefined: $expression") unless (defined $Undef{$expression}); + $Undef{$expression} = 1; + } + return 0; } # Add two expression together @@ -463,18 +481,20 @@ sub find_relative_label { my $curlocation = $Var{'.'}; # Error check: no labels at all - die("No relative labels\n") if ( !defined( $Rlabel{$label} ) ); + if ( !defined( $Rlabel{$label} ) ) { + return err("relative label $label not defined\n"); + } # Get the list of possible locations for this label my $locarray = $Rlabel{$label}; # Error check: no locations - die("No relative labels\n") if ( @{$locarray} == 0 ); + return err("No relative labels") if ( @{$locarray} == 0 ); # Error check: forward but no next location, or backward but no previous - die("No forward label\n") + return err("No forward label $label") if ( ( $direction eq 'f' ) && ( $curlocation > $locarray->[-1] ) ); - die("No backward label\n") + return err("No backward label $label") if ( ( $direction eq 'b' ) && ( $curlocation < $locarray->[0] ) ); # Search forward for a location larger then the current one diff --git a/tools/wktcat.s b/tools/wktcat.s new file mode 100644 index 0000000..ef11a35 --- /dev/null +++ b/tools/wktcat.s @@ -0,0 +1,123 @@ +" Warren's cat program: cat [arg1 arg2 ...] +" +" Because the a7out simulator currently doesn't deal with ASCII files, +" here is how you can test it: +" ./as7 wktcat.s > a.out +" +" ./a7out a.out > z1 +" +" +" ./a7out a.out z1 z1 +" +" +" Also, the current coding is hideous and needs refactoring. +" I'm still coming to grips with PDP-7 assembly code. + + +main: + " Load the pointer pointer in 017777 to see if we have any arguments + lac 017777 i + sza " No args, so copy stdin to stdout + jmp catfiles " Yes args, so deal with them below + +" This section copies from standard input to standard output +stdinout: + " Read five words into the buffer from stdin + " Five was chosen arbitrarily + lac d0 + sys read; buf; 5 + spa " Skip if result was >= 0 + jmp error " Result was -ve, so error result + sna " Skip if result was >0 + jmp end " Result was zero, so nothing left to read + + " Save the count of words read in + dac 1f + + " Write five words from the buffer to stdout + lac d1 + sys write; buf; 1:0 + + " and loop back for more words to read + jmp stdinout + +" This section opens files, and copies their contents to standard output +catfiles: + " We start with AC pointing to an argument. Save it at label 1f + dac name + + " Open the file and get the fd into AC + sys open; name:0; 0; 0 + spa + jmp badfile " Bad fd, exit with an error message + dac fd " Save the file descriptor + +fileloop: + " Read five words into the buffer from the input file + lac fd + sys read; buf; 5 + spa " Skip if result was >= 0 + jmp error " Result was -ve, so error result + sna " Skip if result was >0 + jmp fileend " Result was zero, so nothing left to read + + " Save the count of words read in + dac 1f + + " Write five words from the buffer to stdout + lac d1 + sys write; buf; 1:0 + + " and loop back for more words to read + jmp fileloop + +fileend: + " Close the open file descriptor + lac fd + sys close + + " Load and increment the 017777 pointer + lac 017777 + tad d1 + dac 017777 + + " Load the pointer pointer in 017777 to see if we have any more arguments + lac 017777 i + sna " No args, so end the program + jmp end + jmp catfiles " Otherwise loop back to cat this file + +end: + " exit + sys exit + + +" This code comes from the real cat.s +badfile: + lac name " Get the pointer to the filename + dac 1f " Store it in 1f below + lac d8 " Load fd 8 which is stderr + sys write; 1:0; 4 " Write the name, max 4 words + lac d8 " Then write " ?\n" + sys write; 1f; 2 + sys exit " and exit + +1: 040; 077012 + + +error: + " Print an "err read" string and exit + lac d1 + sys write; noreadstr; 5 + sys exit + +noreadstr: + ;;;012000 + +fd: 0 " fd of the open file +d0: 0 " Constants 0 and 1 +d1: 1 +d8: 8 " stderr seems to have fd 8 + +" Input buffer for read +buf: 0; 0; 0; 0; 0