; ; Program: ECHO ; Author: Richard Conn ; Version: 1.0 ; Date: 22 Mar 84 ; version equ 10 z3env SET 0F400H ;base address of ZCPR3 Environment Descriptor ; ; The purpose of ECHO is two-fold: ; 1) to provide a convenient way of sending messages to ; the console during the execution of a command file or multiple command ; line; for example: ; ; echo Assembling;m80 =$1;^E ; if input;echo Linking;l80 /P:100,$1,A:SYSLIB/S,$1/N,/E;fi ; ; as a single multiple command line will print the informative messages of ; "ASSEMBLING" and "LINKING" during the respective phases of the commands ; ; 2) to provide a convenient way to send escape sequences ; to the CRT and printer; ECHO does no character translation, using direct ; BIOS calls, so sequences used to program intelligent devices can be ; issued by running echo and typing in those sequences ; ; ; Z3LIB and SYSLIB References ; ext z3init,print ; ; Equates ; wboot equ 00h tbuff equ 80h fcb1 equ 5ch cr equ 0dh ff equ 0ch lf equ 0ah ; ; Environment Definition ; if z3env ne 0 ; ; External ZCPR3 Environment Descriptor ; jmp start db 'Z3ENV' ;This is a ZCPR3 Utility db 1 ;External Environment Descriptor z3eadr: dw z3env start: lhld z3eadr ;pt to ZCPR3 environment ; else ; ; Internal ZCPR3 Environment Descriptor ; MACLIB Z3BASE.LIB MACLIB SYSENV.LIB z3eadr: jmp start SYSENV start: lxi h,z3eadr ;pt to ZCPR3 environment endif ; ; Start of Program -- Initialize ZCPR3 Environment ; call z3init ;initialize the ZCPR3 Env and the VLIB Env ; ; Check for Help ; lda fcb1+1 ;get first char cpi '/' ;if slash, then print help jnz echo call print db 'ECHO, Version ' db (version/10)+'0','.',(version mod 10)+'0',cr,lf db 'Syntax:',cr,lf db ' ECHO text <-- send text to console',cr,lf db ' ECHO $text <-- send text to printer',cr,lf db ' ECHO $text^L <-- send text to printer',cr,lf db ' terminated by CR,LF,FF' db 0 ret ; ; Run ECHO Routine ; ECHO: LXI H,TBUFF+1 ;PT TO FIRST CHAR ECHO1: MOV A,M ;SKIP LEADING SPACES INX H ;PT TO NEXT CPI ' ' JZ ECHO1 MOV B,A ;CHAR IN B CPI '$' ;PRINT FLAG? JZ ECHO2 DCX H ;PT TO CHAR ; ; LOOP TO ECHO CHARS ; ECHO2: MOV A,M ;GET CHAR ORA A ;EOL? JZ ECHO4 CPI FF ;FORM FEED? JZ ECHO3 ECHO2C: CALL ECHOUT ;SEND CHAR INX H ;PT TO NEXT JMP ECHO2 ; ; FORM FEED - SEND NEW LINE FOLLOWED BY FORM FEED IF PRINTER OUTPUT ; ECHO3: MOV A,B ;CHECK FOR PRINTER OUTPUT CPI '$' JNZ ECHOFF ;SEND FORM FEED NORMALLY IF NOT PRINTER CALL ECHONL ;SEND NEW LINE MVI A,FF ;SEND FORM FEED JMP ECHOUT ; ; SEND FORM FEED CHAR TO CONSOLE ; ECHOFF: MVI A,FF ;GET CHAR JMP ECHO2C ; ; END OF PRINT LOOP - CHECK FOR PRINTER TERMINATION ; ECHO4: MOV A,B ;CHECK FOR PRINTER OUTPUT CPI '$' RNZ ;DONE IF NO PRINTER OUTPUT ; ; OUTPUT A NEW LINE ; ECHONL: MVI A,CR ;OUTPUT NEW LINE ON PRINTER CALL ECHOUT MVI A,LF ;FALL THRU TO ECHOUT ; ; OUTPUT CHAR TO PRINTER OR CONSOLE ; ECHOUT: MOV C,A ;CHAR IN C PUSH H ;SAVE HL PUSH B ;SAVE BC LXI D,0CH-3 ;OFFSET FOR CONSOLE OUTPUT MOV A,B ;CHECK FOR PRINTER CPI '$' JNZ ECHOUT1 INX D ;ADD 3 FOR PRINTER OFFSET INX D INX D ; ; OUTPUT CHAR IN C WITH BIOS OFFSET IN DE ; ECHOUT1: CALL BIOUT ;BIOS OUTPUT POP B ;RESTORE BC,HL POP H RET ; ; OUTPUT CHAR IN C TO BIOS WITH OFFSET IN DE ; BIOUT: LHLD WBOOT+1 ;GET ADDRESS OF WARM BOOT DAD D ;PT TO ROUTINE PCHL ;JUMP TO IT end