From 0b0ea2e637c986fe5888019c2f476a3171f95b7a Mon Sep 17 00:00:00 2001 From: Phil Budne Date: Thu, 25 Feb 2016 18:59:46 -0500 Subject: [PATCH 01/32] typed in files s5-s9 from 01-s1.pdf --- scans/s5.s | 272 +++++++++++++++++++++++++++++++++++++++ scans/s6.s | 341 +++++++++++++++++++++++++++++++++++++++++++++++++ scans/s7.s | 363 +++++++++++++++++++++++++++++++++++++++++++++++++++++ scans/s8.s | 210 +++++++++++++++++++++++++++++++ scans/s9.s | 117 +++++++++++++++++ 5 files changed, 1303 insertions(+) create mode 100644 scans/s5.s create mode 100644 scans/s6.s create mode 100644 scans/s7.s create mode 100644 scans/s8.s create mode 100644 scans/s9.s diff --git a/scans/s5.s b/scans/s5.s new file mode 100644 index 0000000..3baf07f --- /dev/null +++ b/scans/s5.s @@ -0,0 +1,272 @@ +"** 01-s1.pdf page 28 +" s5 + +dskswap: 0 + cli; ais 3 + dac 9f+t + jms dsktrans; -64; userdata; 9f+t; dskswap + lac 0f+t + tad o20 + dac 9f+t + jms dsktrans; -4096; 4096; 9f+t; dekswap + isc dskswap + jmp dskswap + +t = t+1 + +access: 0 + lac i.flags + idunno "** ??? + lac u.uid + spa + jmp access i + sad i.uid + ird 2 + lacq + and mode + sza + jmp access i + jms error + +fassign: 0 + -1 + dac 9f+t +1: + lac 9f+t + tad d10 + jms fget + jms halt " will not happen + lac f.flags + sma + jmp 1f + isz 9f+t + jmp 1b + jmp fassign i +1: + lac mode + xor o400000 + dac f.flags + lac ii + dac f.i + lac 9f+t + tad d10 + dac u.ac + dzm f.badd + jms fput + isz fassign + jmp fassign i +t = t+1 + +fget: 0 + jms betwen; d0; d9 + jmp fget i + cli; mul; 3 + iacq "** ?? +"** 01-s1.pdf page 29 + + tad ofilesp + dac 9f+t + dac .+2 + jms copy; ..; fnode; 3 + isz fget + jmp fget i + +fput: 0 + lac 9f+t + dac .+3 + jms copy; ; fnode; ..; 3 + jmp fput i +t = t+1 + +forall: 0 + lac u.base + sad u.limit + jmp 1f + lac u.base + rai + lac u.base i + sni + lrs 9 + and o777 + jmp forall i +1: + lac u.ount + dac u.ac + jmp sysexit + +sleep: 0 + law ulist-1 + dac 8 + lac o200000 + lmq "** ??? +1: + lac u.ulistp i + sad 8 i + jmp 1f + isz 8 + isz 8 + isz 8 + cla; lrs 1 + jmp 1b +1: + tad o100000 + dac u.ulistp i + lac sleep i + dac 9f+t + lac 9f+t i + isz sleep + jmp sleep i +t = t+1 + +"** 01-s1.pdf page 30 + +dslot: 0 + dzm di + skp +1: + isz di + lac di + jms dget + lac d.i + sza + jmp 1b + jmp dslot i + +icreat: 0 + dac 9f+t + jms dslot + lac o20 + dac ii +1: + isz ii + lac ii + jms iget + lac i.flags + spa + jmp 1b + lac ii + dac d.i + jms copy; name; d.name; 4 + isz s.uniq + lac s.uniq + dac d.uniq + dac i.uniq + lac 9f+t + xor o400000 + dac i.flags + lac u.uid + dac u.uid + -1 + dac i.niks + dzm i.size + jms copyz; i.dskps; 7 + jms iput + jms dput + jmp icreat i +t = t+1 + +dspput: 0 + and o177 + sna + jmp i dspput + sad o14 + jmp 1f + img "** ??? + sad o12 + jmp dspni + lac dsploc i + sad o400000 + jmp dspleft + omq + dac dsploc i + isz dsploc + jmp i dspput + +"** 01-s1.pdf page 31 + +1: + jms dspinit + jmp dspput i + +dspleft: + lac dsploc + sad edspbuf + jmp 1f + dac 8 + lac o400000 + dac 8 i + cla; liss 18+7 + dac dsploc i + jmp dspput i + +dspni: 0 + lac dspino + sad d33 + jmp 1f + isz dspino + jmp dspni i +1: + lac o2000 + wbi + isz dspput + jmp dspput i + +dspinit: 0 + lac dspbuf+3 + dac dsploc + lac o300000 + dac dspbuf+3 + dzm dspino + jmp dspinit i + +movdsp: 0 + iof + cdf + dac dspbufp + -1 + dac .dspb + ion + jmp movdsp i + +arg: 0 + lac u.rq+8 i + isz u.rq+8 + jmp arg i + +argname: 0 + jms arg + dac .+2 + jms copy; ..; name; 4 + lac u.edir + jms namei; name + jms error + jmp argname i + +seektell: 0 + jms arg + dac u.base + +"** 01-s1.pdf page 32 + jms arg + dac u.limit + jms finac + lac u.limit + sna + jmp seektell i + sad d1 + jmp .+3 + lac i.size + jmp seektell i + lac f.badd + jmp seektell i + +isown: 0 + jms argname + jms iget + lac u.uid + sma + sad i.uid + skp + jms error + jmp isown i + diff --git a/scans/s6.s b/scans/s6.s new file mode 100644 index 0000000..9f6559d --- /dev/null +++ b/scans/s6.s @@ -0,0 +1,341 @@ +"** 01-s1.pdf page 34 +" S6 + +itrunc: 0 + -7 + dac 9f+t + lac idskpp + dac 9f+t+1 +1: + lac 9f+t+1 i + sna + jmp 4f + lac i.flags + and o200000 + sna + jmp 3f + -64 + dac 9f+t+2 + lac dskbufp + dac 9f+t+3 +2: + lac 9f+t+1 i + jms dskrd + lac 9f+t+3 i + sza + jms free + isz 9f+t+3 + isz 9f+t+3 + jmp 2b +3: + lac 9f+t+1 i + jms free + dzm 9f+t+1 i +4: + isz 9f+t+1 + isz 9f+t + jmp 1b + lac i.flags + and o577777 + dac i.flacs + jmp itrunc i +t = t+4 + +namei: 0 + jms iget + -1 + tad namei i + dac 9f+t+1 + isz namei + lac i.flags + and o20 + sna + jmp namei i + -8 + tad i.size + cma + irss 3 + dac 9f+t + sna + jmp namei i + dzm di +1: + lac di + +"** 01-s1.pdf page 35 + + jms dget + lac d.i + sna + jmp 2f + lac 9f+t+1 + dac 8 + lac d.name + sad 8 i + skp + jmp 2f + lac d.name+1 + sad 8 i + skp + jmp 2f + lac d.name+2 + sad 8 i + skp + jmp 2f + lac d.i + isz namei + jmp namei 1 +2: + isz di + isz 9f+t + jmp 1b + jmp namei i +t = t+2 + +iget: 0 + dac ii + cli; idiv; 5 + dac 9f+t + tad d2 + dac 9f+i+1 + jms dskrd + lac 9f+t + cli; mul; 12 + lacq + tad dskbufp + dac 9f+t + dac .+2 + jms copy; ..; inode; 12 + jmp iget i + +iput: 0 + lac 9f+t+1 + jms dskrd + law inode-1 + dac 8 + -1 + tad 9f+t + dac 9 + -12 + dac 9f+t+2 +1: + lac 8 i + +"** 01-s1.pdf page 36 + + sad 9 i + skp + jmp 2f + isz 9f+t+2 + jmp 1b + jmp iput i +2: + -1 + tad 8 + dac 8 + -1 + tad 9 + dac 9 +1: + lac 8 i + dac 9 i + isz 9f+t+2 + jmp 1b + lac 9f+t+1 + jms dskwr + jmp iput i +t = t+3 + +dget: 0 + dac di + alss 3 + dac 9f+t + jms pget + fac 9f+t+1 + jms dskrd + lac 9f+t + and o77 + tad dskbufp + dac 9f+t+2 + dac .+2 + jms copy; ..; dnode; 8 + lac 9f+t + tad d8 + jms betwen; d0; i.size + skp + jmp dget i + jms dacisize + dzm d.i + jmp dget i + +dput: 0 + lac 9f+t+1 + jms dskrd + lac 9f+t+2 + dac .+3 + jms copy; dnode; ..; 8 + lac 9f+t+1 + jms dskwr + jmp dput i + +t = t+3 "** first t not there (hole from hole punch?) + +pget: 0 + irss 6 + dac 9f+t + lac i.flags + +"** 01-s1.pdf page 36 + + and o200000 + sza + jmp 2f + lac 9f+t + jms betwen; d0; d6 + jmp 1f + rad idskpp + dac 9f+t + lac 9f+t i + sna + jms alloc + dac 9f+t i + jmp pget i +1: + jms alloc + dac 9f+t+1 + jms copy; idskps; dskbuf; 7 + jms copyz; dskbuf+7; 6467 "** NUMBER UNCLEAR 64-7??? + lac 9f+t+1 + jms dskwr + lac 9f+t+1 + dac i.dskps + jms copyz; i.dskps+1; 6 + lac i.flags + xor o200000 + dac i.flags +2: + lac 9f+t + lrss 7 + jms betwen; d0; d6 + jms halt " file too big + tad idskpp + dac 9f+t+1 + lac 9f+t+1 i + sna + jms alloc + dac 9f+t+1 i + dac 9f+t+2 + jms dskrd + lac 9f+t + and o77 + tad dskbufp + dac 9f+t+1 + lac 9f+t+1 i + sza + jmp pget i + jms alloc + dac 9f+t + lac 9f+t+2 + jms dskrd + lac 9f+t + jmp pget i +t = t+3 + +iwrite: 0 + dac 9f+t + lac iwrite + +"** 01-s1.pdf page 38 + + dac oread + lac cslp + dac iwrite + jmp 1f + +iread: 0 + dac 9f+t + lac cnop + dac iwrite +1: + -1 + tad iread i + dac 10 + dac 11 + isz iread + lac iread i + dac 9f+t+1 + isz iread + lac o70000 + xct iwrite + lac i.size + cma + tad 9f+t + cma + jms betwen; d0; 9f+t+1 + lac 9f+t+1 + dac 9f+t+2 + cma + tad d1 + sna + jmp iread i + dac 9f+t+1 +1: + lac 9f+t + jms pget + das 9f+t+3 + jms dskrd + lac 9f+t + and o77 + tad dskbufp + tad dm1 + xct iwrite + jmp .+3 + dac 10 +cskp: + skp + dac 11 +2: + lac 11 i + dac 10 i + isz 9f+t + isz 9f+t+1 + jmp 3f + xct iwrite + jmp 4f + lac 9f+t + jms betwen; d0; i.size + dac i.size + lac 9f+t+3 + 4: +"** 01-s1.pdf page 38 + lac 9f+t+2 + jmp iread i + +3: + lac 9f+t + and o77 + sza + jmp 2b + xct iwrite + jmp 1b + lac 9f+t+3 + jms dskwr + jmp 1b +t = t+4 + +finac: 0 + lac u.ac + jms fget + jms error + lac f.flags + sma + jms error + lac f.i + jms ihet + jms finac i + +dacisize: 0 + dac i.size + jms iput + lac i.size + jmp dacisize i diff --git a/scans/s7.s b/scans/s7.s new file mode 100644 index 0000000..224f223 --- /dev/null +++ b/scans/s7.s @@ -0,0 +1,363 @@ +"** 01-s1.pdf page 41 +" s7 + +pibreak: + dac .ac "** CROSSED OUT.... + dpsf + jmp 1f + + dpcf + dprs + dac dpstat + sma rad + jmp 2f + dprc + dac dpchar + -1 + dac dpread + lac dpstat + rai +2: + sma + jmp piret + -1 + dac dpwrite + jmp piret "** END OF CROSSOUT + +1: clsf + jmp 1f + + lpb + dac pbsfigs + isz s.tim+1 + skp + isz s.tim + isz uquant + "** written: ttydelay -> 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 ra1 + jmp 1f + cdf + lac .dspb + sna + jmp 1f + cdf + lac .dspb + sna + jmp piret + tad dm3 + sna + jmp dsprestart + dac .dspb + jmp piret + +1: sna ra1 + 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 ptcr + 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 44 + + and o2000 + sna + jmp piret + jms dspinit + lac sfiles+6 + jms wakeup + dac sfiles+6 + cla + wbi + jmp piret "** END CROSSED OUT + +1: crsf + jmp 1f + + crrb + dac crchar + -1 + dac crread + jmp piret + +1: crrb + +piret: + lac 0 + rai + 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 + rao + 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..a26d3e9 --- /dev/null +++ b/scans/s8.s @@ -0,0 +1,210 @@ +"** 01-s1.pdf page 48 + +" s8 + +" manifests +mnproc = 10 +dspbss = 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+dspbzs +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 +o232: 0212 +o375: 0375 +o777: 0777 +o2000: 02000 +o4000: 04000 +d7999: 7999 +o10000: 010000 +o17762: 017762 +o17777: 017777 +o20001: 020001 +o40000: 040000 +o40001: 040001 +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 +dspinc: .=.+1 +dspbuf: + 0065057;0147740;0160000 + .=.+30 +coldentry: + dzm 0100 " not re-entrant + caf + ion + clon + law 3072 + vcga + jsp dspinit + law dspbuf + jsp movdsp + cla + jsp 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 +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: clist + 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.lks: .=.+1 + i.size: .=.+1 + i.uniq: .=.+1 + .= inode+12 +di: .=.+1 + 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..77004b2 --- /dev/null +++ b/scans/s9.s @@ -0,0 +1,117 @@ +"** 01-s1.pdf page 54 +" s9 -- cold boot + +. = coldentry+4 + +" zero i-list + + dzm ii + jms copyz; dskbuf; 64 +1: + iac 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 + iac ii + jms iget + jms copyz; inode; 12 + jms getw " flags + dac i.dlags + -1 + dac i.uid + jms getw " number links + dac i.nlks + -2 + tad xx + dac i.size + lac ii + dac u.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 + iss 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 dksio + + + +; 07000 "** writing on listing + jmp 1b + +getw: 0 + jms getc + alss 12 + imq + jms getc + omg + lmg + jms getc + omg + lmg + 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 From 5616e1b20a34f4cae0e6533016314ed8967baccd Mon Sep 17 00:00:00 2001 From: Will Senn Date: Thu, 25 Feb 2016 18:49:52 -0600 Subject: [PATCH 02/32] cas.s transcribed from 04-cas.txt --- scans/cas.s | 1086 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1086 insertions(+) create mode 100644 scans/cas.s diff --git a/scans/cas.s b/scans/cas.s new file mode 100644 index 0000000..9d55452 --- /dev/null +++ b/scans/cas.s @@ -0,0 +1,1086 @@ +" 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: + 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 + 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 + 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 + 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 + 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 + +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 +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 + + + + + +: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 +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 +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 +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 +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 +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 +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 "??? +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 +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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From f576fb552985e0d328384f8e2832274be1d72590 Mon Sep 17 00:00:00 2001 From: Will Senn Date: Thu, 25 Feb 2016 18:52:02 -0600 Subject: [PATCH 03/32] removed trailing carriage returns, also this was transcribed from 04-cas.pdf, not 04-cas.txt --- scans/cas.s | 43 ------------------------------------------- 1 file changed, 43 deletions(-) diff --git a/scans/cas.s b/scans/cas.s index 9d55452..315c794 100644 --- a/scans/cas.s +++ b/scans/cas.s @@ -1041,46 +1041,3 @@ ka " x " mn " r - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 09f14183078fe233af440c89c456b830ec273ea3 Mon Sep 17 00:00:00 2001 From: rswier Date: Thu, 25 Feb 2016 20:02:37 -0500 Subject: [PATCH 04/32] transcribed from 08-rest.pdf --- scans/ind.b | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 scans/ind.b 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; +$) From 08f0bea8d09b6a5bf7a7a756c2f637a6eeb75fc2 Mon Sep 17 00:00:00 2001 From: rswier Date: Thu, 25 Feb 2016 20:06:07 -0500 Subject: [PATCH 05/32] transcribed from 08-rest.pdf --- scans/lease.b | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 scans/lease.b 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 From e5d2831b3334ca7fa6a4cb0cfcf6a5131ab56e40 Mon Sep 17 00:00:00 2001 From: rswier Date: Thu, 25 Feb 2016 20:10:20 -0500 Subject: [PATCH 06/32] transcribed from 06-5-12.pdf --- scans/bl.s | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 scans/bl.s 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 From d213ce5727b4d9213f948018f955eaa13b53aa3e Mon Sep 17 00:00:00 2001 From: rswier Date: Thu, 25 Feb 2016 20:13:43 -0500 Subject: [PATCH 07/32] transcribed from 06-5-12.pdf --- scans/bc.s | 288 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 scans/bc.s 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 From cc79da86a56d8072c4bb7fd2e4c4284465546fcf Mon Sep 17 00:00:00 2001 From: rswier Date: Thu, 25 Feb 2016 20:16:59 -0500 Subject: [PATCH 08/32] transcribed from 06-5-12.pdf --- scans/bi.s | 433 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 433 insertions(+) create mode 100644 scans/bi.s 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 From 2cca3d44739e88e39e81238a88d8dad616ed0cf4 Mon Sep 17 00:00:00 2001 From: Phil Budne Date: Thu, 25 Feb 2016 20:58:17 -0500 Subject: [PATCH 09/32] finish s1.s; tried to clean up s5-s8; let as7 continue after error --- scans/Makefile | 4 ++ scans/Readme | 9 +++- scans/s1.s | 111 ++++++++++++++++++++++++++++++++++++++----------- scans/s5.s | 46 ++++++++++---------- scans/s6.s | 32 +++++++------- scans/s7.s | 16 +++---- scans/s8.s | 10 ++--- scans/sx.s | 22 ++++++++++ tools/as7 | 45 ++++++++++++++------ 9 files changed, 206 insertions(+), 89 deletions(-) create mode 100644 scans/Makefile create mode 100644 scans/sx.s diff --git a/scans/Makefile b/scans/Makefile new file mode 100644 index 0000000..2d84114 --- /dev/null +++ b/scans/Makefile @@ -0,0 +1,4 @@ +AS7=../tools/as7 -d + +system: + $(AS7) s?.s > output diff --git a/scans/Readme b/scans/Readme index 2a67a55..df3dc80 100644 --- a/scans/Readme +++ b/scans/Readme @@ -6,5 +6,12 @@ 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, incomplete +s2.s: pages 7- +s3.s: pages 14- +s4.s: pages 21- +s5.s: pages 28- +s6.s: pages 34- +sx.s: temp symbol defns (from end of s1.s) + cat.c: pages 21-23 of 06-5-12.pdf diff --git a/scans/s1.s b/scans/s1.s index 355c501..d9e639e 100644 --- a/scans/s1.s +++ b/scans/s1.s @@ -102,31 +102,94 @@ swap: 0 dac u.ulistp i ion jmp dskswap; 07000 + lac u.dspbuf + sna + jmp 2f + law dspbuf + jms movdsp +2: + iof + lac o600000 + tad 9f+t i + dac 9f+t i + ion + jms dskswap; 06000 + lac u.swapret + dac swap + lac o20 + dac maxquant + lac u.dspbuf + sza +"** 01-s1.pdf page 4 + jms movdsp +3: + dzm uquant + iof + jmp swap i +t = t+1 -" For now, this stuff is defined so that -" the assembler doesn't complain about it +swp: + jmp . + .save; .getuid; .open; .read; .write; .creat; .seek; .tell + .close; .link; .unlink; .setuid; .rename; .exit; .time; .intrp + .chdir; .chmod; .chown; badcal; .sysloc; badcal; .capt; .rele + .status; badcal; .sems; .rmes; .fork +swn: + .-swp-1 i +.intrp: + lac u.ac + dac u.intflg + jmp okexit + +.sysloc: + lac u.ac + and o1777 + jms betwen; d1; locn + jms error + tad locsw + dac .+1 + lac .. + dac u.ac + jmp sysexit + +locsw: + lac . + iget; inode; userdata; sysdata; copy; copyz; betwen; dskrd + dskwr; dskbuf; dpdata; namei; pbsflgs; alloc; free; dspdata + crdata +locn: + .-locsw-1 -pibreak: 23 -u.ac: 100 -u.mq: 3 -u.rq: 3 -copy: 7 -.savblk: 0 -.insys: 0 -uquant: 0 -betwen: 0 -maxquant: 0 -laci: 0 -swp: 0 -badcal: 0 -coldentry: 0 -halt: 0 -dskio: 0 -sysdata: 0 -dskbuf: 0 -o7000: 07000 -o20001: 020001 chkint: 0 -.save: 0 -lookfor: 0 + lac .insys + sza + jmp chkint i + lac .int1 + sna + jmp 1f + sad u.ofiles+2 + jmp 2f +1: + lac .int2 + sna + jmp chkint i + sad chkint i + sad u.ofiles+2 + skp + jmp chkint i + dzm .int2 + jmp 1f +2: + dzm .int1 +1: +"** 01-s1.pdf page 5 + lac u.intflg + sza + jmp chkint i + -1 + dac .insys + ion + isz chkint + jmp chkint i + diff --git a/scans/s5.s b/scans/s5.s index 3baf07f..0d20930 100644 --- a/scans/s5.s +++ b/scans/s5.s @@ -2,15 +2,15 @@ " s5 dskswap: 0 - cli; ais 3 + cll; als 3 dac 9f+t jms dsktrans; -64; userdata; 9f+t; dskswap - lac 0f+t + lac 9f+t tad o20 dac 9f+t - jms dsktrans; -4096; 4096; 9f+t; dekswap - isc dskswap - jmp dskswap + jms dsktrans; -4096; 4096; 9f+t; dskswap + isz dskswap + jmp dskswap i t = t+1 @@ -21,7 +21,7 @@ access: 0 spa jmp access i sad i.uid - ird 2 + lrs 2 lacq and mode sza @@ -60,8 +60,8 @@ t = t+1 fget: 0 jms betwen; d0; d9 jmp fget i - cli; mul; 3 - iacq "** ?? + cll; mul; 3 + lacq "** 01-s1.pdf page 29 tad ofilesp @@ -83,14 +83,14 @@ forall: 0 sad u.limit jmp 1f lac u.base - rai + ral lac u.base i - sni + snl lrs 9 and o777 jmp forall i 1: - lac u.ount + lac u.count dac u.ac jmp sysexit @@ -157,7 +157,7 @@ icreat: 0 lac u.uid dac u.uid -1 - dac i.niks + dac i.nlks dzm i.size jms copyz; i.dskps; 7 jms iput @@ -171,9 +171,9 @@ dspput: 0 jmp i dspput sad o14 jmp 1f - img "** ??? + lmq sad o12 - jmp dspni + jmp dspnl lac dsploc i sad o400000 jmp dspleft @@ -195,19 +195,19 @@ dspleft: dac 8 lac o400000 dac 8 i - cla; liss 18+7 + cla; llss 18+7 dac dsploc i jmp dspput i -dspni: 0 - lac dspino +dspnl: 0 + lac dsplno sad d33 jmp 1f - isz dspino - jmp dspni i + isz dsplno + jmp dspnl i 1: lac o2000 - wbi + wbi "** ?? isz dspput jmp dspput i @@ -216,12 +216,12 @@ dspinit: 0 dac dsploc lac o300000 dac dspbuf+3 - dzm dspino + dzm dsplno jmp dspinit i movdsp: 0 iof - cdf + caf dac dspbufp -1 dac .dspb @@ -237,7 +237,7 @@ argname: 0 jms arg dac .+2 jms copy; ..; name; 4 - lac u.edir + lac u.cdir jms namei; name jms error jmp argname i diff --git a/scans/s6.s b/scans/s6.s index 9f6559d..e3855c8 100644 --- a/scans/s6.s +++ b/scans/s6.s @@ -37,7 +37,7 @@ itrunc: 0 jmp 1b lac i.flags and o577777 - dac i.flacs + dac i.flags jmp itrunc i t = t+4 @@ -54,7 +54,7 @@ namei: 0 -8 tad i.size cma - irss 3 + lrss 3 dac 9f+t sna jmp namei i @@ -94,13 +94,13 @@ t = t+2 iget: 0 dac ii - cli; idiv; 5 + cll; idiv; 5 dac 9f+t tad d2 dac 9f+i+1 jms dskrd lac 9f+t - cli; mul; 12 + cll; mul; 12 lacq tad dskbufp dac 9f+t @@ -151,14 +151,14 @@ dget: 0 alss 3 dac 9f+t jms pget - fac 9f+t+1 + dac 9f+t+1 jms dskrd lac 9f+t and o77 tad dskbufp dac 9f+t+2 dac .+2 - jms copy; ..; dnode; 8 + jms copy; ..; inode; 8 lac 9f+t tad d8 jms betwen; d0; i.size @@ -173,7 +173,7 @@ dput: 0 jms dskrd lac 9f+t+2 dac .+3 - jms copy; dnode; ..; 8 + jms copy; inode; ..; 8 lac 9f+t+1 jms dskwr jmp dput i @@ -181,11 +181,11 @@ dput: 0 t = t+3 "** first t not there (hole from hole punch?) pget: 0 - irss 6 + lrss 6 dac 9f+t lac i.flags -"** 01-s1.pdf page 36 +"** 01-s1.pdf page 37 and o200000 sza @@ -193,7 +193,7 @@ pget: 0 lac 9f+t jms betwen; d0; d6 jmp 1f - rad idskpp + tad idskpp dac 9f+t lac 9f+t i sna @@ -203,8 +203,8 @@ pget: 0 1: jms alloc dac 9f+t+1 - jms copy; idskps; dskbuf; 7 - jms copyz; dskbuf+7; 6467 "** NUMBER UNCLEAR 64-7??? + jms copy; i.dskps; dskbuf; 7 + jms copyz; dskbuf+7; 64-7 "** NUMBER UNCLEAR lac 9f+t+1 jms dskwr lac 9f+t+1 @@ -247,8 +247,8 @@ iwrite: 0 "** 01-s1.pdf page 38 - dac oread - lac cslp + dac iread + lac cskp dac iwrite jmp 1f @@ -282,7 +282,7 @@ iread: 0 1: lac 9f+t jms pget - das 9f+t+3 + dac 9f+t+3 jms dskrd lac 9f+t and o77 @@ -331,7 +331,7 @@ finac: 0 sma jms error lac f.i - jms ihet + jms iget jms finac i dacisize: 0 diff --git a/scans/s7.s b/scans/s7.s index 224f223..42d841e 100644 --- a/scans/s7.s +++ b/scans/s7.s @@ -3,20 +3,20 @@ pibreak: dac .ac "** CROSSED OUT.... - dpsf + lpsf jmp 1f - dpcf - dprs + lpcf + dprs "** ?? dac dpstat - sma rad + sma ral jmp 2f - dprc + dprc "** ?? dac dpchar -1 dac dpread lac dpstat - rai + ral 2: sma jmp piret @@ -28,7 +28,7 @@ pibreak: jmp 1f lpb - dac pbsfigs + dac pbsflgs isz s.tim+1 skp isz s.tim @@ -251,7 +251,7 @@ ttyrestart: 0 lpb dac pbsflgs+1 -"** 01-s1.pdf page 44 +"** 01-s1.pdf page 45 and o2000 sna diff --git a/scans/s8.s b/scans/s8.s index a26d3e9..9a243c2 100644 --- a/scans/s8.s +++ b/scans/s8.s @@ -102,7 +102,7 @@ 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 dsploc: .=.+1 -dspinc: .=.+1 +dsplno: .=.+1 dspbuf: 0065057;0147740;0160000 .=.+30 @@ -113,11 +113,11 @@ coldentry: clon law 3072 vcga - jsp dspinit + jms dspinit law dspbuf - jsp movdsp + jms movdsp cla - jsp dskio; 06000 + jms dskio; 06000 jms copy; dskbuf; sysdata; ulist-sysdata lac d3 jms namei; initf @@ -194,7 +194,7 @@ inode: i.flags: .=.+1 i.dskps: .=.+7 i.uid: .=.+1 - i.lks: .=.+1 + i.nlks: .=.+1 i.size: .=.+1 i.uniq: .=.+1 .= inode+12 diff --git a/scans/sx.s b/scans/sx.s new file mode 100644 index 0000000..958bc61 --- /dev/null +++ b/scans/sx.s @@ -0,0 +1,22 @@ + +" For now, this stuff is defined so that +" the assembler doesn't complain about it + +.save: 0 +alloc: 0 +betwen: 0 +chkint: 0 +copy: 7 +copyz: 0 +dskio: 0 +dskrd: 0 +dsktrans: 0 +dskwr: 0 +error: 0 +free: 0 +halt: 0 +laci: 0 +lookfor: 0 +o7000: 07000 +o70000: 070000 +swp: 0 diff --git a/tools/as7 b/tools/as7 index 1d235b0..8cc7226 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 @@ -111,12 +125,12 @@ sub parse_file { # Split into a section with possible labels and a # statement section with definitely no labels. The ? # makes the first pattern less greedy. - #print("cmd is >$cmd<\n"); + print("cmd is >$cmd<\n"); $cmd =~ m{(.*?)([^:]*$)}; 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} ); @@ -202,6 +216,7 @@ sub parse_statement { sub parse_expression { my $expression = shift; +print "exp: $expression\n"; # If it's a defined variable ( . , .. , etc.) # return the value return ( $Var{$expression} ) @@ -426,7 +441,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 +482,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 From 815d8bc220d900e093b34a5449bc3262dcecf107 Mon Sep 17 00:00:00 2001 From: Phil Budne Date: Thu, 25 Feb 2016 21:03:39 -0500 Subject: [PATCH 10/32] comment out debug prints --- tools/as7 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/as7 b/tools/as7 index 8cc7226..433cfd2 100755 --- a/tools/as7 +++ b/tools/as7 @@ -125,7 +125,7 @@ sub parse_file { # Split into a section with possible labels and a # statement section with definitely no labels. The ? # makes the first pattern less greedy. - print("cmd is >$cmd<\n"); + #print("cmd is >$cmd<\n"); $cmd =~ m{(.*?)([^:]*$)}; my $labelsect = $1; my $statement = $2; @@ -216,7 +216,6 @@ sub parse_statement { sub parse_expression { my $expression = shift; -print "exp: $expression\n"; # If it's a defined variable ( . , .. , etc.) # return the value return ( $Var{$expression} ) From 719b5a0968b4b116716c66cda612618d7e66f4b1 Mon Sep 17 00:00:00 2001 From: Phil Budne Date: Thu, 25 Feb 2016 21:42:23 -0500 Subject: [PATCH 11/32] add s4.s --- scans/s4.s | 343 +++++++++++++++++++++++++++++++++++++++++++++++++++++ scans/sx.s | 13 -- 2 files changed, 343 insertions(+), 13 deletions(-) create mode 100644 scans/s4.s diff --git a/scans/s4.s b/scans/s4.s new file mode 100644 index 0000000..6c2ceeb --- /dev/null +++ b/scans/s4.s @@ -0,0 +1,343 @@ +"** 01-s1.pdf page 21 +" s4 + +alloc: 0 + -1 + tad s.nfblks + spa + jmp 1f + dac s.nfblks + tad fblksp + jms laci + dac 9f+t + jms copyz; dskbuf; 64 + lac 9f+t + jms dskwr + dzm .savblk + lac 9f+t + jmp alloc i +1: + lac s.nxfblk + sna + jms halt " OUT OF DISK + dac s.fblks + jms dskrd + lac dskbuf + dac s.nxfblk + jms copy; dskbuf+1; s.fblks+1; 9 + lac d10 + dac s.nfblks + jmp alloc-1 + +free: 0 + lmq + lac x.nfblks + sad d10 + jmp 1f + tad fblksp + dac 9f+t + lacq + dac 9f+t i + dzm .savblk + isz s.nfblks + jmp free i +1: + lac x.nxfblk + dac dskbuf + jms copy; s.fblks+1; dskbuf+1; 9 + lacq + dac s.nxfblk + jms dskwr + dzm .savblk + lac d1 + dac s.nfblks + jmp free i +t = t+1 + +laci: 0 + and o1777 + tad o200000 + dac ._1 + lac .. + jmp laci i + +"** 01-s1.pdf page 22 + +betwen: 0 + lmq cmq + lac betwen i + dac 9f+t + lacq + tad 9f+t i + sma + jmp 1f + lac betwen i + dac 9f+t + isz betwen + lacq + tad 9f+t i + cma + spa sna +1: + isz betwen + lacq + cma + jmp betwen i + +copy: 0 + -1 + tad copy i + dac 8 + isz copy + -1 + tad copu i + dac 9 + isz copy + -1 + tad copy i + cma + dac 9f+t + isz copy +1: + lac 8 i + dac 9 i + isz 9f+t + jmp 1b + jmp copy i + +copyz: 0 + -1 + tad copyz i + dac 8 + isz copyz + -1 + tad copyz i + cma + dac 9f+t + isz copyz +1: + dzm 8 i + isz 9f+t + jmp 1b + jmp copyz i +t = t+1 + +putchar: 0 +"** 01-s1.pdf page 23 + dac 9f+t + cla + jms takeq + jmp putchar i + tad of0001 + dac .+4 + lac 9f+t + jms putc + lac char + lac q2+1 .. + isz putchar + jmp putchar i +t = t+1 + +getchar: 0 + jms takeq + jmp i getchar + tad o200001 + dac .+3 + cla + jms putc + lac q2+1 .. + isz getchar + jmp i getchar + +takeq: 0 + rcl + tad lacq1 + dac .+7 + tad o640000 + dac .+17 + dad s1 + dac .+14 + tad o500000 + dac .+5 + lac q1 .. + sna + jmp takeq i + dac lnkaddr + sad q1+1 .. + jmp .+5 + tad o200000 + dac .+1 + lac q2 .. + jmp .+3 + cla + dac q1+1 .. + dac q1 .. + isz takeq + lac lnkaddr + jmp i takeq + +putq: 0 + rcl + tad dacq1 + dac .+14 + tad d1 + dac .+13 + tad o140000 + dac .+1 + lac q1-1 .. +"** 01-s1.pdf page 24 + sna + jmp .+6 + tad o40000 + dac .+2 + lac lnkaddr + dac q2 .. + jmp .+3 + lac lnkaddr + dac q1 .. + dac q1+1 .. + jmp putq i + +srcdbs: 0 + lmq "** written (printed chars obscured) + -ndskbs + dac 9f+t + law dskbs "* -1 dac 8 written + dac 9f+t+1 +1: + lac 9f+t+2 "** crossed out + sad 9f+t+1 "** isz 8 written + jmp srcdbs i + law 65 "** crossed out + tad 9f+t+1 "** crossed out isz 8 written + isz 9f+t+1 + isx 9f+t + jmp 1b + isz srcdbs + jmp srcdbs i + +collapse: 0 + cla + jms srcdbs + jmp 1f + law dskbs + dac 9f+t+1 "** 9f+t+1 crossed out: 8 written in +1: + lac 9f+t+1 "** 9f+t+1 crossed out: 8 written in + dac 0f+1 + tad d2 "** crossed out: original obscured + dac 0f + cma + rad d1 + tad esdkbsp + and o17777 + sna + jmp 0f+3 + dac 0f+2 + jms copy; 0; ..; ..; .. + -65 + tad edskbsp + dac 9f+t + tad d1 + dac 0f + lac dskaddr + dac 9f+t i + jms copy; dskbuf; 0; ..; 64 + jmp collaps i + +dskrd: 0 + jms betwen; d2; d7999 + +"** 01-s1.pdf page 25 + jms halt + sad dskaddr + jmp dskrd i + dac dskaddr + jms srcdbs + jmp 1f + lac dskaddr + jms dskio; 06000 + jmp 1f +1: + dzm 9f+t+1 i + law 1 + tad 9f+t+1 + dac .+2 + jms copy; ..; dskbuf; 64 +2: + jms collaps + jmp dskrd i + +dskwr: 0 + jms betwen; d2; d7999 + jms halt + jms dskio; 07000 + lac dskaddr + jms srcdbs + dzm 9f+t+1 i + jms collapse + jmp dskwr i +t = t+3 + +dskio: 0 + dac dskaddr + cll; idiv; 80 + dac 9f+t + lacq + idiv; 10 + dac 9f+t+1 + lls 22 + xor 9f+t+1 + als 8 + dac 9f+t+1 + lac 9f+t + idiv; 10 + dac 9f+t + ils 22 + xor 9f+t + jms dsktrans; -64; dskbuf; 9f+t; dskio + isz dskio + jmp dskio i +t = t+1 + +dsktrans: 0 + -10 + dac 9f+t +1: + -1 + tad dsktrans + dac 12 +"** 01-s1.pdf page 26 + dscs + lac 12 i + dslw + lac 12 i + dslm + lac 12 i + jms laci + dsld + dzm .dskb + lac 12 i + jms laci + jms laci + dsls + lac .dskb + sna + jmp .-2 + lac .dske + sma + jmp 12 i + isz 9f+t + jmp 1b + jms halt " 10 disk errors +t = t+1 + +halt: 0 + isz 9f+t + jmp .-1 + iof + hlt + jms copy; law; 4096; 4096 + hlt; jmp .-1 +t = t+1 + diff --git a/scans/sx.s b/scans/sx.s index 958bc61..9b32582 100644 --- a/scans/sx.s +++ b/scans/sx.s @@ -3,20 +3,7 @@ " the assembler doesn't complain about it .save: 0 -alloc: 0 -betwen: 0 -chkint: 0 -copy: 7 -copyz: 0 -dskio: 0 -dskrd: 0 -dsktrans: 0 -dskwr: 0 error: 0 -free: 0 -halt: 0 -laci: 0 lookfor: 0 o7000: 07000 o70000: 070000 -swp: 0 From f89b487d08820cc0f3dbe73adc1a53824e88aa3a Mon Sep 17 00:00:00 2001 From: Phil Budne Date: Thu, 25 Feb 2016 22:13:06 -0500 Subject: [PATCH 12/32] add s3.s --- scans/s3.s | 355 +++++++++++++++++++++++++++++++++++++++++++++++++++++ scans/sx.s | 3 - 2 files changed, 355 insertions(+), 3 deletions(-) create mode 100644 scans/s3.s diff --git a/scans/s3.s b/scans/s3.s new file mode 100644 index 0000000..29b7d21 --- /dev/null +++ b/scans/s3.s @@ -0,0 +1,355 @@ +"** 01-s1.pdf page 14 +" s3 + +searchu: 0 + lac searchu i + dac 9f+t+1 + -mnproc + dac 9f+t + law ulist-1 + dac 8 +1: + lac 8 i + dac lu + lac 8 i + dac lu+1 + lac 8 i + dac lu+2 + lac 8 i + dac lu+3 + jms 9f+t+1 i + isz 9f+t + jmp 1b + isz searchu + jmp searchu i + +lookfor: 0 + jms searchu; 1f + isz lookfor + isz lookfor + jmp lookfor i +1: 0 + lac lu + rtl; rtl; and o7 + sad lookfor i + skp + jmp 1b i + -3 + tad 8 + and o17777 + isz lookfor + jmp lookfor i + +.fork: + jms lookfor; 0 " not-user + skp + jms error + dac 9f+t + isz uniqpid + lac uniqpid + dac u.ac + law sysexit + dac u.swapret + lac o200000 + tad u.listp i + dac u.listp i + jms dskswap; 07000 + lac 9f+t + dac u.ulistp + lac o100000 + xor u.ulistp i + dac u.ulistp i + lac u.pid +"** 01-s1.pdf page 15 + dac u.ac + lac uniqpid + dac u.pid + isz 9f+t + dac 9f+t i + isz u.rq+8 + dzm u.intflg + jmp sysexit +t= t+1 + +badcal: + calon + -1 + dac 7 +.save: + lac d1 + jms iget + cla + jms iwrite; 4096; 4096 + jms iwrite; userdata; 64 + jms iput + +.exit: + lac u.dspbuf + sna + jmp .+3 + law dspbuf + jms movdsp + jms awake + lac u.ulistp i + and o77777 + dac u.ulistp i + isz u.ulistp + dzm u.ulistp i + jms swap + +.rmes: + jms awake + lac o100000 + tad u.ulistp i + dac u.ulistp i + law 2 + tad u.ulistp + dac 9f+t + -1 + dac 9f+t i + jms swap + law 2 + tad u.ulistp + dac 9f+t + lac 9f+t i + cma + dac u.ac + dzm 9f+t i + isz 9f+t i + lac 9f+t i + dac u.mq + dzm 9f+t i + jmp sysexit +t = t+1 + +"** 01-s1.pdf page 16 +.smes: + lac u.ac + sna spa + jms error + jms searchu; 1f + law 2 + tad u.ulistp + dac 9f+t + dzm 9f+t i + jms error +1: 0 + lac lu+1 + sad u.ac + skp + jmp 1b i + lac 1u+2 + sad dm1 + jmp 1f + lac o100000 + tad u.ulistp i + dac u.ulistp i + law 2 + tad u.ulistp + dac 9f+t + lac u.ac + dac 9f+t i + jms swap + law 2 + tad u.ulistp + dac 9f+t + dzm 9f+t i + jmp .smes +1: + -3 + tad 8 + dac 0f+t + lac o700000 + tad 9f+t i + dac 9f+t i + isz 9f+t + isz 9f+t + lac u.pid + cma + dac 9f+t i + isz 9f+t + lac u.mq + dac 9f+t i + jmp okexit +t = t+1 + +awake: 0 + jms searchu; 1f + jmp awake i +1: 0 + lac u.pid + sad lu+2 + skp + jmp 1b i + -3 + tad 8 + dac 9f+t +"** 01-s1.pdf page 17 + lac o700000 + tad 9f+t i + dac 9f+t i + jmp 1b i +t = t+1 + +swr: +sww: + jmp .-4 i + .halt; rttyi; rkbdi; rppti; .halt + .halt; wttyo; wskpo; wppto + +.halt: jms halt + +rttyi: + jms chkint1 + lac d1 + jms getchar + jmp1f + and o177 + jms betwen o101; o132 + skp + tad o40 + alss 9 + jmp passone +1: + jms sleep; sfiles+0 + jms swap + jmp rttyi + +wttyo: + jms chkint1 + jms forall + sna + jmp failr + lmq + lac sfiles+1 + spa + jmp 1f + xor 0400000 + dac dfiles+1 + lacq + tls + sad o12 + jms putcr + jmp failr +1: + lacq + dac char + lac d2 "** written: d6 ttyout + jms putchar + skp + jmp failr + jms sleep; sfiles+1 + jms swap + jmp wttyo + +rkdbi: + jms chkint1 + lac d2 + jms getchar +"** 01-s1.pdf page 18 + jmp 3f + lmq + and o155 + sad o55 + jmp 1f + lacq + and o137 + sad o134 + lacq + xor o40 + lmq + jmp 2f +1: + lacq + xor o20 + lmq +2: + lacq + dac u.limit +1: + jms chkint1 + lac u.limit + jms dspput + jmp 1f + jms sleep; sfiles+6 + jms swap + jmp 1b +1: + lac u.limit + alss 9 + jmp passone +3: + jms sleep; sfiles+2 + jms swap + jmp rkdbi + +wdspo: + jms chkint1 + jms forall + jms dspput + jmp failr + jms sleep; sfiles+6 + jms swap + jmp wdspo + + +rppti: + lac d4 + jms getchar + jmp .+3 + alss 9 + jmp apssone + lac sfiles+3 + sma + rsa +1: + jms sleep; sfiles+3 + jms swap + jmp rppti +"** 01-s1.pdf page 19 + +wppto: + jms forall + sna + jmp failr + lmq + lac sfiles+4 + spa + jmp 1f + xor o400000 + dac sfiles+4 + lacq + psa + jmp failr +1: + lacq + dac char + lac d5 + jms putchar + skp + jmp failr + jms sleep; sfiles+4 + jms swap + jmp wppto + +passone: + sad o4000 + jmp okexit + dac u.base i + lac d1 + dac u.ac + jmp sysexit + +error: 0 + -1 + sac u.ac + jmp sysexit + +chkint1: 0 + dzm .insys + jmp chkint + skp + jmp .save + -1 + dac .insys + jmp chkint1 i diff --git a/scans/sx.s b/scans/sx.s index 9b32582..015accc 100644 --- a/scans/sx.s +++ b/scans/sx.s @@ -2,8 +2,5 @@ " For now, this stuff is defined so that " the assembler doesn't complain about it -.save: 0 -error: 0 -lookfor: 0 o7000: 07000 o70000: 070000 From 73237d68fa029824b44fdbe68b88fdfca60cf06f Mon Sep 17 00:00:00 2001 From: Phil Budne Date: Thu, 25 Feb 2016 22:42:59 -0500 Subject: [PATCH 13/32] add s2.s --- scans/s2.s | 334 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 334 insertions(+) create mode 100644 scans/s2.s diff --git a/scans/s2.s b/scans/s2.s new file mode 100644 index 0000000..89fe2c4 --- /dev/null +++ b/scans/s2.s @@ -0,0 +1,334 @@ +"** 01-s1.pdf page 7 +" s2 + +.status: + jms arg + dac .+5 + jms arg + dac .+6 + lac u.cdir + jms namei; .. + jms error + jms namei; .. + jms error + jms iget + lac u.ac + and o17777 + jms betwen; o10000; o17762 + jms error + dac .+3 + jms copy; inode; ..; 12 + dac 9 i + jmp okexit + +.capt: + lac u.ac + dac u.dspbuf + jms movdsp + jmp sysexit + +.rele: + dzm u.dspbuf + law dspbuf + jsp movdsp + jmp sysexit + +.chmod: + jms isown + lac u.ac + and o17 + lmq + lac i.flags + and o777760 + omq + dac i.flags + jms iput + jmp okexit + +.chown: + jms isown + lac u.ac + dac i.uid + jms iput + jmp okexit + +.getuid: + lac u.uid + dac u.ac + jmp sysexit + +.seek: + jms seektell + tad u.base +"** 01-s1.pdf page 8 + spa + jms error + lmq + lac f.flags + and d1 + sna + jms 1f + lacq + jms betwen; d0; i.size + jms dacisize + jmp 2f +1: + lacq + jms betwen; d0; i.size + lac i.size +2: + dac f.badd + dac u.ac + jms fput + jmp sysexit + +.tell: + jms seektell + cma + tad d1 + tad u.base + dac u.ac + jmp sysexit + +.link: + jms arg + dac 0f + jms arg + dac 1f + jms arg + dac 2f + lac d4 + jms namei; 0; 0 + jms error + jms namei; 1; 0 + jms error + dac u.base + jms copy; 2; 0; name; 4 + lac u.cdir + jms namei; name + skp + jms error + lac d1 + dac mode + jms access + jms dslot + lac u.base + jms iget + lac ii + dac d.i "** ?? + jms copy; name; d.name; 4 + lac i.uniq + dac d.uniq + -1 + tad i.nlks + dac i.nlks +"** 01-s1.pdf page 9 + jms imput + jms dput + jms okexit + +.unlink: + jms argname + dac u.base + lac d1 + dac mode + jms access + dac d.i + jms dput + lac u.base + jms u.base + jms iget + isz i.nlks + jmp 1f + jms itrunc + dzm i.flags +1: + jms iput + jmp sysexit + +.setuid: + lac u.uid + sma + jms error + lac u.ac + dac u.uid + jmp sysexit + +.rename: + jms arg + dac 0f + jms arg + dac 1f + lac u.cdir + jms namei; 0;0 + jms error + lac d1 + dac mode + jms access + jms copy; 1; 0; d.name; 4 + jmp okexit + +.time: + lac s.tim + dac u.ac + lac s.tim+1 + dac u.mq + jmp sysexit + +.chdir: + jms argname + jms iget + lac i.flags + and o20 + sna + jms error + lac ii + dac u.cdir +"** 01-s1.pdf page 10 + jmp okexit + +.open: + jms arg + dac 0f + jms arg + sza + lac d1 + sna + lac d2 + dac mode + lac u.cdir + jms namei; 0; 0 + jms error + jms iget + jms access + lac i.flags + and o20 + sna + jmp open1 + lac mode + and d1 + sna + jmp open1 + lac u.uid + sma + jms error + jmp open1 + +.creat: + lac d1 + dac mode + jms arg + dac .+2 + jms copy; ..; name; 4 + lac u.cdir + jms namei; name + jmp 1f + jms iget + jms access + lac i.flags + and o20 + sna + jmp .+4 + lac u.uid + sma + jms error + jms itrunc + cla + jms dacisize + jmp open1 +1: + jms access + lac u.ac + and o17 + jms icreat +open1: + jms fassign + jms error + jmp sysexit + +"** 01-s1.pdf page 11 +.close: + jms finac + dzm f.flags + jms fput + jmp sysexit + +.read: + jms arg + and o17777 + dac u.base + jms arg + dac u.count + lac u.base + jms betwen; o10000; o17777 + jms error + tad u.count + jms betwen; u.base; o17777 + jms error + dac u.limit +1: + jms finac + lac f.flags + and d1 + sza + jms error + lac i.flags + and o40 + sna + jmp 1f + iof + lac ii + tad swr + dac .+1 + jmp .. i +1: + lac u.base + dac 1f+1 + lac u.count + dac 1f+2 + lac f.badd +1: + jms iread; ..; .. + jmp exitrq + +.write: + jms arg + and o17777 + dac u.base + jms arg + dac u.count + tad u.base + jms betwen; u.base; o17777 + jms error + dac u.limit + jms finac + lac f.flags + and d1 + sna + jms error + lac i.flags + and o40 +"** 01-s1.pdf page 12 + sna + jmp 1f + iof + lac ii + tad sww + dac .+1 + jmp .. i +1: + lac u.base + dac 1f+1 + lac u.count + dac 1f+2 + lac f.badd +1: + jms iwrite; ..; .. + +exitrw: + dac u.ac + tad f.badd + dac f.badd + jms iput + jms fput + jmp sysexit From 92cbc9ed9115b6b20b84a5cfdcf1f0e95cdd6d8c Mon Sep 17 00:00:00 2001 From: Phil Budne Date: Thu, 25 Feb 2016 22:49:34 -0500 Subject: [PATCH 14/32] fixes --- scans/s8.s | 3 ++- scans/sx.s | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scans/s8.s b/scans/s8.s index 9a243c2..e70e643 100644 --- a/scans/s8.s +++ b/scans/s8.s @@ -62,7 +62,7 @@ o137: 0137 o155: 0155 o177: 0177 "** 01-s1.pdf page 49 -o232: 0212 +o212: 0212 o375: 0375 o777: 0777 o2000: 02000 @@ -74,6 +74,7 @@ o17777: 017777 o20001: 020001 o40000: 040000 o40001: 040001 +o70000: 070000 o77777: 077777 o100000: 0100000 o140000: 0140000 diff --git a/scans/sx.s b/scans/sx.s index 015accc..8c16094 100644 --- a/scans/sx.s +++ b/scans/sx.s @@ -3,4 +3,3 @@ " the assembler doesn't complain about it o7000: 07000 -o70000: 070000 From cdb09de1c19ee24dad6f89a7aed37dbbce20b934 Mon Sep 17 00:00:00 2001 From: Phil Budne Date: Fri, 26 Feb 2016 00:51:01 -0500 Subject: [PATCH 15/32] fixes --- scans/s1.s | 4 ++-- scans/s2.s | 6 +++--- scans/s3.s | 14 +++++++------- scans/s4.s | 22 +++++++++++----------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/scans/s1.s b/scans/s1.s index d9e639e..3a8fead 100644 --- a/scans/s1.s +++ b/scans/s1.s @@ -133,7 +133,7 @@ swp: .save; .getuid; .open; .read; .write; .creat; .seek; .tell .close; .link; .unlink; .setuid; .rename; .exit; .time; .intrp .chdir; .chmod; .chown; badcal; .sysloc; badcal; .capt; .rele - .status; badcal; .sems; .rmes; .fork + .status; badcal; .smes; .rmes; .fork swn: .-swp-1 i @@ -144,7 +144,7 @@ swn: .sysloc: lac u.ac - and o1777 + and o17777 jms betwen; d1; locn jms error tad locsw diff --git a/scans/s2.s b/scans/s2.s index 89fe2c4..5c51afc 100644 --- a/scans/s2.s +++ b/scans/s2.s @@ -30,7 +30,7 @@ .rele: dzm u.dspbuf law dspbuf - jsp movdsp + jms movdsp jmp sysexit .chmod: @@ -123,7 +123,7 @@ tad i.nlks dac i.nlks "** 01-s1.pdf page 9 - jms imput + jms iput jms dput jms okexit @@ -289,7 +289,7 @@ open1: lac f.badd 1: jms iread; ..; .. - jmp exitrq + jmp exitrw .write: jms arg diff --git a/scans/s3.s b/scans/s3.s index 29b7d21..6ca7b28 100644 --- a/scans/s3.s +++ b/scans/s3.s @@ -72,7 +72,7 @@ lookfor: 0 t= t+1 badcal: - calon + clon -1 dac 7 .save: @@ -195,7 +195,7 @@ swr: sww: jmp .-4 i .halt; rttyi; rkbdi; rppti; .halt - .halt; wttyo; wskpo; wppto + .halt; wttyo; wdspo; wppto .halt: jms halt @@ -203,7 +203,7 @@ rttyi: jms chkint1 lac d1 jms getchar - jmp1f + jmp 1f and o177 jms betwen o101; o132 skp @@ -225,7 +225,7 @@ wttyo: spa jmp 1f xor 0400000 - dac dfiles+1 + dac sfiles+1 lacq tls sad o12 @@ -242,7 +242,7 @@ wttyo: jms swap jmp wttyo -rkdbi: +rkbdi: jms chkint1 lac d2 jms getchar @@ -298,7 +298,7 @@ rppti: jms getchar jmp .+3 alss 9 - jmp apssone + jmp passone lac sfiles+3 sma rsa @@ -342,7 +342,7 @@ passone: error: 0 -1 - sac u.ac + dac u.ac jmp sysexit chkint1: 0 diff --git a/scans/s4.s b/scans/s4.s index 6c2ceeb..c4cdfbf 100644 --- a/scans/s4.s +++ b/scans/s4.s @@ -31,7 +31,7 @@ alloc: 0 free: 0 lmq - lac x.nfblks + lac s.nfblks sad d10 jmp 1f tad fblksp @@ -42,7 +42,7 @@ free: 0 isz s.nfblks jmp free i 1: - lac x.nxfblk + lac s.nxfblk dac dskbuf jms copy; s.fblks+1; dskbuf+1; 9 lacq @@ -57,7 +57,7 @@ t = t+1 laci: 0 and o1777 tad o200000 - dac ._1 + dac .+1 lac .. jmp laci i @@ -90,7 +90,7 @@ copy: 0 dac 8 isz copy -1 - tad copu i + tad copy i dac 9 isz copy -1 @@ -128,10 +128,10 @@ putchar: 0 cla jms takeq jmp putchar i - tad of0001 + tad o40001 dac .+4 lac 9f+t - jms putc + jms putq lac char lac q2+1 .. isz putchar @@ -211,7 +211,7 @@ srcdbs: 0 law 65 "** crossed out tad 9f+t+1 "** crossed out isz 8 written isz 9f+t+1 - isx 9f+t + isz 9f+t jmp 1b isz srcdbs jmp srcdbs i @@ -228,8 +228,8 @@ collapse: 0 tad d2 "** crossed out: original obscured dac 0f cma - rad d1 - tad esdkbsp + tad d1 + tad edskbsp and o17777 sna jmp 0f+3 @@ -243,7 +243,7 @@ collapse: 0 lac dskaddr dac 9f+t i jms copy; dskbuf; 0; ..; 64 - jmp collaps i + jmp collapse i dskrd: 0 jms betwen; d2; d7999 @@ -293,7 +293,7 @@ dskio: 0 lac 9f+t idiv; 10 dac 9f+t - ils 22 + lls 22 xor 9f+t jms dsktrans; -64; dskbuf; 9f+t; dskio isz dskio From ba80514cbd64e37de6472ece0f28342d636c0352 Mon Sep 17 00:00:00 2001 From: Warren Toomey Date: Fri, 26 Feb 2016 17:35:58 +1000 Subject: [PATCH 16/32] Remind people to put in the page numbers and filenames! --- scans/Readme | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scans/Readme b/scans/Readme index df3dc80..8aff8f1 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. @@ -12,6 +12,15 @@ s3.s: pages 14- s4.s: pages 21- s5.s: pages 28- s6.s: pages 34- -sx.s: temp symbol defns (from end of s1.s) +s7.s: pages ??? of ??? +s8.s: pages ??? of ??? +s9.s: pages ??? of ??? +sx.s: temp symbol defns (pages ??? of s1.s) +bc.s: pages ??? of ??? +bi.s: pages ??? of ??? +bl.s: pages ??? of ??? +cas.s: pages ??? of ??? cat.c: pages 21-23 of 06-5-12.pdf +ind.b: pages ??? of ??? +lease.b: pages ??? of ??? From b8550475b0ee852fd0f2e0dbb79a57222039d9e5 Mon Sep 17 00:00:00 2001 From: Warren Toomey Date: Fri, 26 Feb 2016 18:43:20 +1000 Subject: [PATCH 17/32] I've got a very simple cat program working, which reads from stdin and sends it to stdout. --- tools/a7out | 335 ++++++++++++++++++++++++++-------------------- tools/simplecat.s | 29 ++++ 2 files changed, 218 insertions(+), 146 deletions(-) create mode 100644 tools/simplecat.s diff --git a/tools/a7out b/tools/a7out index ee77652..2de634a 100755 --- a/tools/a7out +++ b/tools/a7out @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# A7out: user-mode simulator for PDP-7 Unix applications +# a7out: user-mode simulator for PDP-7 Unix applications # # (c) 2016 Warren Toomey, GPL3 # @@ -11,7 +11,7 @@ use Data::Dumper; ### Global variables ### my $debug = 0; # Debug flag my @Mem; # 8K 18-bit words of main memory -my @FD; # Array of open filehandles +my @FD; # Array of open filehandles # Registers my $PC = 0; # Program counter @@ -74,6 +74,7 @@ sub simulate { my %Oplist = ( oct("004") => \&dac, oct("020") => \&lac, + oct("060") => \&jmp, oct("070") => \&iot, oct("074") => \&special, ); @@ -86,16 +87,16 @@ 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); + printf( STDERR + "PC %06o: instruction %08o, op %03o, ind %o, addr %06o\n", + $PC, $instruction, $opcode, $indirect, $addr ) + if ($debug); # 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", + } else { + printf( STDERR "Unknown instruction 0%o at location 0%o\n", $instruction, $PC ); die("\n"); } @@ -105,34 +106,41 @@ 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: %08o\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", + printf( STDERR "PC %06o: lac %05o (value %08o) into AC\n", $PC, $addr, $Mem[$addr] ) if ($debug); - $AC = ($indirect) ? $Mem[ $Mem[$addr] & 017777 ]: $Mem[$addr]; + $AC = ($indirect) ? $Mem[ $Mem[$addr] & 017777 ] : $Mem[$addr]; $PC++; } # Deposit AC sub dac { my ( $instruction, $indirect, $addr ) = @_; - printf( "PC %06o: dac AC (value %08o) into %05o into AC\n", + printf( STDERR "PC %06o: dac AC (value %08o) into %05o into AC\n", $PC, $AC, $addr ) if ($debug); if ($indirect) { - $Mem[ $Mem[$addr] & 017777 ] = $PC; + $Mem[ $Mem[$addr] & 017777 ] = $PC; } else { - $Mem[$addr] = $AC; + $Mem[$addr] = $AC; } $PC++; } +# Jump +sub jmp { + my ( $instruction, $indirect, $addr ) = @_; + printf( STDERR "PC %06o: jmp %06o\n", $PC, $addr ) if ($debug); + $PC = $addr; +} + # Special instructions sub special { my $instruction = shift; @@ -140,10 +148,22 @@ 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 + printf( STDERR "PC %06o: spa\n", $PC ) if ($debug); + $PC += ( $AC >= 0 ) ? 2 : 1; + return; + } + if ( $instruction == 0741200 ) { # sna: skip on non-zero AC + printf( STDERR "PC %06o: sna\n", $PC ) if ($debug); + $PC += ( $AC != 0 ) ? 2 : 1; + return; + } + printf( STDERR "PC %06o: unknown instruction %08o\n", $PC, $instruction ); + exit(1); } # I/O transfer: used for system calls @@ -163,190 +183,213 @@ sub iot { if ( defined( $Syscallist{$addr} ) ) { $Syscallist{$addr}->(); } else { - printf( "PC %06o: Unknown syscall %d\n", $PC, $addr ); + printf( STDERR "PC %06o: Unknown syscall %d\n", $PC, $addr ); die("\n"); } } # Exit system call sub sys_exit { - printf("PC %06o: exit system call\n", $PC) if ($debug); - exit(0); + printf( STDERR "PC %06o: exit system call\n", $PC ) if ($debug); + 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; + printf( STDERR "PC %06o: close: closing fd %d\n", $PC, $fd ) if ($debug); - # 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] ) ) { + print( STDERR "close: fd $fd is not open\n") if ($debug); + $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); + printf( STDERR "PC %06o: open: file %s\n", $PC, $filename ) if ($debug); + + # 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; + } + } + $AC = $fd; + return; + } else { + # No filehandle, so it's an error + print( STDERR "open failed: $!\n") if ($debug); + $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; + printf( STDERR "PC %06o: read: %d words into %o from fd %d\n", + $PC, $count, $start, $fd ) + if ($debug); - # 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] ) ) { + print( STDERR "read: fd $fd is not open\n") if ($debug); + $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; + printf( STDERR "PC %06o: write: %d words from %o to fd %d\n", + $PC, $count, $start, $fd ) + if ($debug); - # 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] ) ) { + print( STDERR "write: fd $fd is not open\n") if ($debug); + $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++; + } } diff --git a/tools/simplecat.s b/tools/simplecat.s new file mode 100644 index 0000000..7d01b49 --- /dev/null +++ b/tools/simplecat.s @@ -0,0 +1,29 @@ +" Simple cat program: echo stdin to stdout until no more words to read + +main: + " Read 5 words into the buffer from stdin + 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 5 words from the buffer to stdout + lac d1 + sys write; buf; 1:0 + jmp main + +error: +end: + " exit + sys exit + +d0: 0 +d1: 1 + +" Input buffer for read +buf: 0; 0; 0; 0; 0 From 6066798c2577a62cc0ed006bd5d6d49c63324e7e Mon Sep 17 00:00:00 2001 From: rswier Date: Fri, 26 Feb 2016 04:20:39 -0500 Subject: [PATCH 18/32] Transcribed from 05-1-4.pdf First draft in need of proofreading. --- scans/Readme | 15 +- scans/as.s | 980 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 989 insertions(+), 6 deletions(-) create mode 100644 scans/as.s diff --git a/scans/Readme b/scans/Readme index 8aff8f1..96ffd68 100644 --- a/scans/Readme +++ b/scans/Readme @@ -17,10 +17,13 @@ s8.s: pages ??? of ??? s9.s: pages ??? of ??? sx.s: temp symbol defns (pages ??? of s1.s) -bc.s: pages ??? of ??? -bi.s: pages ??? of ??? -bl.s: pages ??? of ??? -cas.s: pages ??? of ??? +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 ??? of ??? cat.c: pages 21-23 of 06-5-12.pdf -ind.b: pages ??? of ??? -lease.b: pages ??? of ??? + +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 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 From 8f8cc64d10abb7a035773a9d3a38385bc6431d1b Mon Sep 17 00:00:00 2001 From: Warren Toomey Date: Fri, 26 Feb 2016 20:56:31 +1000 Subject: [PATCH 19/32] I've added tad and sza to the a7out simulator, and I also added some code to place command-line arguments into the simulated memory. I'm trying to write my own version of cat so I can compare mine to the real one. Right now there's a bug when simplecat has two arguments. Zero and one arguments are OK! Saving so I have a backup before proceeding. --- tools/a7out | 111 ++++++++++++++++++++++++++++++++++++++++++---- tools/simplecat.s | 77 +++++++++++++++++++++++++++++++- 2 files changed, 178 insertions(+), 10 deletions(-) diff --git a/tools/a7out b/tools/a7out index 2de634a..0a68cab 100755 --- a/tools/a7out +++ b/tools/a7out @@ -27,11 +27,12 @@ if ( ( @ARGV > 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); simulate(); exit(0); @@ -67,6 +68,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, @@ -123,7 +181,7 @@ sub lac { # Deposit AC sub dac { my ( $instruction, $indirect, $addr ) = @_; - printf( STDERR "PC %06o: dac AC (value %08o) into %05o into AC\n", + printf( STDERR "PC %06o: dac AC (value %08o) into %05o\n", $PC, $AC, $addr ) if ($debug); if ($indirect) { @@ -134,6 +192,20 @@ sub dac { $PC++; } +# Add to AC +sub tad { + my ( $instruction, $indirect, $addr ) = @_; + printf( STDERR "PC %06o: tac AC (value %08o) from addr %05o\n", + $PC, $AC, $addr ) + if ($debug); + if ($indirect) { + $AC += $Mem[ $Mem[$addr] & 017777 ]; + } else { + $AC+= $Mem[$addr]; + } + $PC++; +} + # Jump sub jmp { my ( $instruction, $indirect, $addr ) = @_; @@ -153,15 +225,20 @@ sub special { exit(1); } if ( $instruction == 0741100 ) { # spa: skip on positive AC - printf( STDERR "PC %06o: spa\n", $PC ) if ($debug); + printf( STDERR "PC %06o: spa AC %06o\n", $PC, $AC ) if ($debug); $PC += ( $AC >= 0 ) ? 2 : 1; return; } if ( $instruction == 0741200 ) { # sna: skip on non-zero AC - printf( STDERR "PC %06o: sna\n", $PC ) if ($debug); + printf( STDERR "PC %06o: sna AC %06o\n", $PC, $AC ) if ($debug); $PC += ( $AC != 0 ) ? 2 : 1; return; } + if ( $instruction == 0740200 ) { # sza: skip on zero AC + printf( STDERR "PC %06o: sza AC %06o\n", $PC, $AC ) if ($debug); + $PC += ( $AC == 0 ) ? 2 : 1; + return; + } printf( STDERR "PC %06o: unknown instruction %08o\n", $PC, $instruction ); exit(1); } @@ -237,14 +314,13 @@ sub sys_open { 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 ) { + foreach my $fd ( 0 .. 99 ) { if ( !defined( $FD[$fd] ) ) { $FD[$fd] = $FH; + $AC = $fd; last; } } - $AC = $fd; return; } else { # No filehandle, so it's an error @@ -393,3 +469,22 @@ sub mem2string { $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); +} diff --git a/tools/simplecat.s b/tools/simplecat.s index 7d01b49..c156620 100644 --- a/tools/simplecat.s +++ b/tools/simplecat.s @@ -1,6 +1,13 @@ " Simple cat program: echo stdin to stdout until no more words to read 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 + +" This section copies from standard input to standard output +stdinout: " Read 5 words into the buffer from stdin lac d0 sys read; buf; 5 @@ -15,15 +22,81 @@ main: " Write 5 words from the buffer to stdout lac d1 sys write; buf; 1:0 - jmp main -error: + " 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 1f + + " Open the file and get the fd into AC + sys open; 1:0; 0; 0 + spa + jmp noopen " Bad fd, exit with an error message + dac fd " Save the file descriptor + +fileloop: + " Read 5 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 5 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 +noopen: + " Print an "err open" string and exit + lac d1 + sys write; noopenstr; 5 + sys exit + +noopenstr: + ;;;012000 + +error: + " Print an "err read" string and exit + lac d1 + sys write; noreadstr; 5 + sys exit + +noreadstr: + ;;;012000 + d0: 0 d1: 1 +fd: 0 " fd of the open file " Input buffer for read buf: 0; 0; 0; 0; 0 From 536de9ea56749ba9f0f76f4921fc6b745c3ea2f2 Mon Sep 17 00:00:00 2001 From: Warren Toomey Date: Fri, 26 Feb 2016 21:26:44 +1000 Subject: [PATCH 20/32] I worked out the bug with the command-line arguments, I was overwriting 017777, oops. I've added more comments to wktcat.s (renamed from simplecat.s). Now we need to find out how the real PDP-7 Unix does command line arguments. --- tools/a7out | 4 +- tools/wktcat.s | 117 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 tools/wktcat.s diff --git a/tools/a7out b/tools/a7out index 0a68cab..bdd64db 100755 --- a/tools/a7out +++ b/tools/a7out @@ -33,6 +33,8 @@ die("Usage: $0 [-d] a.outfile [arg1 arg2 ...]\n") if ( @ARGV < 1 ); # and simulate it load_code( shift(@ARGV) ); set_arguments(@ARGV); +#dump_memory(); +#exit(0); simulate(); exit(0); @@ -105,7 +107,7 @@ sub set_arguments { } # Count the number of words to store each string and its pointer - my $wordcount=1; # 1 as we count the NULL pointer at end of array + my $wordcount=2; # 2 as we count the NULL pointer at end of array my $argcount= @ARGV; foreach my $arg (@ARGV) { # +1 before /2 to allow for the NUL character at end of string diff --git a/tools/wktcat.s b/tools/wktcat.s new file mode 100644 index 0000000..a60c7ed --- /dev/null +++ b/tools/wktcat.s @@ -0,0 +1,117 @@ +" 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 1f + + " Open the file and get the fd into AC + sys open; 1:0; 0; 0 + spa + jmp noopen " 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 + +noopen: + " Print an "err open" string and exit + lac d1 + sys write; noopenstr; 5 + sys exit + +noopenstr: + ;;;012000 + +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 + +" Input buffer for read +buf: 0; 0; 0; 0; 0 From 6534bd6d437ed8adf01b9e920246849df4c85cb5 Mon Sep 17 00:00:00 2001 From: Warren Toomey Date: Fri, 26 Feb 2016 21:28:22 +1000 Subject: [PATCH 21/32] I renamed simplecat.s to wktcat.s --- tools/simplecat.s | 102 ---------------------------------------------- 1 file changed, 102 deletions(-) delete mode 100644 tools/simplecat.s diff --git a/tools/simplecat.s b/tools/simplecat.s deleted file mode 100644 index c156620..0000000 --- a/tools/simplecat.s +++ /dev/null @@ -1,102 +0,0 @@ -" Simple cat program: echo stdin to stdout until no more words to read - -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 - -" This section copies from standard input to standard output -stdinout: - " Read 5 words into the buffer from stdin - 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 5 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 1f - - " Open the file and get the fd into AC - sys open; 1:0; 0; 0 - spa - jmp noopen " Bad fd, exit with an error message - dac fd " Save the file descriptor - -fileloop: - " Read 5 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 5 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 - -noopen: - " Print an "err open" string and exit - lac d1 - sys write; noopenstr; 5 - sys exit - -noopenstr: - ;;;012000 - -error: - " Print an "err read" string and exit - lac d1 - sys write; noreadstr; 5 - sys exit - -noreadstr: - ;;;012000 - -d0: 0 -d1: 1 -fd: 0 " fd of the open file - -" Input buffer for read -buf: 0; 0; 0; 0; 0 From a132327a8bf5c2c31aa30728451c0ca0784e60f5 Mon Sep 17 00:00:00 2001 From: Warren Toomey Date: Fri, 26 Feb 2016 21:45:55 +1000 Subject: [PATCH 22/32] a7out: I had the spa logic wrong. Now fixed. --- tools/a7out | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/a7out b/tools/a7out index bdd64db..80fc3c7 100755 --- a/tools/a7out +++ b/tools/a7out @@ -228,7 +228,8 @@ sub special { } if ( $instruction == 0741100 ) { # spa: skip on positive AC printf( STDERR "PC %06o: spa AC %06o\n", $PC, $AC ) if ($debug); - $PC += ( $AC >= 0 ) ? 2 : 1; + # 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 From b98757bf79b5d4906e667c8fcedeed0992860fd7 Mon Sep 17 00:00:00 2001 From: Will Senn Date: Fri, 26 Feb 2016 05:54:41 -0600 Subject: [PATCH 23/32] added page numbers and source pdf information to readme --- scans/Readme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scans/Readme b/scans/Readme index 96ffd68..8915dc2 100644 --- a/scans/Readme +++ b/scans/Readme @@ -20,7 +20,7 @@ sx.s: temp symbol defns (pages ??? of s1.s) 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 ??? of ??? +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 From 9c8dbdea37ce6f0181cdb0135e59d9bac0611a8f Mon Sep 17 00:00:00 2001 From: Warren Toomey Date: Fri, 26 Feb 2016 21:57:10 +1000 Subject: [PATCH 24/32] tools/a7out: I refactored the indirect logic, much nicer now. --- tools/a7out | 53 ++++++++++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/tools/a7out b/tools/a7out index 80fc3c7..c2880b8 100755 --- a/tools/a7out +++ b/tools/a7out @@ -147,14 +147,17 @@ sub simulate { my $opcode = ( $instruction >> 12 ) & 074; my $indirect = ( $instruction >> 13 ) & 1; my $addr = $instruction & 017777; + + # Work out what any indirect address would be + my $indaddr= ($indirect) ? $Mem[$addr] & 017777 : $addr; printf( STDERR - "PC %06o: instruction %08o, op %03o, ind %o, addr %06o\n", - $PC, $instruction, $opcode, $indirect, $addr ) + "PC %06o: instr %06o, op %03o, ind %o, addr %06o ind %06o\n", + $PC, $instruction, $opcode, $indirect, $addr, $indaddr ) if ($debug); # Simulate the instruction. Each subroutine updates the $PC if ( defined( $Oplist{$opcode} ) ) { - $Oplist{$opcode}->( $instruction, $indirect, $addr ); + $Oplist{$opcode}->( $instruction, $addr, $indaddr ); } else { printf( STDERR "Unknown instruction 0%o at location 0%o\n", $instruction, $PC ); @@ -166,53 +169,45 @@ sub simulate { # Debug code: dump memory contents sub dump_memory { foreach my $i ( 0 .. 017777 ) { - printf( STDERR "%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( STDERR "PC %06o: lac %05o (value %08o) into AC\n", - $PC, $addr, $Mem[$addr] ) + my ( $instruction, $addr, $indaddr ) = @_; + printf( STDERR "PC %06o: lac %05o (value %06o) into AC\n", + $PC, $indaddr, $Mem[$indaddr] ) if ($debug); - $AC = ($indirect) ? $Mem[ $Mem[$addr] & 017777 ] : $Mem[$addr]; + $AC = $Mem[$indaddr]; $PC++; } # Deposit AC sub dac { - my ( $instruction, $indirect, $addr ) = @_; - printf( STDERR "PC %06o: dac AC (value %08o) into %05o\n", - $PC, $AC, $addr ) + my ( $instruction, $addr, $indaddr ) = @_; + printf( STDERR "PC %06o: dac AC (value %06o) into %05o\n", + $PC, $AC, $indaddr ) if ($debug); - if ($indirect) { - $Mem[ $Mem[$addr] & 017777 ] = $PC; - } else { - $Mem[$addr] = $AC; - } + $Mem[$indaddr] = $AC; $PC++; } # Add to AC sub tad { - my ( $instruction, $indirect, $addr ) = @_; - printf( STDERR "PC %06o: tac AC (value %08o) from addr %05o\n", - $PC, $AC, $addr ) + my ( $instruction, $addr, $indaddr ) = @_; + printf( STDERR "PC %06o: tac AC (value %06o) from addr %05o\n", + $PC, $AC, $indaddr ) if ($debug); - if ($indirect) { - $AC += $Mem[ $Mem[$addr] & 017777 ]; - } else { - $AC+= $Mem[$addr]; - } + $AC+= $Mem[$indaddr]; $PC++; } # Jump sub jmp { - my ( $instruction, $indirect, $addr ) = @_; - printf( STDERR "PC %06o: jmp %06o\n", $PC, $addr ) if ($debug); - $PC = $addr; + my ( $instruction, $addr, $indaddr ) = @_; + printf( STDERR "PC %06o: jmp %06o\n", $PC, $indaddr ) if ($debug); + $PC = $indaddr; } # Special instructions @@ -242,13 +237,13 @@ sub special { $PC += ( $AC == 0 ) ? 2 : 1; return; } - printf( STDERR "PC %06o: unknown instruction %08o\n", $PC, $instruction ); + 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 = ( From d6d4c9b8146083fe075fd29b98959ce8a9ebffd0 Mon Sep 17 00:00:00 2001 From: Warren Toomey Date: Fri, 26 Feb 2016 22:37:03 +1000 Subject: [PATCH 25/32] According to cat.s, fd 8 is standard error (not fd2!). I've updated the a7out simulator to have STDERR on fd 8. --- tools/a7out | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/a7out b/tools/a7out index c2880b8..986b645 100755 --- a/tools/a7out +++ b/tools/a7out @@ -50,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"); From e022dbecfc849df013d5972f8149c14945cd1218 Mon Sep 17 00:00:00 2001 From: Phil Budne Date: Fri, 26 Feb 2016 14:15:12 -0500 Subject: [PATCH 26/32] system: update Readme, fix typos --- scans/Readme | 20 ++++++++++---------- scans/s2.s | 12 ++++++------ scans/s3.s | 10 +++++----- scans/s4.s | 12 ++++++------ scans/s5.s | 5 +++++ scans/s7.s | 31 ++++++++++++++++++------------- scans/s8.s | 10 ++++++---- scans/s9.s | 18 +++++++++--------- scans/sx.s | 25 ++++++++++++++++++++++++- 9 files changed, 89 insertions(+), 54 deletions(-) diff --git a/scans/Readme b/scans/Readme index 8915dc2..9d2840f 100644 --- a/scans/Readme +++ b/scans/Readme @@ -6,16 +6,16 @@ For modified versions of these files, look in src/cmds and src/sys. Details of the files: -s1.s: pages 2-5 of 01-s1.pdf, incomplete -s2.s: pages 7- -s3.s: pages 14- -s4.s: pages 21- -s5.s: pages 28- -s6.s: pages 34- -s7.s: pages ??? of ??? -s8.s: pages ??? of ??? -s9.s: pages ??? of ??? -sx.s: temp symbol defns (pages ??? of s1.s) +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 +sx.s: temp additional symbol defns bc.s: pages 7-11 of 06-5-12.pdf bi.s: pages 12-19 of 06-5-12.pdf diff --git a/scans/s2.s b/scans/s2.s index 5c51afc..3847776 100644 --- a/scans/s2.s +++ b/scans/s2.s @@ -98,12 +98,12 @@ jms arg dac 2f lac d4 - jms namei; 0; 0 + jms namei; 0:0 jms error - jms namei; 1; 0 + jms namei; 1:0 jms error dac u.base - jms copy; 2; 0; name; 4 + jms copy; 2:0; name; 4 lac u.cdir jms namei; name skp @@ -160,12 +160,12 @@ jms arg dac 1f lac u.cdir - jms namei; 0;0 + jms namei; 0:0 jms error lac d1 dac mode jms access - jms copy; 1; 0; d.name; 4 + jms copy; 1:0; d.name; 4 jmp okexit .time: @@ -197,7 +197,7 @@ lac d2 dac mode lac u.cdir - jms namei; 0; 0 + jms namei; 0:0 jms error jms iget jms access diff --git a/scans/s3.s b/scans/s3.s index 6ca7b28..742c0a3 100644 --- a/scans/s3.s +++ b/scans/s3.s @@ -51,8 +51,8 @@ lookfor: 0 law sysexit dac u.swapret lac o200000 - tad u.listp i - dac u.listp i + tad u.ulistp i + dac u.ulistp i jms dskswap; 07000 lac 9f+t dac u.ulistp @@ -138,7 +138,7 @@ t = t+1 sad u.ac skp jmp 1b i - lac 1u+2 + lac lu+2 sad dm1 jmp 1f lac o100000 @@ -158,7 +158,7 @@ t = t+1 1: -3 tad 8 - dac 0f+t + dac 9f+t lac o700000 tad 9f+t i dac 9f+t i @@ -281,7 +281,7 @@ rkbdi: 3: jms sleep; sfiles+2 jms swap - jmp rkdbi + jmp rkbdi wdspo: jms chkint1 diff --git a/scans/s4.s b/scans/s4.s index c4cdfbf..e1e406f 100644 --- a/scans/s4.s +++ b/scans/s4.s @@ -55,7 +55,7 @@ free: 0 t = t+1 laci: 0 - and o1777 + and o17777 tad o200000 dac .+1 lac .. @@ -144,7 +144,7 @@ getchar: 0 tad o200001 dac .+3 cla - jms putc + jms putq lac q2+1 .. isz getchar jmp i getchar @@ -155,7 +155,7 @@ takeq: 0 dac .+7 tad o640000 dac .+17 - dad s1 + tad d1 dac .+14 tad o500000 dac .+5 @@ -234,7 +234,7 @@ collapse: 0 sna jmp 0f+3 dac 0f+2 - jms copy; 0; ..; ..; .. + jms copy; 0:..; ..; .. -65 tad edskbsp dac 9f+t @@ -242,7 +242,7 @@ collapse: 0 dac 0f lac dskaddr dac 9f+t i - jms copy; dskbuf; 0; ..; 64 + jms copy; dskbuf; 0:..; 64 jmp collapse i dskrd: 0 @@ -265,7 +265,7 @@ dskrd: 0 dac .+2 jms copy; ..; dskbuf; 64 2: - jms collaps + jms collapse jmp dskrd i dskwr: 0 diff --git a/scans/s5.s b/scans/s5.s index 0d20930..9a136ce 100644 --- a/scans/s5.s +++ b/scans/s5.s @@ -89,6 +89,11 @@ forall: 0 lrs 9 and o777 jmp forall i +failr: + lac u.base + add o400000 + dac u.base + jmp forall+1 1: lac u.count dac u.ac diff --git a/scans/s7.s b/scans/s7.s index 42d841e..03ce63d 100644 --- a/scans/s7.s +++ b/scans/s7.s @@ -3,15 +3,16 @@ pibreak: dac .ac "** CROSSED OUT.... - lpsf + + dpsf jmp 1f - lpcf - dprs "** ?? + dpcf + dprs dac dpstat sma ral jmp 2f - dprc "** ?? + dprc dac dpchar -1 dac dpread @@ -71,11 +72,7 @@ cnop: jmp piret 1: lds "** BEGIN CROSSED OUT - sma ra1 - jmp 1f - cdf - lac .dspb - sna + sma ral jmp 1f cdf lac .dspb @@ -86,8 +83,16 @@ cnop: jmp dsprestart dac .dspb jmp piret +dsprestart: + lac d1 + dac .dspb + lac dspbufp + beg "** ??? + -10 + dac .dsptm + jmp piret -1: sna ra1 +1: sna ral jmp .+3 racf jmp piret @@ -125,7 +130,7 @@ cnop: "** 01-s1.pdf page 43 - jms ptcr + jms putcr jms ttyrestart jmp piret @@ -277,7 +282,7 @@ ttyrestart: 0 piret: lac 0 - rai + ral lac .ac ion jmp 0 i @@ -292,7 +297,7 @@ wakeup: 0 dac 2f+1 1: lac 9f+t - rao + ral dac 9f+t sma jmp 2f+2 diff --git a/scans/s8.s b/scans/s8.s index e70e643..88ad5f4 100644 --- a/scans/s8.s +++ b/scans/s8.s @@ -4,7 +4,7 @@ " manifests mnproc = 10 -dspbss = 270 +dspbsz = 270 ndskbs = 4 " flags @@ -24,7 +24,7 @@ maxquant: 30 ofilesp: u.ofiles idskpp: i.dskps dskbufp: dskbuf -edspbuf: dspbuf+dspbzs +edspbuf: dspbuf+dspbsz fblksp: s.fblks dacq1: dac q1 lacq1: lac q1 @@ -113,7 +113,7 @@ coldentry: ion clon law 3072 - vcga + wcga jms dspinit law dspbuf jms movdsp @@ -142,6 +142,7 @@ ttydelay: .=.+1 name: .=.+4 lnkaddr: .=.+1 char: .=.+1 +dskaddr: .=.+1 uniqpid: 1 lu: .=.+4 sfiles: .=.+10 @@ -180,7 +181,7 @@ userdata: u.uid: -1 u.pid: 1 u.cdir: 3 - u.ulistp: clist + u.ulistp: ulist u.swapret: 0 u.base: 0 u.count: 0 @@ -200,6 +201,7 @@ inode: i.uniq: .=.+1 .= inode+12 di: .=.+1 +dnode: d.i: .=.+1 d.name: .=.+4 d.uniq: .=.+1 diff --git a/scans/s9.s b/scans/s9.s index 77004b2..4967d2f 100644 --- a/scans/s9.s +++ b/scans/s9.s @@ -1,4 +1,4 @@ -"** 01-s1.pdf page 54 +"** 01-s1.pdf page 53 " s9 -- cold boot . = coldentry+4 @@ -8,7 +8,7 @@ dzm ii jms copyz; dskbuf; 64 1: - iac ii + lac ii jms dskio; 0700 isz ii -710 @@ -42,7 +42,7 @@ jms iget jms copyz; inode; 12 jms getw " flags - dac i.dlags + dac i.flags -1 dac i.uid jms getw " number links @@ -51,7 +51,7 @@ tad xx dac i.size lac ii - dac u.uniq + dac i.uniq law 4096-1 dac 8 -1 @@ -65,7 +65,7 @@ 2: jms getw dac 8 i - iss xx + isz xx jmp 2b 3: lac sum @@ -80,7 +80,7 @@ jms iwrite; 4096; .. jms iput cla - jms dksio + jms dskio @@ -90,10 +90,10 @@ getw: 0 jms getc alss 12 - imq + lmq jms getc - omg - lmg + omq + lmq jms getc omg lmg diff --git a/scans/sx.s b/scans/sx.s index 8c16094..ab37559 100644 --- a/scans/sx.s +++ b/scans/sx.s @@ -1,5 +1,28 @@ - " For now, this stuff is defined so that " the assembler doesn't complain about it +" illegible +idunno=-1 +wbi=-1 + +" disk I/O instructions? +dscs=-1 +dslw=-1 +dslm=-1 +dsld=-1 +dsls=-1 +dssf=-1 +dsrs=-1 + +" display I/O instructions? +dprs=-1 +dprc=-1 +dpsf=-1 +dpcf=-1 + +" printer I/O instructions? +lpsf=-1 +lpcf=-1 +lpb=-1 + o7000: 07000 From fc0d2c2b3101863c98f0aebf4a4c8131f4650d85 Mon Sep 17 00:00:00 2001 From: Phil Budne Date: Fri, 26 Feb 2016 16:25:03 -0500 Subject: [PATCH 27/32] new files: sop.s maksys.s trysys.s (last in 01-s1.pdf) --- scans/Makefile | 4 +-- scans/Readme | 3 ++ scans/maksys.s | 52 +++++++++++++++++++++++++++ scans/sop.s | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++ scans/trysys.s | 40 +++++++++++++++++++++ 5 files changed, 194 insertions(+), 2 deletions(-) create mode 100644 scans/maksys.s create mode 100644 scans/sop.s create mode 100644 scans/trysys.s diff --git a/scans/Makefile b/scans/Makefile index 2d84114..8d6b259 100644 --- a/scans/Makefile +++ b/scans/Makefile @@ -1,4 +1,4 @@ -AS7=../tools/as7 -d +AS7=../tools/as7 system: - $(AS7) s?.s > output + $(AS7) s?.s sop.s > output diff --git a/scans/Readme b/scans/Readme index 9d2840f..fbf09a3 100644 --- a/scans/Readme +++ b/scans/Readme @@ -15,7 +15,10 @@ 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 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: + ;;; Date: Fri, 26 Feb 2016 16:25:53 -0500 Subject: [PATCH 28/32] fixes sop.s supercedes (most of) sx.s --- scans/s5.s | 2 +- scans/s7.s | 2 +- scans/s9.s | 6 +++--- scans/sx.s | 24 ------------------------ 4 files changed, 5 insertions(+), 29 deletions(-) diff --git a/scans/s5.s b/scans/s5.s index 9a136ce..8f12620 100644 --- a/scans/s5.s +++ b/scans/s5.s @@ -212,7 +212,7 @@ dspnl: 0 jmp dspnl i 1: lac o2000 - wbi "** ?? + wbl isz dspput jmp dspput i diff --git a/scans/s7.s b/scans/s7.s index 03ce63d..6d12062 100644 --- a/scans/s7.s +++ b/scans/s7.s @@ -266,7 +266,7 @@ ttyrestart: 0 jms wakeup dac sfiles+6 cla - wbi + wbl jmp piret "** END CROSSED OUT 1: crsf diff --git a/scans/s9.s b/scans/s9.s index 4967d2f..b308170 100644 --- a/scans/s9.s +++ b/scans/s9.s @@ -38,7 +38,7 @@ jmp 1b " 0 count means pause dac xx isz ii - iac ii + lac ii jms iget jms copyz; inode; 12 jms getw " flags @@ -95,8 +95,8 @@ getw: 0 omq lmq jms getc - omg - lmg + omq + lmq add sum dac sum lacq diff --git a/scans/sx.s b/scans/sx.s index ab37559..6b08758 100644 --- a/scans/sx.s +++ b/scans/sx.s @@ -1,28 +1,4 @@ " For now, this stuff is defined so that " the assembler doesn't complain about it -" illegible -idunno=-1 -wbi=-1 - -" disk I/O instructions? -dscs=-1 -dslw=-1 -dslm=-1 -dsld=-1 -dsls=-1 -dssf=-1 -dsrs=-1 - -" display I/O instructions? -dprs=-1 -dprc=-1 -dpsf=-1 -dpcf=-1 - -" printer I/O instructions? -lpsf=-1 -lpcf=-1 -lpb=-1 - o7000: 07000 From 09d5df42804a93091616dffe3d28a4023d95c455 Mon Sep 17 00:00:00 2001 From: Will Senn Date: Fri, 26 Feb 2016 15:44:09 -0600 Subject: [PATCH 29/32] initial transcription of ed1.s and ed2.s from 08-rest.pdf --- scans/Readme | 3 + scans/ed1.s | 771 +++++++++++++++++++++++++++++++++++++++++++++++++++ scans/ed2.s | 519 ++++++++++++++++++++++++++++++++++ 3 files changed, 1293 insertions(+) create mode 100644 scans/ed1.s create mode 100644 scans/ed2.s diff --git a/scans/Readme b/scans/Readme index fbf09a3..08dc3e8 100644 --- a/scans/Readme +++ b/scans/Readme @@ -30,3 +30,6 @@ 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/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 From 5f162abc5e273f7834ca8b955144cbac93450b69 Mon Sep 17 00:00:00 2001 From: Will Senn Date: Fri, 26 Feb 2016 15:45:26 -0600 Subject: [PATCH 30/32] added comments for page numbers to cas.s --- scans/cas.s | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scans/cas.s b/scans/cas.s index 315c794..f4e61fc 100644 --- a/scans/cas.s +++ b/scans/cas.s @@ -1,3 +1,4 @@ +"** 04-cas.pdf page 1 " cas narg = i 017777 @@ -60,6 +61,7 @@ mes: dac 10 advanc: +"** 04-cas.pdf page 2 lac nchar dzm nchar sza @@ -121,6 +123,7 @@ adv1: sad o170 skp jmp 1f +"** 04-cas.pdf page 3 dzm vis jmp advanc 1: @@ -182,6 +185,7 @@ adv1: alss 6 llss 3 tad o60060 +"** 04-cas.pdf page 4 dac i 10 cla llss 3 @@ -243,6 +247,7 @@ loop: lac dely ;"dx ,gr, 0 sna jmp c3 +"** 04-cas.pdf page 5 spa jmp c4 lac d1 @@ -304,6 +309,7 @@ a: dac dist tad incxp dac tmp +"** 04-cas.pdf page 6 lac i tmp dac incx lac dist @@ -364,7 +370,7 @@ com: tad y dac y jmp loop - +"** 04-cas.pdf page 7 out: lac nx dac x @@ -425,6 +431,7 @@ dm3: -3 dm4: -4 o162: 0162 o166: 0166 +"** 04-cas.pdf page 8 o17: 017 o777: 0777 o72: 072 @@ -486,6 +493,7 @@ o12060: 012060 +"** 04-cas.pdf page 9 :ca v af @@ -548,6 +556,7 @@ x mk v ma +"** 04-cas.pdf page 10 aa ak x @@ -609,6 +618,7 @@ r :ci x +"** 04-cas.pdf page 11 md v mi @@ -670,6 +680,7 @@ r :cm v aa +"** 04-cas.pdf page 12 hf ak nk @@ -731,6 +742,7 @@ ck kk mi mc +"** 04-cas.pdf page 13 x jh v @@ -792,6 +804,7 @@ x aa v ka +"** 04-cas.pdf page 14 mc ml "??? kk @@ -853,6 +866,7 @@ v if x ak +"** 04-cas.pdf page 15 v if nf @@ -914,6 +928,7 @@ gc ia ma ml "??? +"** 04-cas.pdf page 16 mc mi kk @@ -975,6 +990,7 @@ hi fk x mn +"** 04-cas.pdf page 17 x mn r From 779e655703449bccf58012c7d7f21b1b740a07b2 Mon Sep 17 00:00:00 2001 From: Warren Toomey Date: Sat, 27 Feb 2016 08:03:52 +1000 Subject: [PATCH 31/32] More git notes. --- misc/git_notes.txt | 4 ++++ 1 file changed, 4 insertions(+) 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 From d2511c36c0e88c9e9535266b3cca870444f689e1 Mon Sep 17 00:00:00 2001 From: Warren Toomey Date: Sat, 27 Feb 2016 08:05:52 +1000 Subject: [PATCH 32/32] I'm trying to bring my wktcat.s file into line with the real one. I've refactored tools/a7out to have a dprintf() function to printf only on debugging. I still need to rewrite the command-line arg storage structure. --- tools/a7out | 74 +++++++++++++++++++++++++------------------------- tools/wktcat.s | 26 +++++++++++------- 2 files changed, 53 insertions(+), 47 deletions(-) diff --git a/tools/a7out b/tools/a7out index 986b645..b349f35 100755 --- a/tools/a7out +++ b/tools/a7out @@ -103,7 +103,7 @@ sub set_arguments { # No arguments, set the 017777 pointer to 017776 which is NULL if (@ARGV==0) { $Mem[ 017777 ] = 017776; - print( STDERR "No arguments, so NULL 017777 pointer\n") if ($debug); + dprintf("No arguments, so NULL 017777 pointer\n"); return; } @@ -151,10 +151,8 @@ sub simulate { # Work out what any indirect address would be my $indaddr= ($indirect) ? $Mem[$addr] & 017777 : $addr; - printf( STDERR - "PC %06o: instr %06o, op %03o, ind %o, addr %06o ind %06o\n", - $PC, $instruction, $opcode, $indirect, $addr, $indaddr ) - if ($debug); + 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} ) ) { @@ -162,7 +160,7 @@ sub simulate { } else { printf( STDERR "Unknown instruction 0%o at location 0%o\n", $instruction, $PC ); - die("\n"); + exit(1); } } } @@ -177,9 +175,8 @@ sub dump_memory { # Load AC sub lac { my ( $instruction, $addr, $indaddr ) = @_; - printf( STDERR "PC %06o: lac %05o (value %06o) into AC\n", - $PC, $indaddr, $Mem[$indaddr] ) - if ($debug); + dprintf( "PC %06o: lac %05o (value %06o) into AC\n", + $PC, $indaddr, $Mem[$indaddr] ); $AC = $Mem[$indaddr]; $PC++; } @@ -187,27 +184,25 @@ sub lac { # Deposit AC sub dac { my ( $instruction, $addr, $indaddr ) = @_; - printf( STDERR "PC %06o: dac AC (value %06o) into %05o\n", - $PC, $AC, $indaddr ) - if ($debug); - $Mem[$indaddr] = $AC; + 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 ) = @_; - printf( STDERR "PC %06o: tac AC (value %06o) from addr %05o\n", - $PC, $AC, $indaddr ) - if ($debug); - $AC+= $Mem[$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 ) = @_; - printf( STDERR "PC %06o: jmp %06o\n", $PC, $indaddr ) if ($debug); + dprintf( "PC %06o: jmp %06o\n", $PC, $indaddr ); $PC = $indaddr; } @@ -223,18 +218,18 @@ sub special { exit(1); } if ( $instruction == 0741100 ) { # spa: skip on positive AC - printf( STDERR "PC %06o: spa AC %06o\n", $PC, $AC ) if ($debug); + 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 - printf( STDERR "PC %06o: sna AC %06o\n", $PC, $AC ) if ($debug); + dprintf( "PC %06o: sna AC %06o\n", $PC, $AC ); $PC += ( $AC != 0 ) ? 2 : 1; return; } if ( $instruction == 0740200 ) { # sza: skip on zero AC - printf( STDERR "PC %06o: sza AC %06o\n", $PC, $AC ) if ($debug); + dprintf( "PC %06o: sza AC %06o\n", $PC, $AC ); $PC += ( $AC == 0 ) ? 2 : 1; return; } @@ -260,13 +255,13 @@ sub iot { $Syscallist{$addr}->(); } else { printf( STDERR "PC %06o: Unknown syscall %d\n", $PC, $addr ); - die("\n"); + exit(1); } } # Exit system call sub sys_exit { - printf( STDERR "PC %06o: exit system call\n", $PC ) if ($debug); + dprintf( "PC %06o: exit system call\n", $PC ); exit(0); } @@ -275,14 +270,14 @@ sub sys_close { # AC is the file descriptor my $fd = $AC; - printf( STDERR "PC %06o: close: closing fd %d\n", $PC, $fd ) if ($debug); + dprintf( "PC %06o: close: closing fd %d\n", $PC, $fd ); # Bump up the PC $PC += 1; # That filehandle is not open, set an error -1 in octal if ( !defined( $FD[$fd] ) ) { - print( STDERR "close: fd $fd is not open\n") if ($debug); + dprint( "close: fd $fd is not open\n"); $AC = 0777777; return; } @@ -307,7 +302,7 @@ sub sys_open { # Convert this to a sensible ASCII filename my $filename = mem2string($start); - printf( STDERR "PC %06o: open: file %s\n", $PC, $filename ) if ($debug); + dprintf( "PC %06o: open: file %s\n", $PC, $filename ); # Open the file if ( open( my $FH, "<", $filename ) ) { @@ -323,7 +318,7 @@ sub sys_open { return; } else { # No filehandle, so it's an error - print( STDERR "open failed: $!\n") if ($debug); + dprintf( "open failed: $!\n"); $AC = 0777777; return; } @@ -340,17 +335,17 @@ sub sys_read { my $fd = $AC; my $start = $Mem[ $PC + 1 ]; my $count = $Mem[ $PC + 2 ]; - my $end = $start + $count - 1; - printf( STDERR "PC %06o: read: %d words into %o from fd %d\n", - $PC, $count, $start, $fd ) - if ($debug); + 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 ); # Bump up the PC $PC += 3; # That filehandle is not open, set an error -1 in octal if ( !defined( $FD[$fd] ) ) { - print( STDERR "read: fd $fd is not open\n") if ($debug); + dprint( "read: fd $fd is not open\n"); $AC = 0777777; return; } @@ -393,17 +388,17 @@ sub sys_write { my $fd = $AC; my $start = $Mem[ $PC + 1 ]; my $count = $Mem[ $PC + 2 ]; - my $end = $start + $count - 1; - printf( STDERR "PC %06o: write: %d words from %o to fd %d\n", - $PC, $count, $start, $fd ) - if ($debug); + 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; # That filehandle is not open, set an error -1 in octal if ( !defined( $FD[$fd] ) ) { - print( STDERR "write: fd $fd is not open\n") if ($debug); + dprint( "write: fd $fd is not open\n"); $AC = 0777777; return; } @@ -487,3 +482,8 @@ sub string2mem { } return($base); } + +# Print out debug messages +sub dprintf { + printf( STDERR @_) if ($debug); +} diff --git a/tools/wktcat.s b/tools/wktcat.s index a60c7ed..ef11a35 100644 --- a/tools/wktcat.s +++ b/tools/wktcat.s @@ -44,12 +44,12 @@ 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 1f + dac name " Open the file and get the fd into AC - sys open; 1:0; 0; 0 + sys open; name:0; 0; 0 spa - jmp noopen " Bad fd, exit with an error message + jmp badfile " Bad fd, exit with an error message dac fd " Save the file descriptor fileloop: @@ -91,14 +91,19 @@ end: " exit sys exit -noopen: - " Print an "err open" string and exit - lac d1 - sys write; noopenstr; 5 - sys exit -noopenstr: - ;;;012000 +" 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 @@ -112,6 +117,7 @@ noreadstr: 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