.Title TWAIT System Independent TWAIT Routine .Psect Alvin,Gbl,Con ;Edit History ; ;E06 25-Nov-85 dvj The need for checking for TSX-Plus has been removed. ; Only RT SJ needs to be detected. Therefore, the need ; to invoke .Serr has been removed. The TWait routine ; has been placed in the Alvin Psect. R0 is also now ; saved so that no registers are disrupted on return. ; ;E05 04-Apr-84 dfk Continuation of E04: Get the right bit this time. ;E04 01-Apr-84 dfk Change to issue TWAIT EMT if SJ Timer Support is ; sysgenned, since the $TIME words in the RMON offsets ; is not maintained in this case (Eric Dana's bug). ; ;E03 25-Feb-84 dfk Rewrite to NOT use the clock vector. Instead, watch ; the $TIME field in the RMON offsets until the requested ; amount of time has passed. This eliminates all the ; worry about Control-C's screwing up the clock vector. ; ;E02; Add a call to .GVAL to get RT-11's configuration word. ;E01; Add a test of the "SCCA" flag before the second ".SCCA" is issued. ; ; This subroutine does a TWAIT in a fashion thats independent of whether its ; running on RT11SJ (which does not support TWAIT), or on another version of ; RT-11 or on TSX-Plus (all of which support TWAIT). The $TWAIT macro is ; used to call this routine, and its parameter is a one-word count of clock ; ticks, which is (in USA) 65535/60 seconds, about 1Ksec or 16 2/3 minutes. ; ; The $TWAIT macro is used to call this routine-- ; .MACRO $TWAIT TimVal ; Use this sort of like RT-11 TWAIT. JSR R5,TWAIT ; Call twait routine. .WORD TimVal ; Single word time value. .ENDM RMON = 54 ; Address in low mem of RMON offsets. CONFIG = 300 ; System configuration bits. C.SJ = 1 ; If this bit is zero, its RT11SJ. $TIME = 320 ;E03; RT-11 only, offset of high order time. SYSGEN = 372 ;E04; RMON Offsets: Sysgen configuration word. TIMER$ = 2000 ;E04; SYSGEN Word: SJ Timer support is genned. .MCALL .SERR ;E03; Used to prevent illegal EMT's for TSX. .MCALL .MTPS ;E03; Used to SET the processor priority. .MCALL .GVAL ;E03; To access RMON offsets on RT11XM & TSX+. ;E06 .PSECT $TWAIT ;E03; Place into separate PSECT which links ; ;E03; into program just before its end. ; ; The $TWAIT macro calls this subroutine. ;E06 All registers remain intack on return. ; TWAIT:: Mov R0,-(SP) ;E06 Save the register which will be used. MOV (R5)+,$TW.TIM+2 ;E03; Set up the time value.. BEQ 300$ ;E03; Zero interval-- Return to caller. ;E06 .SERR ; Don't crap out on illegal EMT's. ;E06 MOV #TS.LIN,R0 ; Point to EMT parameter list. ;E06 EMT 375 ; Get TSX+ timesharing line #. Is it TSX+ ? ;E06 BCC 270$ ; Yes. Just do a TWAIT. CMP -(SP),-(SP) ;E03; Make room for parameter list on stack. .GVAL SP,#CONFIG ;E03; Get RT-11's configuration word. CMP (SP)+,(SP)+ ;E03; Eliminate parameter list from stack. BIT R0,#C.SJ ;E02; Is this RT11SJ ? BNE 270$ ; No. Just do a TWAIT. CMP -(SP),-(SP) ;E04; Make room for parameter list on stack. .GVAL SP,#SYSGEN ;E04; Get the sysgen configuration bitmask. CMP (SP)+,(SP)+ ;E04; Eliminate parameter list from stack. BIT R0,#TIMER$ ;E05; Is there "SJ Timer Support" ? BNE 270$ ;E04; Yes. Just do a TWAIT. ; ; The following code is the special case, being that it is for RT-11 SJ which ; does not support the TWAIT-- ; ; ; The following algorithm is used because it does not have to do double-word ; arithmetic, it does not need to go to priority seven for compares, and it ; is immune from missing-a-tick causing a wait of another 65536 ticks-- ; CLR -(SP) ;E03; Make room on stack for current time val. MOV @#RMON,R0 ;E03; Point to the RMON offsets. 200$: MOV $TIME+2(R0),(SP);E03; Get current low order time value. 220$: CMP $TIME+2(R0),(SP);E03; Has another tick gone by ? BEQ 220$ ;E03; No. Wait for it to happen. DEC $TW.TIM+2 ;E03; Use up a tick from interval parameter. BNE 200$ ;E03; Not yet done, go wait for another tick. TST (SP)+ ;E03; Done with comparison value time word. Br 300$ ;E06 will restore R0 which has been saved. 270$: MOV #$TW.2,R0 ; Point to Twait EMT parameter list. EMT 375 ; Go to sleep for a while. 300$: Mov (Sp)+,R0 ;E06 Restore the saved R0 for full reentrancy. RTS R5 ; Done. Return to caller. ;;******************************* $TW.2: .BYTE 0,24 ; Twait EMT parameter list. .WORD $TW.TIM ; Address of double-word time value in ticks. $TW.TIM:.WORD 0,0 ; This is the time value (high order zero). ;E06 TS.LIN: .BYTE 0,110 ; TSX+ EMT code: Get T/S line #. ;******************************** .End