gunner.94 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435
  1. TITLE GUNNER
  2. ; GUNNER is a replacement for the original muddle gunner, which knows only
  3. ; about COMBAT. This version will find any dead demon, and do more or less
  4. ; the right thing with it. In particular:
  5. ; for COMBAT it tries to look like the current incarnation: rename the
  6. ; offending plan to GUNNED >, and send mail to the author of the plan.
  7. ; In addition, it sends mail to the COMBAT maintainer (clr).
  8. ; for BATCHN it kills all inferiors (with the exception of the garbage
  9. ; collector, should it exist) and closes the script channel, sending mail
  10. ; to swg.
  11. ; for COMSYS it closes all channels, unlocks the locks (via location 3+40addr),
  12. ; and sends mail to poor pdl.
  13. ; other demons are just gunned down; mail is sent to mb.
  14. ; mail is always sent to taa.
  15. ; Whereupon, the demon is caused to recons itself.
  16. ; A fairly disgusting algorithm is used to decide if a demon is permanently
  17. ; losing, in which case the above actions are suppressed: the demon is
  18. ; disowned, and mail is sent (with some additional history information);
  19. ; the demon is left down in this case.
  20. O=0
  21. A=1
  22. B=2
  23. C=3
  24. D=4
  25. E=5
  26. F=6
  27. G=7
  28. PBLOCK=10
  29. LOSTBL=11
  30. SOU1=12
  31. SOU2=13
  32. DEM=14 ; DEMON NAME
  33. T=15 ; OFFSET INTO DEMON TABLE
  34. U=16 ; SYSTEM USER INDEX
  35. P=17
  36. ; CHANNELS
  37. DSKI==0
  38. DSKO==1
  39. USRI==2
  40. USRO==3
  41. ; PAGE FOR RANDOM MAPPING
  42. MAPPAG=100.
  43. MAPBEG=MAPPAG*2000
  44. ; DEFINITIONS FOR DEMON STATS TABLE
  45. DEMNAM==0
  46. DEMCT==1
  47. WINCT==2
  48. LOSCT==3
  49. DATST==4 ; FIRST WORD OF DATA
  50. DATLEN==2 ; LENGTH OF EACH DATA ENTRY
  51. LOSLEN==DATST+4*DATLEN
  52. ; OFFSETS INTO DATA ENTRY
  53. LOSPC==0 ; LOSING PC
  54. LOSTM==1 ; TIME LOSS WAS DISCOVERED
  55. ; DEFINITIONS FOR PROCESS TABLE
  56. PROCES==0
  57. NXTRUN==1
  58. INTRVL==2
  59. ITERS==3
  60. PLEN==4 ; LENGTH OF BLOCK
  61. ; RANDOMS
  62. SN2311==43 ; DEVICE CODE FOR DSK DEVICE CHANNELS
  63. SNUSR==61 ; DEVICE CODE FOR NON-FOREIGN USR DEVICE CHANNELS
  64. SNMSP==31 ; DEVICE CODE FOR IPC DEVICE
  65. BUSRC==100000 ; USER-SETTABLE BIT IN LH OF USTP
  66. IOSDEV==000600 ; LH OF BYTE POINTER TO DEVICE CODE IN IOS WORD
  67. ; CONSTANT STRING OUTPUT
  68. DEFINE SOUT CHAN,TXT
  69. MOVE SOU1,[440700,,[ASCII /TXT/]]
  70. MOVEI SOU2,.LENGTH /TXT/
  71. .CALL [SETZ
  72. SIXBIT /SIOT/
  73. MOVSI %TJDIS
  74. MOVEI CHAN
  75. SOU1
  76. SETZ SOU2]
  77. .LOSE 1000
  78. TERMIN
  79. LOC 42
  80. JSR TSINT
  81. LOC 100
  82. SUBTTL VARIABLES
  83. LOC44: 0
  84. MPVFLG: 0 ; MPV MIGHT HAPPEN BECAUSE DOING UNLOCKING
  85. DEBUGF: 0 ; DEBUGGING
  86. SYSVER: 0 ; SYSTEM VERSION
  87. SLPTIM: 0 ; TIME TO SLEEP
  88. TIMLFT: 0 ; TIME LEFT BEFORE GOING AWAY (IN 30'THS)
  89. CMIN: 0 ; USED TO ACCUMULATE NEXT SLPTIM
  90. LUNAME: 0 ; CONTAINS UNAME OF MUNGED JOB
  91. LJNAME: 0 ; JNAME
  92. DUNAME: 0 ; UNAME OF JOB WHEN DISOWNED
  93. DJNAME: 0 ; JNAME
  94. ; SWITCHES USED WHEN SENDING MAIL. ZEROED WHENEVER DEMON FOUND TO HACK.
  95. BLTBEG:
  96. SNDTWO: 0 ; -1 WHEN HAVE SENT FIRST MAIL (TO DEMON OWNER)
  97. GOTJOB: 0 ; -1 IF WE HAVE JOB AS INFERIOR
  98. BADUPC: 0 ; PC WHEN GUNNED
  99. VALLEN: 0 ; LENGTH OF .VALUE STRING, OR 0
  100. GUNNED: 0 ; IF -1, JOB WAS GUNNED DOWN
  101. DISOWN: 0 ; IF -1, JOB WAS DISOWNED
  102. LEFT: 0 ; IF -1, JOB WAS LEFT AROUND
  103. BATCH: 0 ; -1 INDICATES THIS TYPE OF JOB (SPECIAL HACKING)
  104. COMBAT: 0
  105. LOKKIL: 0
  106. INFKIL: 0 ; # OF INFERIORS KILLED FOR A JOB (IF DISOWNED)
  107. CHNKIL: 0 ; # OF CHANNELS CLOSED FOR JOB
  108. OVERTI: 0 ; JOB RAN MORE THAN TWO HOURS (FOR COMBAT)
  109. FN1: 0 ; FIRST FILE NAME OF PLAN
  110. FN2: 0 ; SECOND FILE NAME OF PLAN
  111. RFN2: 0 ; SECOND FILE NAME OF 'GUNNED'
  112. BLTEND:
  113. LOSER: 0 ; SNAME IN PLAN: SEND MAIL HERE, TOO.
  114. SNDSAV: 0 ; SAVED P, IN CASE IOC ERROR WHEN SENDING MAIL.
  115. VALBLN==20.
  116. VALBUF: BLOCK VALBLN ; BUFFER FOR .VALUE STRINGS, IF APPLICABLE.
  117. ; TABLE OF DEMON OWNERS: WHOM SHALL I SEND TO?
  118. OWNTAB:
  119. COMNAM: SIXBIT /COMSYS/
  120. SIXBIT /PDL/
  121. ZONNAM: SIXBIT /ZONE/
  122. SIXBIT /CLR/
  123. BATNAM: SIXBIT /BATCHN/
  124. SIXBIT /SWG/
  125. OWNPTR: OWNTAB-.,,OWNTAB
  126. ; TABLE OF POSSIBLE FIRST NAMES OF PLANS FOR COMBAT, IN ORDER
  127. PLNTAB: SIXBIT /RIOT/
  128. SIXBIT /RWASTE/
  129. SIXBIT /PLAN/
  130. SIXBIT /WASTE/
  131. PLNNAM: PLNTAB-.,,PLNTAB
  132. EXBLK: 0 ; BLOCK STUFFED INTO JOB TO BE EXECUTED
  133. .BREAK 16,600000
  134. .BREAK 16,600000
  135. EXLEN==.-EXBLK ; LENGTH OF BLOCK
  136. ; BLOCK FOR SAVING INFERIOR'S INTERRUPT STATUS: MASKS AND PENDING INTERRUPTS
  137. INTBLK:
  138. IPIRQC: 0
  139. IIFPIR: 0
  140. IMASK2: 0
  141. IMASK: 0
  142. INFRUN: 0 ; IF -1, INFERIOR IS RUNNING
  143. RNDBLK: BLOCK 3 ; USED BY APTOFI
  144. APCNT: 0 ; USED BY APTOFI WHEN FINDS FILE LOCKED OR SOMETHING
  145. ; BLOCK FOR DEMON STATS. ALLOCATED WHEN A NEW DEMON IS OBSERVED, IN BLOCKS OF
  146. ; LOSLEN (CURRENTLY 12.) WORDS.
  147. LOSCNT==15 ; 15 DEMONS???
  148. LOSBLK: BLOCK LOSCNT*LOSLEN
  149. PDLLEN==20
  150. PDL: BLOCK PDLLEN
  151. INBLEN==100.
  152. INBUF: BLOCK INBLEN/5
  153. INBPTR: 440700,,INBUF
  154. PTABLE: PUSHJ P,DEMSCN ? 0 ? <15.*60.>*30. ? 0
  155. PUSHJ P,MSCAN ? 0 ? 0 ? 0
  156. PPTR: PTABLE-.,,PTABLE
  157. SUBTTL STARTUP & MAIN LOOP
  158. START: .CLOSE 1, ; SINCE DEMON STILL HAS CHANNEL FOR SYMBOLS
  159. MOVE P,[-PDLLEN,,PDL]
  160. PUSHJ P,SETUP ; WILL SKIP IF DEMON SHOULD STAY UP
  161. .LOGOUT
  162. .CALL [SETZ
  163. SIXBIT /LOGIN/
  164. [SIXBIT /GUNNER/]
  165. SETZ [0]]
  166. SETOM DEBUGF
  167. .SUSET [.SMASK,,[%PIIOC+%PIMPV]]
  168. .SUSET [.SMSK2,,[377,,0]]
  169. .RSYSI A, ; GET SYSTEM VERSION
  170. CAME A,SYSVER
  171. JRST INIT ; GO INITIALIZE
  172. BEGIN: SKIPE DEBUGF
  173. PUSHJ P,DEBUG
  174. MLOOP: MOVE PBLOCK,PPTR
  175. MOVEI A,777777
  176. MOVEM A,CMIN
  177. PLOOP: MOVE A,NXTRUN(PBLOCK)
  178. SUB A,SLPTIM ; TIME TO NEXT RUN
  179. JUMPG A,PEND ; NOT YET
  180. XCT PROCES(PBLOCK) ; RUN IT
  181. MOVE A,INTRVL(PBLOCK) ; TIME TO NEXT RUN, SINCE JUST RAN
  182. AOS ITERS(PBLOCK)
  183. PEND: CAMG A,CMIN ; SHORTEST TIME SO FAR?
  184. MOVEM A,CMIN ; YES
  185. MOVEM A,NXTRUN(PBLOCK)
  186. ADD PBLOCK,[PLEN,,PLEN]
  187. JUMPL PBLOCK,PLOOP ; DONE?
  188. MOVE A,TIMLFT
  189. SUB A,SLPTIM
  190. MOVEM A,TIMLFT
  191. MOVE A,CMIN
  192. MOVEM A,SLPTIM
  193. CAMLE A,TIMLFT
  194. JRST [PUSHJ P,SETUP ; MAYBE DONE
  195. .LOGOUT
  196. JRST .+1]
  197. .SLEEP A,
  198. JRST MLOOP
  199. SUBTTL DEMON-SCANNING
  200. DEMSCN: MOVE T,DEMTAB
  201. SCNLOP: SKIPE DEM,(T) ; IS THIS A DEMON?
  202. PUSHJ P,DEMHAK ; YES, GO HACK IT
  203. ADD T,DMTLL
  204. JUMPL T,SCNLOP
  205. POPJ P,
  206. ; COME HERE WITH DEMON NAME IN DEM, POINTER TO DEMON TABLE ENTRY IN T.
  207. ; IF DEMON NEEDS TO GO AWAY, DO THE RIGHT THING.
  208. DEMHAK: SKIPG U,1(T) ; USER INDEX
  209. POPJ P, ; NOT >0, SO DEMON IS DOWN
  210. PUSHJ P,LSINIT ; MAKE AN ENTRY IN LOSTBL FOR IT, OR FIND EXISTING
  211. SKIPL @APRC ; TEST SIGN BIT OF APRC: SET IF DISOWNED
  212. JRST ZONHAK ; GO CHECK FOR COMBAT OVERTIME
  213. MOVE A,@USTP ; GET USTP FOR THIS JOB
  214. TLNN A,BUSRC ; TEST STOPPED BIT
  215. JRST DEMWIN ; DEMON IS WINNING: SEE IF THIS IS INTERESTING
  216. ; JOB IS NOW KNOWN TO BE DISOWNED AND STOPPED.
  217. SKIPGE WINCT(LOSTBL) ; HAVE WE DISABLED IT?
  218. POPJ P, ; YES
  219. SETZM BLTBEG ; NO, SO CLOBBER MAIL SWITCHES
  220. MOVE A,[BLTBEG,,BLTBEG+1]
  221. BLT A,BLTEND ; ZERO SWITCHES
  222. MOVE A,@UNAME
  223. MOVEM A,LUNAME ; SAVE DEAD JOB'S UNAME
  224. MOVE A,@JNAME
  225. MOVEM A,LJNAME ; AND JNAME
  226. MOVE A,@UPC ; AND UPC
  227. MOVEM A,BADUPC
  228. PUSHJ P,GETJOB ; OWN JOB
  229. JRST WINCHK
  230. PUSHJ P,VALCHK ; CHECK FOR .VALUE
  231. WINCHK: PUSHJ P,WINNER ; GO SEE IF I'M A LOSER
  232. JRST DISABL ; YES, SO DISABLE ME
  233. CAMN DEM,[SIXBIT /COMSYS/]
  234. JRST COMHAK
  235. CAMN DEM,[SIXBIT /BATCHN/]
  236. JRST BATHAK ; SPECIAL HACKS REQUIRED FOR BATCHN
  237. CAMN DEM,[SIXBIT /ZONE/]
  238. JRST ZONHK1 ; AND COMBAT
  239. SETOM GUNNED
  240. .UCLOSE USRO, ; FLUSH JOB
  241. JFCL
  242. .CALL DEMSIG ; SIGNAL NEW ONE
  243. JFCL
  244. MOVEI A,0
  245. PUSHJ P,SNDMAL ; SEND MAIL
  246. POPJ P, ; AND LEAVE
  247. ; COME HERE TO DISABLE DEMON IF CHOMPING: LEAVE IT AROUND, SEND SPECIAL MAIL.
  248. DISABL: SETOM LEFT ; SAY WE LEFT JOB AROUND
  249. SETOM WINCT(LOSTBL) ; CLOBBER ENTRY IN TABLE
  250. MOVEI A,0
  251. PUSHJ P,SNDMAL
  252. .DISOWN USRI,
  253. POPJ P, ; AND DEPART
  254. ; COME HERE IF DEMON IS UP AND RUNNING: POSSIBLY HACK ITS LOSTBL ENTRY.
  255. DEMWIN: AOSG A,WINCT(LOSTBL) ; INCREASE # OF WINNAGES
  256. JRST RECONS ; DEMON WAS DISABLED LAST TIME, SO WE NEED TO RE-INIT
  257. SKIPE @FLSINS ; IS IT REALLY RUNNING?
  258. JRST DMRUN ; SEE IF SLEEP OR HANG
  259. DMWON: AOS DEMCT(LOSTBL) ; NUMBER OF SURVEYS WHEN DEMON UP AND RUNNING
  260. CAIG A,4 ; MORE THAN 4 WINS AND STILL AROUND?
  261. POPJ P, ; LET IT GO
  262. ; RE-INITIALIZE DEMON'S BLOCK, EITHER AFTER RECONSAGE OR AFTER NUMEROUS WINNAGES
  263. RECONS: SETZM WINCT(LOSTBL)
  264. HRLZI A,WINCT(LOSTBL)
  265. HRRI A,WINCT+1(LOSTBL)
  266. BLT A,LOSLEN-1(LOSTBL)
  267. AOS WINCT(LOSTBL)
  268. POPJ P,
  269. DMRUN: MOVE O,@LSUUO
  270. TLZ O,777 ; TURN OFF AC FIELDS AND INDIRECT BIT
  271. CAME O,[.SLEEP] ; SLEEPING?
  272. CAMN O,[.HANG] ; HANGING?
  273. JRST [SOS WINCT(LOSTBL) ; DON'T COUNT THIS
  274. POPJ P,]
  275. JRST DMWON ; SEE IF TIME TO RECONS
  276. SUBTTL STATS CODE
  277. ; LSINIT TAKES A DEMON NAME IN DEM, AND FINDS OR ALLOCATES A BLOCK FOR IT
  278. ; IN LOSBLK, WITH A POINTER TO SAME IN LOSTBL.
  279. LSINIT: MOVE LOSTBL,[-LOSLEN*LOSCNT,,LOSBLK]
  280. LSILOP: CAMN DEM,DEMNAM(LOSTBL) ; HAVE WE FOUND THE RIGHT BLOCK?
  281. POPJ P, ; YES, SO FLUSH
  282. SKIPN (LOSTBL) ; IS THIS BLOCK EMPTY?
  283. JRST [MOVEM DEM,DEMNAM(LOSTBL)
  284. POPJ P,] ; YES, SO WIN ANYWAY
  285. ADD LOSTBL,[LOSLEN,,LOSLEN]
  286. JUMPL LOSTBL,LSILOP
  287. .VALUE ; WE JUST RAN OUT OF SPACE
  288. ; WINNER UPDATES THE TABLE ENTRY OF THE CURRENT DEMON, WHICH IS KNOWN TO BE
  289. ; DEAD. THIS INVOLVES SAVING THE DATA IN THE TABLE FOR IT, AND DECIDING
  290. ; WHETHER THE DEMON SHOULD STAY DOWN. IF THE DEMON SHOULD NOT STAY DOWN
  291. ; (IF THE DEMON IS A WINNER), WINNER SKIPS.
  292. WINNER: PUSH P,A
  293. PUSH P,B
  294. PUSH P,C
  295. PUSH P,D
  296. SKIPE A,WINCT(LOSTBL)
  297. JRST [CAIL A,3
  298. SOS WINCT(LOSTBL)
  299. JRST .+1] ; SO THIS LOSSAGE WON'T GET RECYCLED NEXT TIME
  300. AOS A,LOSCT(LOSTBL)
  301. SUBI A,1
  302. IMULI A,DATLEN
  303. ADDI A,DATST(LOSTBL) ; POINT TO NEXT DATA BLOCK IN ENTRY
  304. MOVE B,@UPC ; GET PC
  305. MOVEM B,LOSPC(A)
  306. .CALL [SETZ ; SAVE AWAY TIME OF LOSSAGE
  307. SIXBIT /RQDATE/
  308. SETZM LOSTM(A)]
  309. .LOSE 1000
  310. MOVE A,LOSCT(LOSTBL)
  311. CAIG A,1
  312. JRST WINWIN ; ONLY ONE LOSS. LET IT LIVE.
  313. CAIL A,4
  314. JRST WINOUT ; FOUR LOSSES. FLUSH IT.
  315. ; THE NUMBER OF LOSSES IS NOW KNOWN TO BE 2 OR 3.
  316. MOVE B,WINCT(LOSTBL)
  317. CAIL B,4
  318. JRST WINWIN ; FOUR WINS. DON'T FLUSH IT.
  319. CAIG B,1
  320. JRST WINOUT ; 0 OR 1 WINS. FLUSH IT.
  321. HRRZ B,DATST+LOSPC(LOSTBL) ; GET FIRST LOSING PC
  322. HRRZ C,DATST+DATLEN+LOSPC(LOSTBL)
  323. CAIN B,(C)
  324. JRST WINOUT ; WE HAVE TWO PC'S THE SAME, SO FLUSH
  325. HRRZ D,DATST+<2*DATLEN>+LOSPC(LOSTBL)
  326. CAIN B,(D)
  327. JRST WINOUT
  328. CAIN C,(D)
  329. JRST WINOUT
  330. WINWIN: AOS -4(P)
  331. WINOUT: POP P,D
  332. POP P,C
  333. POP P,B
  334. POP P,A
  335. POPJ P,
  336. SUBTTL COMSYS CODE
  337. COMHAK: SKIPN GOTJOB
  338. POPJ P,
  339. MOVE B,[.RIOC+1,,C] ; IOC IS NORMALLY ZERO FOR CLOSED CHANNEL
  340. CCHNLP: .USET USRO,B
  341. JUMPE C,CCHNLE
  342. LDB D,[220400,,B] ; CHANNEL NUMBER
  343. LSH D,27
  344. IOR D,[.CLOSE]
  345. MOVEM D,EXBLK
  346. MOVEI E,CHNKIL
  347. PUSHJ P,INFEXE ; DO THE CLOSE
  348. CCHNLE: ADD B,[1,,0]
  349. TLNE B,17
  350. JRST CCHNLP
  351. MOVE A,@OPTION ; CHECK THE OPTION WORD
  352. TLNN A,OPTLOK
  353. JRST COMDON
  354. .CALL [SETZ
  355. SIXBIT /USRVAR/
  356. MOVEI USRO
  357. MOVEI .ROPTIO
  358. MOVEI 0
  359. SETZ [TLZ OPTLOK]]
  360. .VALUE
  361. HRRZ A,@40ADDR
  362. ADDI A,3
  363. .ACCESS USRI,A
  364. MOVE B,[-2,,C]
  365. .IOT USRI,B ; READ IN LOCS 43 & 44
  366. MOVEM D,LOC44
  367. SETOM MPVFLG ; IF CHOMPAGE OCCURS, WE'LL KNOW WHY
  368. JUMPE C,UNLOK2 ; NO LOCKS--GO TO CRITICAL CODE
  369. MOVEI A,(C)
  370. MOVEI E,LOKKIL
  371. MOVEI F,1000
  372. UNLOK1: .ACCESS USRI,A
  373. MOVE B,[-2,,C]
  374. .IOT USRI,B
  375. TLNN D,-1
  376. HRLI D,476000
  377. HLL A,D ; CONS THE OPCODE INTO A (WHERE THE ADDRESS LIVES)
  378. MOVEM A,EXBLK
  379. PUSHJ P,INFEXE ; DO THIS UNLOCK
  380. TRNN D,-1
  381. JRST UNLOK2
  382. HRRZ A,D
  383. SOJG F,UNLOK1 ; STOP AFTER 512, REGARDLESS
  384. UNLOK2: SKIPN A,LOC44 ; PICK UP AOBJN POINTER
  385. JRST COMDON
  386. HRRZ F,@UPC
  387. UNLOKL: MOVE B,[-2,,C]
  388. .ACCESS USRI,A
  389. .IOT USRI,B
  390. CAIL F,(C) ; BEFORE END OF CRITICAL SECTION?
  391. JRST UNLOKE
  392. HLRZS C
  393. CAIGE F,(C) ; AFTER BEGINNING?
  394. JRST UNLOKE
  395. MOVEM D,EXBLK
  396. PUSHJ P,INFEXE ; DO THE UNLOCK
  397. UNLOKE: ADD A,[2,,2]
  398. JUMPL A,UNLOKL
  399. COMDON: SETZM MPVFLG
  400. PUSHJ P,DISJO1
  401. MOVE A,COMNAM+1
  402. PUSHJ P,SNDMAL
  403. POPJ P,
  404. SUBTTL BATCHN CODE
  405. ; COME HERE TO HACK BATCHN: CLOSES INFERIORS AND SCRIPT, LEAVES CORPSE
  406. ; AROUND DISOWNED.
  407. BATHAK: SETOM BATCH
  408. SKIPN GOTJOB ; GOT JOB?
  409. POPJ P, ; FAILED. OH, WELL.
  410. MOVE B,[.RIOS+1,,C] ; GET WORD FOR USETTING .IOS
  411. BCHNLP: .USET USRO,B ; GET IOS IN C
  412. LDB C,[IOSDEV,,C] ; GET DEVICE CODE IN C
  413. CAIN C,SNUSR
  414. PUSHJ P,INFFLS ; GO FLUSH INFERIOR
  415. CAIN C,SN2311
  416. PUSHJ P,CHNFLS ; GO FLUSH CHANNEL (IF WRITE/WRITE-OVER MODE)
  417. ADD B,[1,,0] ; AOS CHANNEL NUMBER
  418. TLNE B,17 ; SEE IF ALL DONE
  419. JRST BCHNLP
  420. PUSHJ P,DISJOB ; DO DISOWN AND START NEW ONE.
  421. MOVE A,BATNAM+1
  422. PUSHJ P,SNDMAL ; SEND MAIL
  423. POPJ P, ; AND DEPART
  424. ; FLUSH INFERIOR OPEN ON CHANNEL SPECIFIED IN LOW 4 BITS OF LH OF B.
  425. ; STUFF .UCLOSE ? .BREAK ? .BREAK IN STARTING AT LOC 26, START JOB
  426. ; THERE (AFTER TURNING OFF ALL INTERRUPTS).
  427. INFFLS: LDB D,[220400,,B] ; GET CHANNEL NUMBER IN D
  428. LSH D,27 ; INTO AC FIELD
  429. IOR D,[.UCLOSE]
  430. MOVEM D,EXBLK
  431. MOVEI E,INFKIL
  432. ; ALTHOUGH THIS ROUTINE IS NORMALLY JRSTED TO (AND DOES A POPJ), THE PERCEPTIVE
  433. ; OBSERVER WILL NOTICE THAT IF WE PUSHJ TO IT, IT WILL TASTEFULLY POPJ AND
  434. ; WE MAY CONTINUE FROBBING. IPCOFF DOES SO.
  435. INFEXE: PUSH P,D
  436. MOVE D,[-EXLEN,,EXBLK]
  437. .ACCESS USRO,[26] ; ACCESS TO SUITABLE LOCATION
  438. .IOT USRO,D ; STUFF IT IN
  439. .USET USRO,[.RPIRQC,,IPIRQC]
  440. .USET USRO,[.RIFPIR,,IIFPIR]
  441. .USET USRO,[.RMSK2,,IMASK2]
  442. .USET USRO,[.RMASK,,IMASK]
  443. .USET USRO,[.SPIRQC,,[0]]
  444. .USET USRO,[.SIFPIR,,[0]]
  445. .USET USRO,[.SMSK2,,[0]]
  446. .USET USRO,[.SMASK,,[0]] ; SAVE & CLEAR INTERRUPTS
  447. .USET USRO,[.RUPC,,G]
  448. .USET USRO,[.SUPC,,[26]] ; SET PC
  449. SETOM INFRUN
  450. .USET USRO,[.SUSTP,,[0]] ; START JOB (WILL INTERRUPT WHEN DONE)
  451. SKIPE INFRUN
  452. .HANG
  453. SKIPE MPVFLG
  454. JRST [.USET USRO,[.RPIRQC,,D]
  455. JRST .+1]
  456. .USET USRO,[.SPIRQC,,IPIRQC]
  457. .USET USRO,[.SIFPIR,,IIFPIR]
  458. .USET USRO,[.SMASK,,IMASK]
  459. .USET USRO,[.SMSK2,,IMASK2] ; RESTORE INTERRUPTS
  460. .USET USRO,[.SUPC,,G] ; RESTORE PC
  461. SKIPE MPVFLG
  462. JRST [TDNN D,[%PIWRO+%PIMPV]
  463. JRST .+1
  464. POP P,D
  465. SUB P,[1,,1]
  466. JRST COMDON] ; FLUSH IF JOB GOT ERROR
  467. AOS (E) ; ADD 1 TO FROBS KILLED
  468. POP P,D
  469. POPJ P, ; DEPART
  470. ; HERE TO FLUSH SCRIPT CHANNEL IF EXISTS. GETS FILE NAME FROM SYSTEM,
  471. ; IF IT'S 'NBATCH LOG', THEN DOES CLOSE.
  472. CHNFLS: LDB D,[220400,,B] ; GET CHANNEL NUMBER
  473. .CALL [SETZ ; GET FILE NAME
  474. SIXBIT /RFNAME/
  475. MOVEI USRO ; JOB
  476. D ; CHANNEL #
  477. MOVEM
  478. MOVEM E
  479. SETZM F]
  480. POPJ P, ; GIVE UP
  481. CAME E,[SIXBIT /NBATCH/]
  482. POPJ P,
  483. CAME F,[SIXBIT /LOG/]
  484. POPJ P,
  485. LSH D,27
  486. IOR D,[.CLOSE]
  487. MOVEM D,EXBLK ; STUFF .CLOSE OUT
  488. MOVEI E,CHNKIL
  489. JRST INFEXE ; AND GO DO IT.
  490. ; CLOSE IPC CHANNEL IF EXISTS, SO WILL BE ABLE TO MUDINQ AT NEW DEMON. THIS
  491. ; IS CALLED BY DISJOB.
  492. IPCOFF: PUSH P,A
  493. PUSH P,B
  494. PUSH P,C
  495. PUSH P,D
  496. PUSH P,E
  497. MOVEI E,C ; HACK, HACK
  498. MOVE A,[.RIOS+1,,B]
  499. IPCLOP: .USET USRO,A
  500. LDB C,[000600,,B] ; ISOLATE DEVICE CODE
  501. CAIN C,SNMSP ; IPC DEVICE?
  502. JRST IPCOF1 ; YES, GO CLOSE IT
  503. IPCCON: ADD A,[1,,0]
  504. TLNE A,17 ; CHECKED ALL CHANNELS?
  505. JRST IPCLOP ; NO
  506. POP P,E
  507. POP P,D
  508. POP P,C
  509. POP P,B
  510. POP P,A
  511. POPJ P,
  512. IPCOF1: LDB C,[220400,,A] ; GET CHANNEL NUMBER
  513. LSH C,27
  514. IOR C,[.CLOSE] ; CONS UP .CLOSE
  515. MOVEM C,EXBLK
  516. PUSHJ P,INFEXE ; GO TO ROUTINE
  517. JRST IPCCON ; AND LOOK FOR MORE.
  518. SUBTTL COMBAT CODE
  519. ; CHECK TO SEE IF COMBAT RAN OVERTIME: MORE THAN WHATEVER RUNTIMER WAS SET FOR.
  520. ZONHAK: CAME DEM,[SIXBIT /ZONE/]
  521. JRST DEMWIN
  522. MOVE B,@UTRNTM ; GET RUN TIME
  523. CAMG B,[250000.*60.*5] ; GREATER THAN FIVE MINUTES? (START-UP)
  524. JRST DEMWIN ; NO
  525. SKIPLE @RTIMER ; SEE IF NO RUNTIME INTERRUPT ENABLED.
  526. JRST DEMWIN ; STILL ENABLED, SO GO AWAY.
  527. SETZM BLTBEG
  528. MOVE A,[BLTBEG,,BLTBEG+1]
  529. BLT A,BLTEND ; CLEAR BLOCK
  530. SETOM GUNNED
  531. SETOM OVERTI
  532. MOVE A,@UNAME
  533. MOVEM A,LUNAME
  534. MOVE A,@JNAME
  535. MOVEM A,LJNAME
  536. JRST ZONHK2
  537. ; FLUSH COMBAT, RENAME APPROPRIATE PLAN, ETC.
  538. ZONHK1: SKIPN GOTJOB
  539. SETOM GUNNED
  540. ZONHK2: SETOM COMBAT
  541. HLRO A,LUNAME
  542. CAMN A,[-1] ; WAS THE CROCK LOGGED IN?
  543. JRST RESTAR
  544. MOVE A,PLNNAM
  545. RNMLP: .CALL [SETZ ; DON'T CHASE LINKS
  546. SIXBIT /OPEN/
  547. [.UAI+<1_4>,,DSKI]
  548. [SIXBIT /DSK/]
  549. (A)
  550. [SIXBIT /</]
  551. SETZ [SIXBIT /COMBAT/]]
  552. JRST [AOBJN A,RNMLP
  553. JRST RESTAR]
  554. .CALL [SETZ
  555. SIXBIT /FILBLK/
  556. MOVEI DSKI
  557. MOVEM FN1
  558. MOVEM FN2
  559. SETZM A]
  560. .LOSE 1000
  561. TLNE A,1 ; TEST LINK BIT
  562. JRST
  563. MOVEI C,INBLEN
  564. MOVE D,INBPTR
  565. .CALL [SETZ
  566. SIXBIT /SIOT/
  567. MOVEI DSKI
  568. D
  569. SETZ C]
  570. .LOSE 1000
  571. MOVEI C,INBLEN
  572. MOVE D,INBPTR
  573. NMLOOP: ILDB E,D
  574. CAIN E,"" ; LOOK FOR QUOTES
  575. JRST RNMNAM
  576. SOJGE C,NMLOOP
  577. JRST RESTAR ; DIDN'T FIND IT, SO GO TO RESTART
  578. RNMNAM: MOVE F,[440600,,G]
  579. MOVEI G,0
  580. SIXLOP: ILDB E,D
  581. CAIN E,""
  582. JRST SIXLP1
  583. SUBI E,40
  584. CAIL E,100
  585. SUBI E,40
  586. IDPB E,F
  587. TLNE F,770000
  588. JRST SIXLOP
  589. SIXLP1: MOVEM G,LOSER ; SO THE CHOMPER CAN BE TOLD.
  590. DORENM: .CALL [SETZ
  591. SIXBIT /RENAME/
  592. [SIXBIT /DSK/]
  593. FN1
  594. FN2
  595. [SIXBIT /COMBAT/]
  596. [SIXBIT /GUNNED/]
  597. SETZ [SIXBIT />/]]
  598. JRST RESTAR
  599. SKIPN LOSER
  600. JRST RESTAR
  601. .CALL [SETZ
  602. SIXBIT /RFNAME/
  603. MOVEI DSKI
  604. MOVEM
  605. MOVEM
  606. SETZM RFN2]
  607. .LOSE 1000
  608. ; COME HERE TO SEND OUT MAIL AND RESTART DEMON.
  609. RESTAR: SKIPN GUNNED
  610. PUSHJ P,DISJOB
  611. MOVE A,ZONNAM+1 ; GET NAME TO SEND TO
  612. PUSHJ P,SNDMAL
  613. POPJ P,
  614. SUBTTL UTILITIES
  615. ; UTILITIES FOR OWNING AND DISOWNING JOBS.
  616. ; GETJOB: TRY TO CONS UP (AS AN INFERIOR) THE JOB WHOSE JNAME IS IN DEM
  617. ; AND WHOSE SYSTEM INDEX IS IN U. IF SUCCEED, SKIP.
  618. GETJOB: PUSH P,A
  619. PUSH P,B
  620. PUSH P,C
  621. MOVE A,U
  622. IDIV A,L ; GET USER INDEX IN A
  623. ADDI A,400000
  624. .CALL [SETZ ; TRY TO OPEN FOR WRITING
  625. SIXBIT /OPEN/
  626. [.BIO,,USRO]
  627. [SIXBIT /USR/]
  628. A
  629. SETZI 0]
  630. JRST GETOUT ; FAILED
  631. .CALL [SETZ
  632. SIXBIT /OPEN/
  633. [.BII,,USRI]
  634. [SIXBIT /USR/]
  635. A
  636. SETZI 0]
  637. JRST GETOUT
  638. .CALL [SETZ ; GET JOB NAMES, ETC.
  639. SIXBIT /RFNAME/
  640. MOVEI USRI
  641. MOVEM
  642. MOVEM DUNAME
  643. MOVEM DJNAME
  644. MOVEM
  645. SETZM C]
  646. JRST GETOUT
  647. TRNE C,<1_3> ; SEE IF REALLY INFERIOR
  648. JRST GETOUT
  649. SETOM GOTJOB
  650. AOS -3(P)
  651. JRST GETPOP
  652. GETOUT: .CLOSE USRI,
  653. .CLOSE USRO,
  654. GETPOP: POP P,C
  655. POP P,B
  656. POP P,A
  657. POPJ P,
  658. ; COME HERE TO DISOWN CURRENT JOB, AND START UP NEW DEMON (NAME IS IN DEM)
  659. DISJOB: PUSHJ P,IPCOFF ; NEED TO CLOSE ANY IPC CHANNELS THAT ARE AROUND
  660. DISJO1: .DISOWN USRI,
  661. JFCL
  662. .CALL [SETZ
  663. SIXBIT /STDMST/
  664. DEM
  665. [-1]
  666. SETZI 0]
  667. JFCL
  668. .CALL DEMSIG
  669. JFCL
  670. POPJ P,
  671. DEMSIG: SETZ
  672. SIXBIT /DEMSIG/
  673. DEM
  674. SETZI 0
  675. ; IF JOB .VALUE'ED, GET THE STRING IT SENT. PUT LENGTH IN VALLEN, STRING
  676. ; IN VALBUF.
  677. VALCHK: PUSH P,A
  678. PUSH P,B
  679. PUSH P,C
  680. MOVE B,@SV40 ; HAS LAST UUO, WITH EFFECTIVE ADDRESS
  681. LDB A,[301400,,B] ; GET OPCODE IN B
  682. CAIE A,0432 ; FOR .VALUE
  683. JRST VALCOT
  684. GETVST: TLZ B,-1 ; TURN OFF LH, LEAVING ONLY EFFECTIVE ADDRESS
  685. JUMPE B,VALCOT
  686. .ACCESS USRI,B
  687. MOVE A,[-VALBLN,,VALBUF]
  688. .IOT USRI,A
  689. MOVE B,[440700,,VALBUF]
  690. MOVEI A,0
  691. VALLOP: ILDB C,B
  692. JUMPE C,VALLOT
  693. AOJA A,VALLOP
  694. VALLOT: MOVEM A,VALLEN
  695. VALCOT: POP P,C
  696. POP P,B
  697. POPAJ: POP P,A
  698. POPJ P,
  699. SUBTTL MAIL ROUTINES
  700. ; SEND THE RIGHT MAIL TO ALL THE RIGHT PEOPLE.
  701. SNDMAL: MOVEM P,SNDSAV ; TO ALLOW RECOVERY FROM IOC ERRORS
  702. JUMPE A,GETNAM ; IF NO NAME PROVIDED, SEARCH FOR IT.
  703. SNDML1: PUSH P,[SIXBIT /MAIL/] ; NAME TWO
  704. PUSH P,A ; NAME ONE
  705. PUSH P,A ; SNAME
  706. PUSHJ P,APTOFI ; GET TO END OF MAIL FILE
  707. POPJ P,
  708. SOUT DSKO,[
  709. From GUNNER ]
  710. PUSHJ P,DTPRNT
  711. SOUT DSKO,[
  712. ]
  713. MOVE A,LUNAME
  714. PUSHJ P,SXPRNT
  715. .IOT DSKO,[" ]
  716. MOVE A,LJNAME
  717. PUSHJ P,SXPRNT
  718. SKIPE LEFT ; DEMON CHOMPED?
  719. JRST OBIT
  720. SKIPE OVERTI ; COMBAT RAN OVERTIME?
  721. JRST [SOUT DSKO,[ ran two hours.]
  722. JRST SNDFAT]
  723. SOUT DSKO,[ died.]
  724. SKIPE B,VALLEN
  725. JRST [SOUT DSKO,[
  726. .VALUE with UPC ]
  727. MOVE A,BADUPC
  728. PUSHJ P,OCPRNT
  729. SOUT DSKO,[:
  730. ]
  731. MOVE A,[440700,,VALBUF]
  732. .CALL [SETZ
  733. SIXBIT /SIOT/
  734. MOVEI DSKO
  735. A
  736. SETZ B]
  737. .LOSE 1000
  738. SOUT DSKO,[
  739. ]
  740. JRST SNDFAT]
  741. SOUT DSKO,[
  742. PC was ]
  743. MOVE A,BADUPC
  744. PUSHJ P,OCPRNT
  745. SNDFAT: SKIPE GUNNED
  746. JRST [SOUT DSKO,[
  747. ]
  748. JRST COMCHK]
  749. SOUT DSKO,[ Disowned as ]
  750. MOVE A,DUNAME
  751. PUSHJ P,SXPRNT
  752. .IOT DSKO,[" ]
  753. MOVE A,DJNAME
  754. PUSHJ P,SXPRNT
  755. SOUT DSKO,[.
  756. ]
  757. SKIPN A,LOKKIL
  758. JRST CKBAT
  759. PUSHJ P,DCPRNT
  760. SOUT DSKO,[ lock]
  761. MOVE A,LOKKIL
  762. CAIN A,1
  763. .IOT DSKO,["s]
  764. SOUT DSKO,[ unlocked.
  765. ]
  766. CKBAT: SKIPN A,CHNKIL
  767. JRST CKBAT1
  768. PUSHJ P,DCPRNT
  769. SOUT DSKO,[ channel]
  770. MOVE A,CHNKIL
  771. CAIN A,1
  772. .IOT DSKO,["s]
  773. SOUT DSKO,[ closed.
  774. ]
  775. CKBAT1: SKIPN BATCH
  776. JRST COMCHK
  777. SKIPN A,INFKIL
  778. JRST SNDDON
  779. PUSHJ P,DCPRNT
  780. SOUT DSKO,[ inferior]
  781. MOVE A,INFKIL
  782. CAIN A,1
  783. .IOT DSKO,["s]
  784. SOUT DSKO,[ killed.
  785. ]
  786. JRST SNDDON
  787. COMCHK: SKIPN COMBAT
  788. JRST SNDDON
  789. SKIPN A,FN1
  790. JRST SNDDON
  791. PUSHJ P,SXPRNT
  792. .IOT DSKO,[" ]
  793. MOVE A,FN2
  794. PUSHJ P,SXPRNT
  795. SOUT DSKO,[ renamed to ]
  796. MOVE A,[SIXBIT /GUNNED/]
  797. PUSHJ P,SXPRNT
  798. .IOT DSKO,[" ]
  799. MOVE A,RFN2
  800. PUSHJ P,SXPRNT
  801. SOUT DSKO,[.
  802. ]
  803. SNDDON: .IOT DSKO,[^_]
  804. .CLOSE DSKO,
  805. SKIPN SNDTWO
  806. JRST [SETOM SNDTWO ; SEND MAIL TO TAA
  807. MOVE A,[SIXBIT /TAA/]
  808. JRST SNDML1]
  809. SKIPN COMBAT
  810. JRST SNDPPJ
  811. SKIPN A,LOSER
  812. JRST SNDPPJ
  813. SETZM LOSER
  814. JRST SNDML1
  815. SNDPPJ: SETZM SNDSAV
  816. POPJ P,
  817. ; GENERATE MESSAGE FOR REALLY DEAD DEMON
  818. OBIT: PUSH P,A
  819. PUSH P,B
  820. PUSH P,C
  821. SOUT DSKO,[ lost completely. Disowned as ]
  822. MOVE A,DUNAME
  823. PUSHJ P,SXPRNT
  824. .IOT DSKO,[" ]
  825. MOVE A,DJNAME
  826. PUSHJ P,SXPRNT
  827. .IOT DSKO,[".]
  828. SOUT DSKO,[
  829. Losing times and pc's were:
  830. ]
  831. MOVEI C,DATST(LOSTBL)
  832. MOVE B,LOSCT(LOSTBL)
  833. LPLOOP: MOVE A,LOSTM(C)
  834. PUSHJ P,DTPRN1 ; ENTRY TO DTPRNT FOR ARGUMENT
  835. SOUT DSKO,[, ]
  836. MOVE A,LOSPC(C)
  837. PUSHJ P,OCPRNT
  838. SOUT DSKO,[
  839. ]
  840. SOJLE B,LPDONE
  841. ADDI C,DATLEN
  842. JRST LPLOOP
  843. LPDONE: POP P,C
  844. POP P,B
  845. POP P,A
  846. JRST SNDDON
  847. ; FIND SOMEONE TO SEND TO
  848. GETNAM: PUSH P,B
  849. MOVE B,OWNPTR
  850. GETNLP: CAMN DEM,(B)
  851. JRST [MOVE A,1(B)
  852. POP P,B
  853. JRST SNDML1]
  854. ADD B,[2,,2]
  855. JUMPL B,GETNLP
  856. MOVE A,[SIXBIT /MB/]
  857. POP P,B
  858. JRST SNDML1
  859. ; UTILITIES FOR WRITING FILE: APPEND TO FILE, DATE PRINTER, SIXBIT PRINTER,
  860. ; NUMBER PRINTERS.
  861. ; PRINT SUPPLIED DATE ON DSKO
  862. DTPRN1: PUSH P,A
  863. PUSH P,B
  864. PUSH P,C
  865. PUSH P,D
  866. MOVE B,A
  867. JRST DTPRN2
  868. ; PRINT DATE ON DSKO
  869. DTPRNT: PUSH P,A
  870. PUSH P,B
  871. PUSH P,C
  872. PUSH P,D
  873. .CALL [SETZ ; GET DATE
  874. SIXBIT /RQDATE/
  875. SETZM B]
  876. .LOSE 1000
  877. DTPRN2: HRRZ C,B
  878. IDIVI C,7200. ; HOURS SINCE MIDNIGHT IN C
  879. MOVE A,C
  880. CAIG A,9.
  881. .IOT DSKO,["0]
  882. PUSHJ P,DCPRNT
  883. .IOT DSKO,[":]
  884. MOVE C,D
  885. IDIVI C,120. ; MINUTES SINCE BEGINNING OF HOUR
  886. MOVE A,C
  887. CAIG A,9.
  888. .IOT DSKO,["0]
  889. PUSHJ P,DCPRNT
  890. .IOT DSKO,[":]
  891. ASH D,-1
  892. MOVE A,D
  893. CAIG A,9.
  894. .IOT DSKO,["0]
  895. PUSHJ P,DCPRNT
  896. .IOT DSKO,[" ]
  897. LDB A,[270400,,B] ; MONTH
  898. PUSHJ P,DCPRNT
  899. .IOT DSKO,["/]
  900. LDB A,[220500,,B]
  901. PUSHJ P,DCPRNT ; DAY
  902. .IOT DSKO,["/]
  903. LDB A,[330700,,B]
  904. PUSHJ P,DCPRNT
  905. POP P,D
  906. POP P,C
  907. POP P,B
  908. POP P,A
  909. POPJ P,
  910. POPJ P,
  911. ; SIXBIT IS IN A. PRINT IT.
  912. SXPRNT: PUSH P,B
  913. PUSH P,C
  914. MOVE C,[440600,,A]
  915. SXPLOP: ILDB B,C
  916. JUMPE B,SXPOUT
  917. ADDI B,40
  918. .IOT DSKO,B
  919. TLNE C,770000
  920. JRST SXPLOP
  921. SXPOUT: POP P,C
  922. POP P,B
  923. POPJ P,
  924. ; OCTAL STUFF IS IN A.
  925. OCPRNT: PUSH P,B
  926. PUSH P,C
  927. CAILE A,777777
  928. JRST OCPRN1
  929. MOVE C,OCTTAB
  930. JRST DCPLP1
  931. OCPRN1: MOVE B,A
  932. HLRZ A,B
  933. PUSHJ P,OCPRNT
  934. SOUT DSKO,[,,]
  935. HRRZ A,B
  936. PUSHJ P,OCPRNT
  937. POP P,C
  938. POP P,B
  939. POPJ P,
  940. ; DECIMAL STUFF IS IN A.
  941. DCPRNT: PUSH P,B
  942. PUSH P,C
  943. MOVE C,POWTAB
  944. DCPLP1: IDIV A,(C)
  945. JUMPE A,[MOVE A,B
  946. AOBJN C,DCPLP1
  947. .IOT DSKO,["0]
  948. JRST DCPOUT]
  949. DCPLP2: ADDI A,"0
  950. .IOT DSKO,A
  951. AOBJN C,[MOVE A,B
  952. IDIV A,(C)
  953. JRST DCPLP2]
  954. DCPOUT: POP P,C
  955. POP P,B
  956. POPJ P,
  957. PT: 1000000. ? 100000. ? 10000. ? 1000. ? 100. ? 10. ? 1.
  958. POWTAB: PT-.,,PT
  959. OT: 1000000 ? 100000 ? 10000 ? 1000 ? 100 ? 10 ? 1
  960. OCTTAB: OT-.,,OT
  961. ; OPEN <FOO>;<BAR> <BLETCH>, WHERE ARGS ARE (P), -1(P), -2(P). SKIPS IF SUCCESSFUL.
  962. APTOFI: PUSH P,B
  963. PUSH P,C
  964. PUSH P,D
  965. PUSH P,E
  966. MOVNI B,2
  967. MOVEM B,APCNT
  968. APTOF1: .CALL [SETZ
  969. SIXBIT /OPEN/
  970. [.BII,,DSKI]
  971. [SIXBIT /DSK/]
  972. MOVE -6(P)
  973. MOVE -7(P)
  974. MOVE -5(P)
  975. SETZB B]
  976. JRST APERCK
  977. .CALL [SETZ
  978. SIXBIT /FILLEN/
  979. MOVEI DSKI
  980. SETZM C]
  981. .LOSE 1000
  982. JUMPE C,APREOP
  983. SUBI C,2
  984. .ACCESS DSKI,C
  985. MOVE B,[-2,,RNDBLK]
  986. .IOT DSKI,B
  987. MOVE B,[440700,,RNDBLK]
  988. MOVEI E,0
  989. ENDLOP: ILDB D,B
  990. JUMPE D,APREOP
  991. CAIN D,^C
  992. JRST APREOP
  993. AOJA E,ENDLOP
  994. APREOP: .CLOSE DSKI,
  995. .CALL [SETZ
  996. SIXBIT /OPEN/
  997. [.UAO+100000,,DSKO]
  998. [SIXBIT /DSK/]
  999. MOVE -6(P)
  1000. MOVE -7(P)
  1001. MOVE -5(P)
  1002. SETZB B]
  1003. JRST IMGFLD
  1004. JUMPE C,APDONE
  1005. IMULI C,5
  1006. ADDI C,(E)
  1007. .ACCESS DSKO,C
  1008. APWON: AOS -4(P) ; WON, SO SKIP
  1009. APDONE: POP P,E
  1010. POP P,D
  1011. POP P,C
  1012. POP P,B
  1013. POP P,A
  1014. SUB P,[3,,3]
  1015. JRST (A)
  1016. ; COME HERE IF FIRST OPEN FAILED. CODE IS IN B.
  1017. APERCK: CAIE B,%ENSFL ; FILE NOT FOUND?
  1018. JRST APDONE ; NO, SO CHOMP IMMEDIATE.
  1019. .CALL [SETZ
  1020. SIXBIT /OPEN/
  1021. [.UAO,,DSKO]
  1022. [SIXBIT /DSK/]
  1023. MOVE -6(P)
  1024. MOVE -7(P)
  1025. MOVE -5(P)
  1026. SETZB B]
  1027. JRST APDONE
  1028. JRST APWON
  1029. ; COME HERE IF OPEN FOR WRITE-OVER FAILED.
  1030. IMGFLD: AOSLE APCNT ; WE'RE ONLY ALLOWED TO TRY TWICE
  1031. JRST APDONE ; OH, WELL
  1032. MOVEI B,10.*30.
  1033. .SLEEP B,
  1034. JRST APTOF1 ; AND TRY AGAIN.
  1035. SUBTTL INITIALIZATION
  1036. ; SET UP FOR DEBUGGING--STOP GUNNER IF UP; KEEP IT FROM COMING UP IF
  1037. ; NOT
  1038. DEBUG: .CALL [SETZ
  1039. SIXBIT /OPEN/
  1040. [.BII,,USRI]
  1041. [SIXBIT /USR/]
  1042. [SIXBIT /GUNNER/]
  1043. SETZ [SIXBIT /GUNNER/]]
  1044. JRST KEEPDN
  1045. .USET USRI,[.RUIND,,A] ; GET USER INDEX
  1046. IMUL A,L
  1047. ADD A,USTP1 ; LOCATION OF USTP WORD
  1048. HRLI A,[0 ? BUSRC,,0] ; BLOCK FOR IFSET
  1049. .IFSET A,
  1050. .LOSE 1000
  1051. KEEPDN: .CALL [SETZ
  1052. SIXBIT /OPEN/
  1053. [.BIO,,DSKO]
  1054. [SIXBIT /DSK/]
  1055. [SIXBIT /GUNNER/]
  1056. [SIXBIT /DOWN/]
  1057. SETZ [SIXBIT /COMBAT/]]
  1058. .LOSE 1400
  1059. .CLOSE DSKO,
  1060. POPJ P,
  1061. ; COME HERE TO DO PROPER STDMST'S, ETC., DECIDE IF DEMON SHOULD STAY
  1062. ; UP (SKIP IF IT SHOULD).
  1063. ; DEMON IS DEFINED TO RUN FROM 6PM-9AM, WEEKENDS, HOLIDAYS. COMPUTES
  1064. ; TIME REQUIRED TO RUN UNTIL IT KNOWS IT SHOULD GO DOWN. BEFORE
  1065. ; GOING DOWN, IT CHECKS AGAIN.
  1066. SETUP: PUSH P,A
  1067. PUSH P,B
  1068. PUSH P,C
  1069. PUSH P,D
  1070. .CALL [SETZ
  1071. SIXBIT /OPEN/
  1072. [.BII,,DSKI]
  1073. [SIXBIT /DSK/]
  1074. [SIXBIT /GUNNER/]
  1075. [SIXBIT /DOWN/]
  1076. SETZ [SIXBIT /COMBAT/]]
  1077. JRST SETUP2 ; FILE DOESN'T EXIST, SO MIGHT COME UP
  1078. .CLOSE DSKI,
  1079. JRST SETUPO
  1080. SETUP2: .CALL [SETZ
  1081. SIXBIT /RQDATE/
  1082. SETZM A]
  1083. .LOSE 1000
  1084. HRRZ B,A
  1085. CAIL B,2*3600.*18. ; IS IT PAST 6 PM?
  1086. JRST [MOVEI C,2*3600.*24.
  1087. SUB C,B ; NUMBER OF HALF-SECS LEFT TODAY
  1088. ADDI C,<2*3600.*9.>+<120.*14.>
  1089. JRST SETUP1] ; HAVE # HALF-SECONDS TO STAY UP, SO GO DO IT.
  1090. CAIGE B,2*3600.*9. ; BEFORE 9AM?
  1091. JRST [MOVEI C,<2*3600.*9.>+<120.*14.>
  1092. SUB C,B
  1093. JRST SETUP1]
  1094. .RYEAR A,
  1095. LDB A,[320300,,A] ; GET DAY OF WEEK
  1096. JUMPE A,WEKEND
  1097. CAIN A,6
  1098. JRST WEKEND
  1099. .RDATE A,
  1100. .CALL [SETZ
  1101. SIXBIT /OPEN/
  1102. [.BII,,DSKI]
  1103. [SIXBIT /DSK/]
  1104. [SIXBIT /HLIDAY/]
  1105. A
  1106. SETZ [SIXBIT /COMBAT/]]
  1107. JRST STDOWN
  1108. .CLOSE DSKI,
  1109. WEKEND: MOVEI C,<2*3600.*24.>+<2*3600.*9.>+<120.*14.>
  1110. SUB C,B
  1111. ; NUMBER OF HALF-SECONDS TO STAY UP IS IN C.
  1112. SETUP1: IMULI C,15. ; CONVERT TO 30THS
  1113. MOVEM C,TIMLFT ; TIME LEFT TO RUN
  1114. .CALL [SETZ
  1115. SIXBIT /STDMST/
  1116. [SIXBIT /GUNNER/]
  1117. [<24.*30.>,,1]
  1118. SETZI <24.*30.>]
  1119. .LOSE 1000
  1120. AOS -4(P)
  1121. SETUPO: POP P,D
  1122. POP P,C
  1123. POP P,B
  1124. POP P,A
  1125. POPJ P,
  1126. ; COME HERE IF WANT TO STAY DOWN.
  1127. STDOWN: MOVEI A,<18.*2.*3600.>+<2*120.> ; SIX PM+EPSILON
  1128. SUB A,B ; HALF-SEC UNTIL 6
  1129. IDIVI A,240. ; TWO MIN. UNTIL 6
  1130. .CALL [SETZ
  1131. SIXBIT /STDMST/
  1132. [SIXBIT /GUNNER/]
  1133. [<24.*30.>,,0]
  1134. SETZ A]
  1135. .LOSE 1000
  1136. JRST SETUPO
  1137. ; MAP IN SYSTEM, EVAL SYMBOLS, PDUMP.
  1138. ; THERE ARE CURRENTLY THREE CLASSES OF SYMBOLS:
  1139. ; THE FIRST, USER VARIABLES, ARE SAVED WITH U IN THE LEFT HALF; WE INDIRECT
  1140. ; THROUGH THEM TO PICK UP THE CURRENT JOB'S VARIABLES. 400000 IS ADDED TO
  1141. ; THESE
  1142. ; MEMBERS OF THE SECOND GROUP ARE SPECIAL (DEMON TABLE STUFF)
  1143. ; MEMBERS OF THE THIRD GROUP AREN'T AFFECTED BY WHERE THE SYSTEM IS MAPPED
  1144. ; IN: L, PRIMARILY.
  1145. INIT: MOVEM A,SYSVER
  1146. MOVE A,USRVAR
  1147. USRLOP: MOVE B,(A)
  1148. .EVAL B,
  1149. .VALUE
  1150. ADDI B,400000
  1151. HRLI B,U
  1152. MOVEM B,1(A)
  1153. ADD A,[2,,2]
  1154. JUMPL A,USRLOP
  1155. MOVE A,SYSLOC
  1156. SYSLOP: MOVE B,(A)
  1157. .EVAL B,
  1158. .VALUE
  1159. ADDI B,400000
  1160. MOVEM B,1(A)
  1161. ADD A,[2,,2]
  1162. JUMPL A,SYSLOP
  1163. MOVE A,SYSCON
  1164. SYSCLP: MOVE B,(A)
  1165. .EVAL B,
  1166. .VALUE
  1167. MOVEM B,1(A)
  1168. ADD A,[2,,2]
  1169. JUMPL A,SYSCLP
  1170. HRLS DMTLL ; MAKE DMTLL BE FOO,,FOO
  1171. MOVN A,DMLNG
  1172. HRLI A,(A)
  1173. HRR A,DMTTBL
  1174. MOVEM A,DEMTAB ; AOBJN POINTER TO DEMON TABLE
  1175. MOVE A,[-200,,200]
  1176. MOVEI B,0
  1177. .CALL [SETZ
  1178. SIXBIT /CORBLK/
  1179. MOVEI %CBRED
  1180. MOVEI %JSELF
  1181. A
  1182. MOVEI %JSABS
  1183. SETZ B]
  1184. .LOSE 1000
  1185. JRST BEGIN
  1186. ; TABLES FOR EVAL
  1187. ; GROUP 1: VALUE SAVED HAS U IN LH, 400000 ADDED.
  1188. USRTAB: SQUOZE 0,APRC
  1189. APRC: 0
  1190. SQUOZE 0,USTP
  1191. USTP: 0
  1192. SQUOZE 0,UNAME
  1193. UNAME: 0
  1194. SQUOZE 0,JNAME
  1195. JNAME: 0
  1196. SQUOZE 0,UTRNTM ; RUN TIME
  1197. UTRNTM: 0
  1198. SQUOZE 0,FLSINS
  1199. FLSINS: 0
  1200. SQUOZE 0,LSUUO
  1201. LSUUO: 0 ; LAST UUO EXECUTED
  1202. SQUOZE 0,UPC
  1203. UPC: 0
  1204. SQUOZE 0,RTIMER
  1205. RTIMER: 0
  1206. SQUOZE 0,SV40
  1207. SV40: 0
  1208. SQUOZE 0,OPTION
  1209. OPTION: 0
  1210. SQUOZE 0,40ADDR
  1211. 40ADDR: 0
  1212. USRVAR: USRTAB-.,,USRTAB
  1213. ; GROUP 2: VALUE SAVED HAS 400000 ADDED. REFERS TO ABSOLUTE LOCATIONS IN SYSTEM
  1214. SYSTAB: SQUOZE 0,DMTTBL
  1215. DMTTBL: 0
  1216. SYSLOC: SYSTAB-.,,SYSTAB
  1217. ; GROUP 3: LOCATION-INDEPENDENT VALUES
  1218. SYSCTB: SQUOZE 0,L
  1219. L: 0
  1220. SQUOZE 0,DMLNG
  1221. DMLNG: 0
  1222. SQUOZE 0,DMTLL
  1223. DMTLL: 0
  1224. SQUOZE 0,USTP
  1225. USTP1: 0 ; UNMODIFIED VALUE, FOR DOING IFSETS
  1226. SYSCON: SYSCTB-.,,SYSCTB
  1227. DEMTAB: 0 ; AOBJN POINTER TO DEMON TABLE
  1228. SUBTTL RANDOMNESS
  1229. ADDRS: -3,,.+1
  1230. GPSPTR
  1231. -11,,F
  1232. GGPPTR
  1233. -11,,20
  1234. GBSPTR
  1235. -11,,32
  1236. GOT: 0
  1237. GOT1: 0
  1238. GOTCT: 0
  1239. IOFF=MAPBEG
  1240. GPSPTR=IOFF+5
  1241. GGPPTR=IOFF+17
  1242. GBSPTR=IOFF+31
  1243. IDSPTR=IOFF+602
  1244. AMAZE=IOFF+665
  1245. UNMPTR=IOFF+1757
  1246. MSCAN: MOVEI A,400002 ; MAYBE SOMEDAY THIS WILL BE HAND-CRAFTED
  1247. SETZM GOT
  1248. LOOP: .CALL [SETZ
  1249. SIXBIT /CORBLK/
  1250. MOVEI %CBNDW
  1251. MOVEI %JSELF
  1252. MOVEI MAPPAG
  1253. A
  1254. SETZI 2]
  1255. JRST LOOP1
  1256. MOVE B,ADDRS
  1257. TSTLUP: MOVE O,1(B)
  1258. MOVE C,(B)
  1259. CAME O,(C)
  1260. JRST LOOP1
  1261. AOS B
  1262. AOBJN B,TSTLUP
  1263. GOTIT: MOVE D,[START,,GPSPTR]
  1264. BLT D,GBSPTR
  1265. SETOM GOT
  1266. SETOM GOT1
  1267. AOS GOTCT
  1268. PUSH P,[SIXBIT /LOADED/]
  1269. PUSH P,[SIXBIT /_TTYS_/]
  1270. PUSH P,[SIXBIT /IMLAC/]
  1271. PUSHJ P,APTOFI
  1272. JRST MSCHED ; OH, WELL
  1273. .RDATI A,
  1274. PUSHJ P,SXPRNT
  1275. .IOT DSKO,[" ]
  1276. MOVE A,B
  1277. PUSHJ P,SXPRNT
  1278. SOUT DSKO,[ I got: ]
  1279. SKIPN C,UNMPTR
  1280. MOVE C,IDSPTR
  1281. ADDI C,IOFF
  1282. UNMLUP: MOVE A,(C)
  1283. JUMPE A,UNMLU1
  1284. PUSHJ P,SXPRNT
  1285. .IOT DSKO,[" ]
  1286. UNMLU1: AOBJN C,UNMLUP
  1287. SOUT DSKO,[
  1288. ]
  1289. .CLOSE DSKO,
  1290. .CALL [SETZ
  1291. SIXBIT /CORBLK/
  1292. MOVEI 0
  1293. MOVEI %JSELF
  1294. SETZI MAPPAG]
  1295. .LOSE 1000
  1296. JRST MSCHED
  1297. LOOP1: CAIGE A,400000+60.
  1298. AOJA A,LOOP
  1299. MSCHED: SKIPE GOT
  1300. JRST [MOVEI A,<300.*30.> ; FIVE MINUTES
  1301. JRST MSCHE1]
  1302. SKIPE GOT1
  1303. JRST [SETZM GOT1 ; IF GOT ONE LAST TIME, SCHED FOR FIVE MIN AGAIN
  1304. MOVEI A,<300.*30.>
  1305. JRST MSCHE1]
  1306. .RTIME A,
  1307. CAMGE A,[SIXBIT /060000/]
  1308. JRST MNIGHT
  1309. CAMG A,[SIXBIT /210000/]
  1310. JRST MWEEKN
  1311. MNIGHT: MOVEI A,<1800.*30.> ; THIRTY MINUTES
  1312. JRST MSCHE1
  1313. MWEEKN: MOVEI A,<7200.*30.> ; TWO HOURS
  1314. MSCHE1: MOVEM A,INTRVL(PBLOCK) ; STUFF IT OUT
  1315. POPJ P,
  1316. SUBTTL INTERRUPT HANDLER
  1317. TSINT: 0
  1318. TSINTR: 0
  1319. EXCH A,TSINT
  1320. JUMPL A,TSWRD2
  1321. TRNN A,%PIIOC ; IOC INTERRUPT?
  1322. JRST TSMPVQ
  1323. SKIPN SNDSAV ; WRITING TO DISK?
  1324. JRST FATAL1 ; NO, SO CHOMP
  1325. .DISMIS [.+1]
  1326. .CLOSE DSKI, ; FLUSH EVERYTHING
  1327. .CLOSE DSKO,
  1328. MOVE P,SNDSAV
  1329. SETZM SNDSAV
  1330. EXCH A,TSINT
  1331. POPJ P,
  1332. TSMPVQ: SKIPN MPVFLG
  1333. JRST FATAL
  1334. EXCH A,TSINT
  1335. .DISMIS [COMDON] ; FORGET IT
  1336. FATAL:
  1337. FATAL1: .VALUE
  1338. TSWRD2: TLNN A,377 ; INFERIOR INTERRUPT
  1339. JRST TSOUT
  1340. .USET USRO,[.RPIRQC,,A]
  1341. TRNN A,%PIBRK
  1342. JRST [TDNN A,[%PIWRO+%PIPAR+%PIMPV+%PIILO]
  1343. JRST FATAL
  1344. JRST TSMPVQ] ; IF INFERIOR GOT SOMETHING LIKE THIS, UNLOCK CHECK
  1345. SETZM INFRUN
  1346. TSOUT: EXCH A,TSINT
  1347. .DISMIS TSINTR
  1348. END START
  1349.