.dsabl gbl .psect ; this is the code that gets run when login spawns itself ; at exit. Please note that the buffer checks done by the ; peeks at offset 10 and 12 into the KBDDDB could change ; in a future release of RSTS. .macro kbpeek offset,result ; this macro is used by the mov offset ,-(sp) ; code that tries to run a call .kbpeek ; login command file from .if nb, result ; a spawned login .ift ; look at various offsets in mov (sp)+ ,result ; the spawner's kb ddb .iff mov (sp)+ ,r0 .endc .endm .macro clrfqb call fqbzap .endm .macro clrxrb call xrbzap .endm .asect . = 0 sp.jdb: .blkw 1 ; jdb addr of job who spawned sp.kb: .blkw 1 ; kb# of login that spawned us sp.j2: .blkw 1 ; job number times 2 sp.job: .blkw 1 ; job number sp.ddb: .blkw 1 ; kb ddb from previous login sp.fir: .blkw 1 ; flag word .psect global <.priv> jb.st = 12 ; offset for jbstat word uu.sys jb.wa = 14 ; offset for kbwait word uu.sys .psect work ,rw,d,gbl,rel,ovr work:: .blkw 20 .psect frc:: save clr @12(r5) mov #work ,r4 mov @6(r5) ,sp.job(r4) mov sp.job(r4),sp.j2(r4) ; get spawner's jn * 2 asl sp.j2(r4) ; save the job number times2 ;- clr sp.fir(r4) ; flag for first time thru call 200$ ; get the jdb address so we bcs 110$ ; no (job went away then) mov firqb+32,sp.jdb(r4) ; check for job going away. beq 110$ ; no job is there now mov sp.jdb(r4),xrb+0 ; get the other job's kbddb .priv ,.peek ; twice into the iob .priv ,.peek ; at last mov xrb+0 ,sp.ddb(r4) ; and save it movb firqb+5 ,sp.kb(r4) ; and save it 10$: call 200$ ; get the current job status bcs 110$ ; oops cmp firqb+32,sp.jdb(r4) ; see if it is the same job bne 110$ ; could not possibly be kbpeek #2 ,r1 ; look into the kb ddb for kbpeek #6 ; check if job is attached. cmpb sp.j2(r4),r1 ; is this the same job here? bne 110$ ; no bit #8192. ,r0 ; yes, but is the job attached? beq 110$ ; no, so exit kbpeek #10. ,r1 ; check for tt wait by checking tstb firqb ; error? bne 110$ ; yes kbpeek #12. ; buffer chain status out. cmp r1 ,r0 ; have things cleared up now ? bne 20$ ; no, wait a little while then bit #2 ,firqb+jb.wa ; waiting for terminal input? beq 20$ ; no bit firqb+jb.st,firqb+jb.wa ; what about the 'runnability'? beq 30$ ; yes, ready for force a line. 20$: mov #1 ,xrb+0 ; not yet ready, sleep a little mov #1 ,@12(r5) ; br 100$ .priv ,.sleep ; a short nap please br 10$ ; next please 30$: kbpeek #8. ; check for control c hit tst @10(r5) ; but is this the first time? beq 40$ ; yes bit #1 ,r0 ; check that bit now beq 110$ ; time to stop 40$: mov 2(r5) ,r2 ; force it now mov @4(r5) ,r0 call send ; inc @10(r5) ; not the first time anymore 100$: unsave clc return 110$: sec ; abort here mov #-1 ,@12(r5) unsave return 200$: clrfqb ; get job's current status movb #uu.sys ,firqb+fqfun ; need jbstat,jbwait movb sp.job(r4),firqb+fqfun+1; job number goes here incb firqb+fqfun+2 ; subfunction code 1 .priv ,.uuo ; do a job systat now tstb firqb ; set error bits in psw beq 210$ ; no error sec ; error 210$: return .kbpeek:mov sp.ddb(r4),xrb+0 ; return a value from KBDDDB add 2(sp) ,xrb+0 ; simple to do .priv ,.peek ; return a value mov xrb+0 ,2(sp) ; on top of the passed offset return send: 230$: mov r2 ,xrb+xrloc ; the address of the text mov r0 ,xrb+xrbc ; the number of bytes to send beq 240$ ; nothing to send here mov #5 ,xrb+xrlen ; Function code for TTYDVR. clr xrb+xrci ; Chan*2 doesn't do anything movb #ttyhnd ,xrb+xrci+1 ; Device handler index mov sp.kb(r4),xrb+10 ; Keyborad number in binary .priv .spec ; Call special function tst xrb+2 ; anything at all get sent? beq 240$ ; it all got sent cmp xrb+2 ,r0 ; nothing at all ? beq 240$ ; abort then sub xrb+2 ,r0 ; try to send the rest of it add r0 ,r2 ; and back again br 230$ ; next please 240$: return xrbzap: save ; clear out the xrb for .mesag mov #xrb ,r0 10$: clr (r0)+ cmp r0 ,#xrb+xrmod+2 bne 10$ unsave return fqbzap: save ; clear out the xrb for .mesag mov #firqb ,r0 10$: clr (r0)+ cmp r0 ,#firqb+40+2 bne 10$ unsave return .end