.TITLE VTMWRT - WRITE TO FILE/TERMINALS .IDENT /01.5/ .ENABL LC ;+ ; ; Free software BY ; Project Software & Development, Inc. ; ; This software is furnished for free and may be used and copied as ; desired. This software or any other copies thereof may be provided or ; otherwise made available to any other person. No title to and ; ownership of the software is hereby transferred or allowed. ; ; The information in this software is subject to change without notice ; and should not be construed as a commitment by PROJECT SOFTWARE ; AND DEVELOPMENT, INC. ; ; PROJECT SOFTWARE assumes no responsibility for the use or reliability ; of this software on any equipment whatsoever. ; ; Project Software & Development, Inc. ; 14 Story St. ; Cambridge, Ma. 02138 ; 617-661-1444 ; ; ; Title: VTMWRT.MAC ; Author: Robin Miller ; Date: Jupy 14, 1982 ; ; Description: ; ; Writes the VTM message to a file and/or terminals. ; ; ; Modification History: ; ;- .ENABL AMA .NLIST BEX .MCALL PUT$, QIOW$S ; Macro to generate error message. .MACRO ERRMSG LABEL,MSG .NCHR $$$, .PSECT $ERMSG,RO,D,REL,CON LABEL: .ASCII "MSG" .EVEN .PSECT MOV #LABEL,R1 MOV #$$$,R2 CALL OUTMSG .ENDM ; Local equates: ON = 1 ; ENABLED FLAG OFF = 0 ; DISABLED FLAG ; Offsets for output table entrys: O.FLAG = 0 ; ENABLED / DISABLED O.FDB = 2 ; OFFSET TO FDB O.LUN = 4 ; OFFSET TO LUN O.EFN = 5 ; OFFSET TO EFN ; Output table: OTABLE:: TENTRY::.WORD ON ; LOCAL TERMINAL ENTRY .WORD TOFDB ; TERMINAL OUTPUT FDB .BYTE TOLUN,TOEFN ; TERMINAL LUN / EFN ENTSIZ = .-TENTRY ; SIZE OF EACH ENTRY FENTRY:: ; OUTPUT FILE ENTRY .WORD OFF ; INITIALLY DISABLED .WORD OUTFDB ; OUTPUT FILE FDB .BYTE OUTLUN,OUTEFN ; OUTPUT FILE LUN / EFN AENTRY:: ; ADDITION TERMINAL ENTRYS .WORD OFF ; INITIALLY DISABLED .WORD 0 ; NO FDB, MUST BE A TERMINAL .BYTE TTYLUN,TTYEFN ; TERMINAL LUN / EFN .WORD -1 ; END OF TABLE (FOR NOW) NENTRY::.WORD AENTRY+ENTSIZ ; NEXT TABLE ENTRY TTYST: .BYTE TC.TTP ; GET TERMINAL TYPE TTYPE: .BYTE 0 ; AND STORE IT HERE TTYSIZ = .-TTYST ; SIZE OF STATUS TABLE .SBTTL WRTMSG - CALCULATE COUNT AND WRITE MESSAGE ;+ ; ; WRTMSG - Calculate the byte count and write the message. ; ; Inputs: ; BUFPTR = the updated output buffer address. ; ; Outputs: ; BUFPTR = starting address of message buffer. ; ; All registers are preserved. ; ;- WRTMSG::JSR R2,$SAVVR ; SAVE R0 - R2 CALL SETBUF ; SET THE BUFFER AND COUNT MOV R1,BUFPTR ; RESET THE BUFFER POINTER TST R2 ; IS THERE A BYTE COUNT ? BEQ 10$ ; IF EQ, DON'T SKIP WRITE CALL WRITIT ; WRITE IT TO THE TERMINAL BIC #B.CLR,STATUS ; ONLY CLEAR SCREEN ONCE 10$: RETURN .SBTTL WRITIT - WRITE THE MESSAGE TO THE TERMINAL ;+ ; ; WRITIT - Write the message to the terminal and/or file. ; ; Inputs: ; R1 = the buffer address. ; R2 = the buffer byte count. ; ; Outputs: ; Carry clear/set = success/failure. ; ; All registers are preserved. ; ;- WRITIT::CALL $SAVAL ; SAVE R0 - R5 MOV R1,BUFADR ; SAVE THE BUFFER ADDRESS MOV R2,BYTCNT ; AND THE BUFFER BYTE COUNT MOV #OTABLE,R3 ; START OF THE OUTPUT TABLE ; Loop through list of output devices. 10$: BIT #B.CTRC,STATUS ; WAS CTRL/C TYPED ? BNE 100$ ; IF NE, YES (RETURN) TST (R3) ; END OF THE TABLE ? BMI 100$ ; IF MI, YES BGT 30$ ; IF GT, ENABLED 20$: ADD #ENTSIZ,R3 ; POINT TO NEXT ENTRY BR 10$ ; AND CHECK NEXT ENTRY ; Output to this device (terminal or file). 30$: CALL SETUP ; SETUP AND DO OUTPUT BR 20$ ; AND CONTINUE ... 100$: RETURN .SBTTL WRTTTY - WRITE MESSAGE TO TERMINAL ;+ ; ; WRTTTY - Write message to the terminal only. ; ; This routine presumes the message to output is in MSGBUF. ; ; Inputs: ; R1 = the buffer address. ; R2 = the buffer byte count. ; ; Outputs: ; All registers are preserved. ; ;- WRTTTY:: CALL $SAVAL ; SAVE R0 - R5 MOV #TENTRY,R3 ; TERMINAL OUTPUT ENTRY ; MOV (R3),-(SP) ; SAVE STATUS (INCASE DISABLED) ; MOV #ON,(R3) ; ENABLE TERMINAL OUTPUT CALL SETUP ; SETUP AND WRITE MESSAGE ; MOV (SP)+,(R3) ; RESTORE ORIGINAL STATUS RETURN ; Same as WRTTTY except write it to the output file. WRTFIL:: CALL $SAVAL ; SAVE R0 - R5 MOV #FENTRY,R3 ; OUTPUT FILE ENTRY CALL SETUP ; SETUP AND WRITE MESSAGE RETURN .SBTTL SETBUF - SET BUFFER AND BYTE COUNT ;+ ; ; SETBUF - Set the buffer address and byte count. ; ; Inputs: ; BUFPTR = the updated message buffer pointer. ; ; Outputs: ; R1 = the message buffer address. ; R2 = the buffer byte count. ;- SETBUF:: MOV #MSGBUF,R1 ; SET THE BUFFER ADDRESS MOV BUFPTR,R2 ; COPY UPDATED BUFFER POINTER SUB R1,R2 ; CALCULATE THE BYTE COUNT RETURN .SBTTL SETUP - SETUP FOR PUT$ OR QIO$ ;+ ; ; SETUP - Setup for PUT$ or QIO$. ; ; This routine is called to setup the LUN and EFN for a PUT$ or QIO$. ; If the output LUN is assigned to a terminal, a QIO$ is used otherwise ; a PUT$ is used to write the message. ; ; Inputs: ; R1 = the buffer address. ; R2 = the buffer byte count. ; R3 = device entry to output to. ; ; Outputs: ; R0 is destroyed. ; ;- .ENABL LSB SETUP:: TST (R3) ; DEVICE ENABLED ? BEQ 100$ ; IF EQ, NO (DO NOTHING) MOVB O.LUN(R3),LUN ; COPY THE LUN MOVB O.EFN(R3),EFN ; COPY THE EFN MOV O.FDB(R3),R0 ; COPY THE FDB ADDRESS BEQ 10$ ; IF EQ, THERE IS NONE BITB #FD.TTY,F.RCTL(R0) ; ARE WE GOING TO A TERMINAL ? BNE 10$ ; IF NE, YES (USE QIO) ; Output to the file. CALL DOPUT ; NO, DO PUT TO FILE BCC 100$ ; IF CC, SUCCESS BR 90$ ; ERROR ENCOUNTERED ; Output to the terminal. 10$: QIOW$S #SF.GMC,LUN,EFN,,#TIOSB,,<#TTYST,#TTYSIZ> CALL CHKERR ; CHECK FOR ERRORS BCS 90$ ; IF CS, ERROR ; Insure the terminal is a VT100 family terminal. CMPB TTYPE,#T.V100 ; ARE WE ON A VT100 ? BEQ 20$ ; IF EQ, YES ; Range of VT100 terminals is T.V101 (24) through T.V132 (31). CMPB TTYPE,#T.V101 ; Is this possible VT100 family ? BLO 15$ ; If LO, no CMPB TTYPE,#T.V132 ; Really a VT100 family terminal ? BLOS 20$ ; IF LOS, yes 15$: ERRMSG NVT100,<%VTM-W-BADTTY, terminal is not of the VT100 family.> BR 90$ ; NOW DISABLE TERMINAL 20$: CALL DOQIO ; DO A QIO TO THE TERMINAL BCC 100$ ; IF CC, SUCCESS ; Disable the device when an error occurs. 90$: CLR (R3) ; ERROR, DISABLE THIS DEVICE SEC ; RETURN FAILURE STATUS 100$: RETURN .DSABL LSB .SBTTL DOQIO - DO A QIO TO A TERMINAL ;+ ; ; DOQIO - Do a QIO to a terminal. ; ; Inputs: ; R1 = the buffer addres ; R2 = the buffer byte count. ; LUN and EFN must be preset. ; ; Outputs: ; Carry bit clear/set = success/failure. ; ; All registers are preserved. ; ;- DOQIO:: QIOW$S FUNC,LUN,EFN,,#TIOSB,, CALL CHKERR ; CHECK/REPORT ANY ERRORS RETURN .SBTTL DOPUT - DO A PUT TO THE OUTPUT FILE ;+ ; ; DOPUT - Write a record to the output file. ; ; Inputs: ; R0 = the FDB address. ; R1 = the buffer address. ; R2 = the buffer byte count. ; ; Outputs: ; Carry bit clear/set = success/failure. ; ; All registers are preserved. ;- DOPUT:: CALL $SAVAL ; SAVE ALL REGISTERS PUT$ R0,R1,R2 ; WRITE THE OUTPUT RECORD BCC 10$ ; IF CC, SUCCESS MOV F.ERR(R0),-(SP) ; SAVE THE FCS ERROR CODE CALL CLOFIL ; CLOSE THE OUTPUT FILE MOV (SP)+,R0 ; COPY THE FCS ERROR CODE ; Output the error message (C bit set by WRTERR). CALL WRTERR ; REPORT THE ERROR MESSAGE 10$: RETURN .END