.TITLE TCFLIO .ENABL LC ; ; Input output routine for the TCFL subroutine library ; ; AUTHOR: S.C. Cribbs (Technical Services Branch) ; Atomic Energy of Canada Ltd. Pinawa, Manitoba ; 83/05/15 version 2 .NLIST ; Conditional Assembly Definitions ; ONLY$O = 1 ;Assemble Only Output code ; MTT$Y = 1 ;Define for Multiterminal I/O ; USERBF = 1 ;Output routed to user's buffer ; TIME$R = 1 ;Monitor provides .MRKT Support (SJ) ; FBXM = 1 ;Use .TWAIT rather than .MRKT in FB & XM monitors .LIST .NLIST BEX,CND,MC .LIST ME ; The following symbols have been defined for this assembly: .IIF NDF ONLY$O, ONLY$O = 0 ;Assemble both Output & Input code .IIF NE ONLY$O, ONLY$O = 1 ;Assemble Output Only code .IIF NDF MTT$Y, MTT$Y = 0 .IIF NE MTT$Y, MTT$Y = 1 ;Multi-terminal I/O .IIF NDF USERBF, USERBF = 0 .IIF NE USERBF, USERBF = 1 ;Constructed strings returned in user's buffer .IIF GT MTT$Y+USERBF-1, .END ;ERROR--more than one I/O option requested .IF EQ MTT$Y+USERBF ;All I/O will be routed to the job's console .ENDC ;EQ MTT$Y+USERBF .IIF NDF FBXM, FBXM = 0 .IF EQ ONLY$O .IF NE FBXM FBXM = 1 ;Monitor provides .TWAIT support (FB & XM) TIME$R = 0 ;.MRKT support not required .IFF .IIF NDF TIME$R, TIME$R = 0 .IF NE TIME$R TIME$R = 1 ;Monitor provides .MRKT support (SJ) .IFF TIME$R = 0 ;Program simulates .MRKT support .ENDC ;NE TIME$R .ENDC ;NE FBXM .ENDC ;EQ ONLY$O .IF EQ MTT$Y JSW = 44 ;Job status word .IFF ERRBYT = 52 ;Monitor's error code storage .ENDC ;EQ MTT$Y .GLOBL OUTSTR,OUTTZ,OUTTZN ;Entry points .IF EQ ONLY$O .GLOBL IGTC,TSET,TRESET,TTMDE,FLUSHB ;Entry points .ENDC ;EQ ONLY$O .IF NE MTT$Y .GLOBL LUNTRM .ENDC ;NE MTT$Y .IF NE USERBF .GLOBL DFNBUF .ENDC ;NE USERBF .MCALL .RCTRLO .IF EQ USERBF .MCALL .PRINT .ENDC ;EQ USERBF .IF EQ MTT$Y .IF EQ ONLY$O .MCALL .TTINR .ENDC ;EQ ONLY$O .IFF .MCALL .MTPRNT,.MTRCTO,.EXIT .IF EQ ONLY$O .MCALL .MTGET,.MTSET,.MTIN .ENDC ;EQ ONLY$O .ENDC ;EQ MTT$Y .IF EQ ONLY$O .IF NE FBXM .MCALL .TWAIT .ENDC ;NE FBXM .IF NE TIME$R .MCALL .MRKT,.CMKT .ENDC ;NE TIME$R .ENDC ;EQ ONLY$O .PSECT USER$D RW,D,LCL,REL,CON ;Protect from USR swapping .IF NE MTT$Y EMTMTT: .BLKW 3 ;Multiterminal programmmed request workspace MTCHR: .BLKW 4 ;Terminal's characteristics block MTIBUF: .BLKW 1 ;.MTIN buffer ERRMSG: .ASCIZ /Multiterminal error (code=7) - program aborted/ .EVEN .ENDC ;NE MTT$Y .IF NE USERBF NMEBUF: .BLKW 1 ;Address of user's character buffer .ENDC ;NE USERBF .IF EQ ONLY$O XPIRED: .BLKW 1 ;Timing event indicator SAVE: .BLKW 1 ;Temporary storage of terminal characteristics .IF NE FBXM EMTTWT: .BYTE 0,24 ;.TWAIT request code .WORD TINT TINT: .WORD 0 ;Time-out period .WORD 12. ; = one fifth second .ENDC ;NE FBXM .IF NE TIME$R EMTMKT: .BYTE 0,22 ;.MRKT request code .WORD TINT .WORD TIMOUT .WORD 101010 EMTCMK: .BYTE 0,23 ;.CMKT request code .WORD 101010 .WORD 0 TINT: .WORD 0 ;Time-out period .WORD 60. ; = one second .ENDC ;NE TIME$R .ENDC ;EQ ONLY$O .PAGE .PSECT USER$I RW,I,LCL,REL,CON ;Pure code .NLIST ME .LIST MC .IF NE MTT$Y ; ; Define the multi-terminal port to be used for I/O ; ; Called from FORTRAN by: ; CALL LUNTRM(NPORT) ; where: ; NPORT - The number of the multi-terminal port to be used. ; ; Note: The calling program must request use of the terminal port ; from the monitor [CALL MTATCH(?)] before calling LUNTRM. LUNTRM: TST (R5)+ ;Skip over FORTRAN argument count .MTRCTO #EMTMTT,@(R5)+ ;Load "LUN" and verify terminal OK BCS MTTERR ;Jump if any error detected RETURN ;to caller ; ; Internally called routine to display a multi-terminal error code ; on the system console and then abort the program. ; MTTERR: MOV #ERRMSG+26.,R0 ;Load a pointer to message code byte MOVB @#ERRBYT,(R0)+ ;Get error code from monitor BISB #'0,-(R0) ;Convert to ASCII format .RCTRLO ;Make sure Console will receive .PRINT #ERRMSG ;Tell user the tale of woe .EXIT ;Abort program execution .PAGE .ENDC ;NE MTT$Y .IF NE USERBF ; ; Define the address of the user's buffer for TCFLO's returned strings ; ; Called from FORTRAN by: ; CALL DFNBUF(BUFFER) ; where: ; BUFFER - is a FORTRAN vector of appropriate length to handle ; the maximum string length to be returned. ; 81 bytes is a nice round number. ; DFNBUF: TST (R5)+ ;Skip over Fortran argument count MOV (R5)+,NMEBUF ;Preserve address of user's buffer RETURN ;to caller .PAGE .ENDC ;NE MTT$Y ; ; Device "somewhat" independent ASCIZ string output subroutine ; ; Called from FORTRAN by: ; CALL OUTTZ(STRING) !Append ; or ; CALL OUTTZN(STRING) !Do not append ; where ; STRING - is an ASCIZ character string (ends with a null). ; OUTTZ: TST (R5)+ ;Skip over FORTRAN's arg. count MOV (R5)+,R0 ;Load address of string to be ouptut BNE OUTSTR ;Send it OUTTZN: TST (R5)+ ;Skip over FORTRAN's arg. count MOV (R5)+,R0 ;Load address of string to be ouptut MOV R0,R2 ;Need a working copy of string pointer 1$: TSTB (R2)+ ;Walk thru - looking for null term. BNE 1$ ;Loop till located MOVB #200,-(R2) ;Replace it - No wanted CALL OUTSTR ;Subroutine Call to send string CLRB (R2)+ ;Replace clobbered null terminator RETURN ; to caller ; ; Internally called routine: OUTSTR ; ; Depending on code assembled, Send the string (pointed to by R0) ; to this job's console, the assigned terminal (Multi-terminal), or ; store it in the defined user's buffer. ; ; Registers used: R0,R1 .IF NE MTT$Y OUTSTR: MOV R0,R1 ;Preserve address of the string .MTPRNT #EMTMTT,R1 ;Output the string to the terminal BCS MTTERR ;Take action on error conditions .IFF .IF NE USERBF OUTSTR: MOV NMEBUF,R1 ;Get pointer to user's buffer MOVB #200,R2 ;Build terminator match code 1$: MOVB (R0)+,@R1 ;Install a character in the buffer CMPB R2,(R1)+ ;Copied the terminator char. yet? BNE 1$ ;Loop till done .IFF OUTSTR: .PRINT ;Output string pointed to by R0 .ENDC ;NE USERBF .ENDC ;NE MTT$Y RETURN .IF EQ ONLY$O .PAGE ; ; Empty the terminal's input buffer ; ; Called by FORTRAN: CALL FLUSHB ; ; FLUSHB: JSR PC,TSET ;Define required terminal settings .IF NE MTT$Y 1$: .MTIN #EMTMTT,#MTIBUF ;Get a char. from "LUN" .IFF 1$: .TTINR ;Get a character from console .ENDC ;NE MTT$Y BCC 1$ ;Loop till buffer empty JSR PC,TRESET ;Reset terminal to user's settings RETURN ; to caller ; ; Internally called subroutine: IGTC (called by LESCSQ) ; ; Depending on the code assembled, obtain a single character from ; either the program console or the allocated multi-terminal port. ; RT-11 special mode, no wait input is used, so timeout protection ; has been provided. When executing under the FB or XM monitors, ; the .TWAIT programmed request is used so as to be a good neighbor ; to other jobs on the system. The .MRKT programmed request can ; be defined for SJ monitors sysgened to support it. Finally, for ; those poor souls without even a LTC, IGTC will simulate timeout. ; For systems that use either .TWAIT or .MRKT, a default 1/5 second ; timeout period has been defined (symbol TINT). Simulated timeouts ; last ~1 second on an LSI-11/2 processor. ; .IF NE FBXM .IF NE MTT$Y IGTC: .MTIN #EMTMTT,#MTIBUF ;Get a char. from "LUN" .IFF IGTC: .TTINR ;Get a character from console .ENDC ;NE MTT$Y BCC 1$ ;Jump if a character received .TWAIT #EMTTWT ;Sleep for one fifth second .IF NE MTT$Y .MTIN #EMTMTT,#MTIBUF ;Get a char. from "LUN" .IFF .TTINR ;Get a character from console .ENDC ;NE MTT$Y BCC 1$ ;Jump if a character received SEC ;Declare error condition .IF NE MTT$Y RTS PC ;Error exit from IGTC 1$: MOVB MTIBUF,R0 ;Character must be returned in register RTS PC ;Return to LESCSQ .IFF 1$: RTS PC ;Return to LESCSQ .ENDC ;NE MTT$Y .IFF IGTC: MOV #1000,XPIRED ;Initialize I/O time-out indicator .IF NE TIME$R .MRKT #EMTMKT ;Monitor will time it for us .ENDC ;NE TIME$R .IF NE MTT$Y 1$: .MTIN #EMTMTT,#MTIBUF ;Get a char. from "LUN" .IFF 1$: .TTINR ;Get a character from console .ENDC ;NE MTT$Y BCC 2$ ;Jump if a character received .IF NE TIME$R TST XPIRED ;Check I/O time-out flag .IFF DEC XPIRED ;Count down number of loops till time-out .ENDC ;NE TIME$R BNE 1$ ;Unless I/O time-out, go look for char. again SEC ;Declare error condition RTS PC ;Error exit from IGTC 2$: .IF NE TIME$R MOV R0,R1 ;Preserve the input character .CMKT #EMTCMK ;Cancel timing event MOV R1,R0 ;Return the character to caller in R0 .ENDC ;NE TIME$R .IF NE MTT$Y MOVB MTIBUF,R0 ;Character must be returned in register .ENDC ;NE MTT$Y RTS PC ;Return to LESCSQ .IF NE TIME$R TIMOUT: CLR XPIRED ;Declare I/O time-out RTS PC ;End of completion routine .ENDC ;NE TIME$R .ENDC ;NE FBXM .PAGE ; Device "somewhat" independent routine to define terminals ; operating characteristics. ; ; Called from FORTRAN by: ; ; CALL TTMDE(IARG) ; where: ; IARG - Defines Terminal features wanted ; = 0 - Uppercase only, line mode, wait ; = 1 - Enable lowercase, line mode, wait ; = 2 - Uppercase only, Single Character, wait ; = 3 - Enable lowercase, Single Character, wait ; = 4 - Uppercase only, line mode, no wait ??? ; = 5 - Enable lowercase, line mode, no wait ??? ; = 6 - Uppercase only, Single Character, no wait ; = 7 - Enable lowercase, Single Character, no wait ; ; Note: IARG values of 3 or 4 are impractical - but may be set. ; TTMDE: TST (R5)+ ;Skip over FORTRAN argument count CLR R1 ;Init. bit mask workspace MOV @(R5)+,R0 ;Obtain the argument value ROR R0 ;Rotate low order bit into carry BCC 1$ ;Jump if not set BIS #40000,R1 ;Enable lowercase 1$: ROR R0 ;Rotate bit 2 into carry BCC 2$ ;Jump if not set BIS #10000,R1 ;Enable Single Character mode 2$: ROR R0 ;Rotate bit 3 into carry BCC 3$ ;Jump if not set BIS #100,R1 ;Enable No wait terminal mode 3$: CALL TSET ;Get present terminal characteristics BIC #50100,SAVE ;Clear out any feature set BIS R1,SAVE ;Set in the requested features BR TRESET ;Define new terminal characteristics .PAGE ; ; Internally called subroutine: TSET (called by LESCSQ) ; ; Depending on the code assembled, this routine will set bits on ; in either the job status word (JSW) or the terminal's control block ; (TCB). It is intended to be used to enable lowercase input, RT-11 ; Special mode (single character), and no wait for input conditions. ; The terminal's original operating conditions are preserved so that ; they may be restored by subroutine TRESET. ; ; .IF NE MTT$Y TSET: .MTGET #EMTMTT,#MTCHR ;Get terminal's characteristics BCC MTGOK ;Jump if no error MTTDSP: JMP MTTERR ;Dispatch to error routine MTGOK: MOV MTCHR,SAVE ;Preserve first word BIS #50100,MTCHR ;Set lowercase, no echo, nowait .MTSET #EMTMTT,#MTCHR ;Define new characteristics BCS MTTDSP ;Abort program on error .MTRCTO #EMTMTT ;Make sure conditions take effect now BCS MTTDSP ;Abort program on error .IFF TSET: MOV #JSW,R0 ;Load address of job status word MOV (R0)+,SAVE ;Preserve terminal's characteristics BIS #50100,-(R0) ;Set lowercase, no echo, nowait .RCTRLO ;Make sure conditions take effect now .ENDC ;NE MTT$Y RTS PC .IF NE MTT$Y TRESET: MOV SAVE,MTCHR ;Reload original characteristics .MTSET #EMTMTT,#MTCHR ;into terminal descriptor block BCS MTTDSP ;Abort program on error .MTRCTO #EMTMTT ;Make sure conditions take effect now BCS MTTDSP ;Abort program on error .IFF TRESET: MOV SAVE,@#JSW ;Reload original terminal conditions .RCTRLO ;Make sure conditions take effect now .ENDC ;NE MTT$Y RTS PC .ENDC ;EQ ONLY$O .END