**************************************************************** * * * * * ***** **** ***** ***** * * * * * * * * * * * * * * * * *** * * * * * * * * * * * * * * * * * * * * ***** **** ***** * * * * * * * VDM--BASED TEXT EDITOR * * * * EDIT 2.0 (MOD 0) * * JANUARY 30, 1983 * * * * COPYRIGHT (C) 1983 * * PROTEUS SOFTWARE LIBRARY * * * * * **************************************************************** * * * EDIT sfile[][,ofile[]][,highmemory] * * * * where the "" must appear exactly as shown * * if the input (source) file is an ALS8-format * * file or if the output file is to be written * * in ALS8 format. If only one file is specified * * then the ofile will default to the same as sfile * * and will be written in the same format. * * * **************************************************************** TITL EDIT ASCF 0 IFLS * ORG 100H XEQ GPRAM * COPY NPTDEFS SPACE EQU ' ' YES EQU -1 NO EQU 0 SUTILFN EQU 2 SUTIL'S FILE NUMBER (USED IN INSERT FILE) * **************************************************************** * START JMP REENT Re-entry point EDIT LXI D,SFILE DE and HL point to infile's name LXI H,SFILE MVI A,PSOP+40H open the file CALL PSCAN MOV A,E get the file # or error # JC OER1 error STA SFNUM save the source file's number LXI D,GPRAM * NEXTL PUSH D DE= address of next free byte XCHG LXI B,512+40 leave this much room DAD B LXI D,EOSP DE-> highest address editor is allowed to use CALL DCMP compare EOSP with HL POP D DE= next free byte again JC ERTOB Too big (HL>EOSP) LDA SALS8 Is source file in ALS8 format? CPI YES JZ NXTL1 Yes. We don't have to add length bytes. PUSH D Save position where length byte should go. INX D Leave room for it. * NXTL1 LDA SFNUM Get file #. LXI B,255 Sets B=0, C=255 (max read count) MVI L,CR line delimiter CALL SYS DB DRDOP delimited read JMP LOAD eof (hopefully) LDA SALS8 Was it ALS8-type? CPI YES JZ NEXTL Yes. No problem. POP H HL-> where length byte should go. XRA A Set A=0. SUB C Compute length (=-C) MOV M,A Store it. JMP NEXTL Read next line. * LOAD PUSH PSW LDA SFNUM CALL SYS DB CLOOP CALL RER1 POP PSW CPI EREOF EOF? JNZ RER1 READ ERROR LDA SALS8 CPI YES JZ LOAD0 It was ALS8, so no problem. POP D Otherwise D is on the stack. * LOAD0 DCX D This brings D back to last thing loaded. PUSH D LAST ADDRESS LOADED CALL OUST DW 0A0DH ASC "EDIT 2.0 (MOD 0)" DW 0A0DH ASC "COPYRIGHT (C) 1983" DW 0A0DH ASC "PROTEUS SOFTWARE LIBRARY" DW 0A0DH ASC "********" DW 0A0DH ASC "Last load addr: " DB 0 * POP H PUSH H SHLD EFP CALL OUT16 OUTPUT LAST ADDRESS CALL OUST DW 0A0DH ASC "Load count: " DB 0 * POP D LHLD BFP MOV A,E SUB L MOV L,A MOV A,D SBB H MOV H,A INX H PUSH H CALL OUT16 LOAD COUNT * * CHECK THE FILE * CALL OUST DW 0A0DH ASC "End of file at: " DB 0 LXI D,EFP POP H MOV A,H ORA L LHLD BFP JZ STEND NO BYTES LOADED LXI B,0 * CKLOP MOV A,M GET COUNT DCR A MOV C,A JZ EFRPT DAD B MOV A,M CPI 0DH JNZ RPERR INX H CALL DCMP JC STEND JNZ CKLOP STEND MVI M,1 JMP EFRPT * * * REPORT BAD FILE * RPERR PUSH H CALL OUST DW 0A0DH DW 0A0DH ASC "Edit abort...file error" ASC " at address: " DB 0 POP H CALL OUT16 CALL OUST DW 0A0DH DB 0 JMP EXIT * * EFRPT SHLD EFP CALL OUT16 * * CHECK FOR FREE SPACE * XCHG LHLD EOSP MOV A,L SUB E MOV L,A MOV A,H SBB D MOV H,A PUSH H CALL OUST DW 0A0DH ASC "Bytes free: " DB 0 POP H CALL OUT16 * STRTED CALL OUST Start editing. DW 0A0DH DW 0A0DH ASC "C/R to continue" DB 0 * EWAIT CALL CONIN CPI 0DH JNZ EWAIT LXI SP,AREA+18 LHLD BFP LXI D,EFP CALL DCMP JC OER1 JNZ EDIT1 * * NULL FILE INITIALIZE IT * MVI M,2 INX H MVI M,CR INX H MVI M,1 SHLD EFP *