;======================================================================== ;= = ;= Programmer: Hunter Goatley = ;= Program: IOMAC.MAR = ;= Language: VAX assembler => MACRO32 = ;= Purpose: Provide easy to use terminal I/O macros for = ;= MACRO-32 programs. = ;= Shop: WKU/ACRS = ;= System: VAX 11/785 VAX/VMS v4.2 = ;= Date: October 17, 1985 = ;= = ;======================================================================== ;= = ;= All routines called by these MACROS can be found in IOMOD.MAR. = ;= = ;= MACROS included: = ;= = ;= CLRSCRN ==> Clear VT100-compatible screen = ;= GET_LINE ==> Get input from SYS$COMMAND = ;= INITIO ==> Initialize terminal I/O = ;= PCHAR ==> Print a character to SYS$COMMAND = ;= PCRLF ==> Print a to SYS$COMMAND = ;= PLINE ==> Print a certain number of bytes = ;= POP01 ==> Pop R0 and R1 off of stack = ;= PRINT ==> Print bytes until 0 byte is found = ;= PRTMSG ==> Print a message to SYS$COMMAND = ;= PUSH01 ==> Push R1 and R0 onto stack = ;= PUSHADR ==> Push an address onto the stack = ;= TTYOUT ==> Print character stored in R0 = ;= = ;======================================================================== ;= = ;= Revision history: = ;= = ;= January 9, 1986 Added PUSH01, POP01, and TTYOUT macros = ;= = ;======================================================================== ; ;======================================================================== ;= = ;= PUSH01 and POP01 macros = ;= = ;= These macros are used to save registers 0 and 1. = ;= PUSH01 pushes R1, followed by R0. POP01 pops R0, then R1. = ;= = ;= Sample calls: = ;= = ;= PUSH01 = ;= POP01 ;= = ;======================================================================== ; .MACRO PUSH01 PUSHL R1 ; Save contents of R1 PUSHL R0 ; Save contents of R0 .ENDM PUSH01 ; .MACRO POP01 MOVL (SP)+,R0 ; Restore contents of R0 MOVL (SP)+,R1 ; Restore contents of R1 .ENDM POP01 ; ;======================================================================== ;= = ;= PUSHADR macro = ;= = ;= This MACRO pushes an address onto the user stack (determining = ;= if a symbolic address was supplied or if deferred addressing = ;= is used and pushes accordingly). = ;= = ;= Sample calls: = ;= = ;= PUSHADR BUFFER = ;= or = ;= PUSHADR (R9) = ;= = ;======================================================================== ; .MACRO PUSHADR ADDR .IF NE %LOCATE(<(>,)-%LENGTH() PUSHAB ADDR .IF_FALSE PUSHAL ADDR .ENDC .ENDM PUSHADR ; ; ;======================================================================== ;= = ;= INITIO macro = ;= = ;= This MACRO initializes terminal I/O (assigns an I/O channel = ;= to SYS$COMMAND. = ;= = ;= Sample call: = ;= = ;= INITIO = ;= = ;======================================================================== ; .MACRO INITIO PUSH01 ; Save R1 and R0 CALLS #0,IO_INIT ; Initialize the I/O POP01 ; Restore R0 and R1 .ENDM INITIO ; ; ;======================================================================== ;= = ;= PCHAR macro = ;= = ;= This MACRO prints one character to SYS$COMMAND. It takes one = ;= argument -- the address of the character. = ;= = ;= Sample calls: = ;= = ;= PCHAR BUFFER = ;= or = ;= MOVAB BUFFER,R9 = ;= PCHAR (R9) = ;= = ;======================================================================== ; .MACRO PCHAR ADDRES PUSH01 ; Save R1 and R0 PUSHADR ADDRES ; Push the buffer address PUSHL #1 ; Push the length of the string CALLS #2,PUT_OUT ; Print it POP01 ; Restore R0 and R1 .ENDM PCHAR ; ;======================================================================== ;= = ;= PLINE macro = ;= = ;= This MACRO prints a specified number of bytes starting at a = ;= specified address. The first argument is the length, the = ;= second is the address. = ;= = ;= Sample call: = ;= = ;= PLINE #80,BUFFER = ;= = ;======================================================================== ; .MACRO PLINE LEN,ADDRES PUSH01 ; Save R1 and R0 PUSHADR ADDRES ; Push address buffer PUSHL LEN ; Push the length CALLS #2,PUT_OUT ; Print it POP01 ; Restore R0 and R1 .ENDM PLINE ; ;======================================================================== ;= = ;= CLRSCRN macro = ;= = ;= This MACRO clears a VT100-compatible screen. It takes no = ;= arguments. = ;= = ;= Sample call: = ;= = ;= CLRSCRN = ;= = ;======================================================================== ; .MACRO CLRSCRN PUSH01 ; Save R1 and R0 CALLS #0,CLRSCR ; Clear the screen POP01 ; Restore R0 and R1 .ENDM CLRSCRN ; ;======================================================================== ;= = ;= PCRLF macro = ;= = ;= This MACRO prints a combo to SYS$COMMAND. It takes = ;= no arguments. = ;= = ;= Sample call: = ;= = ;= PCRLF = ;= = ;======================================================================== ; .MACRO PCRLF PUSH01 ; Save R1 and R0 CALLS #0,CRLF_OUT ; Print a combo POP01 ; Restore R0 and R1 .ENDM PCRLF ; ; ;======================================================================== ;= = ;= GET_LINE macro = ;= = ;= This MACRO gets input from SYS$COMMAND. The number of bytes = ;= to read and the virtual address the bytes are to be stored = ;= serve as its arguments. = ;= = ;= Sample call: = ;= = ;= GET_LINE BUFADD=INBUFF ; Will read up to 80 = ;= ; bytes into INBUFF. = ;= = ;= GET_LINE BUFADD=INBUFF,BUFLEN=#1 ; Read 1 character = ;= = ;======================================================================== ; .MACRO GET_LINE BUFADD,BUFLEN=#80 PUSH01 ; Save R1 and R0 PUSHADR BUFADD ; Push the buffer address PUSHL BUFLEN ; Push the length to read CALLS #2,GETLIN ; Read it POP01 ; Restore R0 and R1 .ENDM GET_LINE ; ; ;======================================================================== ;= = ;= PRTMSG macro = ;= = ;= This MACRO prints the ASCII characters that are passed as its = ;= argument. The ASCII string must be enclosed in angle brackets = ;= (if an angle bracket it included in the string, it must be = ;= surrounded by ^& and &). See the sample calls below. = ;= = ;= Sample calls: = ;= = ;= PRTMSG = ;= or = ;= PRTMSG ^&Message => Never mind& = ;= = ;======================================================================== ; .MACRO PRTMSG MSG,?LABEL,?LINE BRB LABEL LINE: .ASCIZ /MSG/ LABEL: PUSH01 ; Save R1 and R0 PRINT LINE ; Print the buffer POP01 ; Restore R0 and R1 .ENDM PRTMSG ; ; ;======================================================================== ;= = ;= PRINT macro = ;= = ;= This MACRO prints to SYS$COMMAND all bytes from a starting = ;= address until a 0 byte is found. It emulates the .PRINT = ;= PDP RT11 assembler directive. = ;= = ;= Sample call: = ;= = ;= BUFFER: .ASCII /Hello, this is a test/<0> = ;= ... = ;= PRINT BUFFER = ;= = ;======================================================================== ; .MACRO PRINT ADDRES PUSH01 ; Save R1 and R0 PUSHADR ADDRES ; Push the buffer address CALLS #1,PRINT0 ; Start printing POP01 ; Restore R0 and R1 .ENDM PRINT ; ;======================================================================== ;= = ;= TTYOUT macro = ;= = ;= This MACRO prints to SYS$COMMAND the ASCII code it expects to = ;= find in R0 (only the low-order byte is printed). It emulates = ;= the .TTYOUT RT-11 PDP assembler directive. = ;= = ;= Sample calls (to print "Z"): = ;= = ;= MOVB #90,R0 or MOVB #^A/Z/,R0 = ;= TTYOUT TTYOUT = ;= = ;======================================================================== ; .MACRO TTYOUT PUSH01 ; Save R1 and R0 PUSHAL (SP) ; Push address on stack of R0 PUSHL #1 ; Push the length of the string CALLS #2,PUT_OUT ; Print it POP01 ; Restore R0 and R1 .ENDM TTYOUT