* IFLS * * * * * *** *** ****** ***** ** ********** * ** * * ** ** * ** * ** * ** * * ** * * ** ** ** ** ** ** * ** * ** ***** ** ** ** ** * ** ** ** ** ** ** ** * ** ** ** * ** * ** ** * ** ** ****** ***** ** ** * * * * A machine language (memory) editor for use with * the SOL computer and a Helios disk. * Version 1.1 (Mod 0) * * Written by: * * Steve and Joe Maguire * P.O. Box 3742 DT * Anchorage, AK 99510 * * Copyright (C) 1980 * All rights reserved * * * * ORG 100H XEQ $+3 Bypass the jump statement * SCREEN EQU 0CC00H Upper left-hand corner of the screen CHCR EQU 0DH A carriage return CHLF EQU 0AH A linefeed CHDEL EQU 7FH A delete * SUOL EQU 05H Control/E Scroll up one line SDOL EQU 18H Control/X Scroll down one line SUS EQU 12H Control/R Scroll up one screen (16 lines) SDS EQU 03H Control/C Scroll down one screen * CUP EQU 17H Control/W Move cursor up one line CDWN EQU 1AH Control/Z Move cursor down one line CRGT EQU 13H Control/S Move cursor right one byte CLFT EQU 01H Control/A Move cursor left one byte CULC EQU 0EH "HOME CURSOR" Move cursor to upper left corner CEOL EQU 09H "TAB" Move cursor to end of current line CBNL EQU CHCR "RETURN" Move cursor to beginning of next line CBNL1 EQU CHLF "LINE FEED" ditto SPACE EQU 20H Bump cursor to next memory location * INSRT EQU 14H Control/T Insert one byte DELT EQU 08H Control/H Delete one byte SRCH EQU 0FH Control/O Search for specified set of bytes CSRCH EQU 0CH Control/L Continue search SBCMD EQU 16H Control/V Enter sub-command mode ABRT EQU 1BH "ESCAPE" Abort edit EXIT EQU 06H Control/F Exit from the editor ASHX EQU 0 "MODE" ASCII/Hex toggle * * Copy in all of the system equates * COPY NPTDEFS * JMP INIT If it is re-entered, ingore all disk operations * LHLD SYSGLO Set the Level-1 error trap address LXI D,GLERM for returning to this program upon errors DAD D MVI M,-1 INX H MVI M,-1 * LXI SP,STACK * XRA A STA PRTCT * *----------------------------------------* * Process the input file name. * *----------------------------------------* * CMD0 LXI D,FNAM1 Point to the file name receiving area MVI A,PSN Get the file name CALL PSCAN STA LSTCHR Save the last character read * CMDCR LXI H,ILGIFN Illegal file name message JC ABTERR If illegal name, then error LXI H,EXPIFN Expected a file name error message JZ ABTERR If no name, then error * LXI D,FNAM1 Get the attribute byte of this file CALL GETAT STA FLAT1 Save it for later JC IFPRT * *----------------------------------------* * If there is an error in the file name * * check it out here. * *----------------------------------------* * LXI H,ILGIFN If it is an illegal file name, tell which one CPI ERINM JZ ABTERR * CPI ERNEX Is the file non-existent? JNZ ERROR Give a serious abort if that's not the case * LXI H,FDNE Print the file does not exist message CALL LNEOUT * ANSWR CALL INPUT Does he want the file created? ANI 5FH Wait for a reply, then make it upper case CPI 'Y' JNZ RABT1 If he doesn't, then abort * CALL OUTPUT Put out the answer * LXI D,FNAM1 Create the file LXI H,FNAM1 MVI A,PSC+40H CALL PSCAN * JMP CMDCR Go back up to check for any errors * *----------------------------------------* * The file is legal, check protection * *----------------------------------------* * IFPRT ANI PREA Is the input file read protected? LXI H,IFLPRT Abort if so JNZ ABTERR * CALL DELM Go see if command ended with a legal delimiter CPI ',' Was the delimiter a comma? JNZ CMD5 If not, no more command line * *----------------------------------------* * Process the output file name. * *----------------------------------------* * CMD1 LXI D,FNAM2 Create the output file if is doesn't exist MVI A,PSC Do it now CALL PSCAN STA LSTCHR Save the last character scanned * LXI H,ILGOFN If it's an illegal name, say so JC ABTERR * JNZ CMD2 If the file name is there, process it * CPI ',' Is the command like: "MEDIT filename,;"? LXI H,EXPOFN Abort if so JNZ ABTERR * JMP CMD3 The command is like: "MEDIT filename,,hhhh" * CMD2 LXI D,FNAM2 Get the attribute byte for this file CALL GETAT * LXI H,ILGOFN If the output file name is illegal, abort JNC ABTERR * ANI 7FH Strip off the undefined portion STA FLAT2 Save it for later * *----------------------------------------* * Pick up the offset if there is one. * *----------------------------------------* * CMD3 CALL DELM Now, if the last character scanned was a comma, CPI ',' then pick up another value JNZ CMD5 No it wasn't, determine the output file * MVI A,PSV Read in the offset value LXI D,STORAGE CALL PSCAN STA LSTCHR Save the last character scanned * LXI H,ILGVL Point to the illegal value message JC ABTERR LXI H,EXPVL Point to the missing value message JZ ABTERR * CPI CHCR Get last character; it must be a C/R or ";" JZ CMD4 It's a C/R; everything is fine CPI ';' LXI H,SYNTX Some sort of syntax error JNZ ABTERR Oops, not a semicolon so error * CMD4 XCHG . Save the value that was read in LXI D,BUFFER CALL SBTRCT SHLD OFFSET * *----------------------------------------* * Determine which file is the out file. * *----------------------------------------* * CMD5 LDA FLAT2 Get the file number LXI H,FNAM2 ORA A Is the output different from the input file? JP CMD6 Yes, go move the file name into a text message * LDA FLAT1 No, they are the same LXI H,FNAM1 * CMD6 SHLD OUTFIL Save the output file name address * ANI PWRI+PALO Is the file write or extend protected? JZ CMD7 Go open the file if all is okay * LXI H,OFLPRT Point to the error message CALL LNEOUT * CALL INPUT Ask if he would like to load the file anyway ANI 5FH Convert any lower case answers CPI 'Y' JNZ RABT1 If he doesn't want to load, abort * CALL OUTPUT Send out his answer * MVI A,-1 Indicate the the output file is protected STA PRTCT * *----------------------------------------* * Open the file; check if the file is * * a device file -- abort if so. * *----------------------------------------* * CMD7 LXI D,FNAM1 Open the file now CALL OPEN * LXI H,ILGIFN Print the error message JZ ABTERR * *-----------------------------------------* * Size the memory. The buffer size is * * limited by the either the highest * * available memory or the lowest address * * assigned to the system (GLLOW). The * * smaller value is chosen. * *-----------------------------------------* * SIZE LXI H,BUFFER Point to the beginning of available memory MVI A,0AAH This is the check byte (lot's of 1's and 0's) * SZ1 MOV B,M Save the original memory value MVI M,0AAH Move in the test value CMP M Is the value now in memory? MOV M,B Put the original value back before answering INX H Bump the pointer also JZ SZ1 Answer now; loop up if the value was in memory DCX H Adjust pointer to reflect last good location DCX H HL now has the value of the highest available memory * PUSH H Save that value for later LHLD SYSGLO Now, find the lowest address given to the system LXI D,GLLOW Here's the offset DAD D Add it to HL to get the value of GLLOW MOV E,M Move low byte into E INX H Bump the pointer MOV D,M Move high byte into E; DE now has GLLOW POP H Memory scan is in HL * PUSH H To find which is smaller, subtract them from each other PUSH D Save the values CALL SBTRCT Subtract them POP D Retrieve the values POP H MOV A,H If the result is positive, then the scan was smaller ORA A JP READ XCHG . * *----------------------------------------* * Read in the file now. Abort if the * * file is too long to fit in the buffer * *----------------------------------------* * READ SHLD FREE Save the highest legal address * LXI D,BUFFER Find the length of the buffer CALL SBTRCT MOV B,H Put it in BC MOV C,L * LDA FILEN Get the file number LXI D,BUFFER Point to the recieving buffer CALL SYS Go read in the file DB RBLOP JMP ALLDNE * LXI H,FTBIG If we got here, the file is too big JMP ABTERR * *----------------------------------------* * If the read was okay, continue here * *----------------------------------------* * ALLDNE CPI EREOF If EOF has been reached, ignore it JNZ ERROR * PUSH D Save the end of file address CALL CLOSE Close the input file * LHLD OUTFIL Go open the output file XCHG . CALL OPEN Do it now * POP D * LXI H,ILGOFN Abort if illegal output file name JZ ABTERR * *----------------------------------------* * Put some value in text messages that * * will be printed at some time or other * *----------------------------------------* * MES LXI H,EOFADR Put the EOF value in a text message CALL PRDE for printing later DCX D * LXI H,LLADR Put the last-load value in a text message, too CALL PRDE * LXI H,ENDADR Turn the end address into ASCII and put CALL PRDE it in the end-address message * XCHG . Save the end-address SHLD BFFNS * XCHG . Calculate the number of free bytes LHLD FREE Compute: highest-memory minus end-address CALL SBTRCT DCX H Subtract one to account for the End-of-file XCHG . Put the value in a message LXI H,BYTFRE Go do it CALL PRDE * LHLD BFSTT Put the buffer-start address in a XCHG . Message also LXI H,BEGADR CALL PRDE * CALL LNGTH Calculate the file length MOV A,D Is the file length zero? ORA E JNZ ALL0 No, print the sign on message * LXI H,BUFFER Put in an end of file byte MVI M,1 Go back and fake a one byte program load INX H Here's the one byte XCHG . It must be in DE JMP MES Go start over * ALL0 LXI H,SGNON Print the sign on message CALL LNEOUT * ALL1 CALL INPUT Wait for a carriage return CPI CHCR JNZ ALL1 * CALL CLEAR Clean up the screen * JMP INIT Go start working * *----------------------------------------* * Abort with an error message pointed * * to by HL. * *----------------------------------------* * ABTERR PUSH H Save the message location LXI H,EDTABT Send out the abort message CALL LNEOUT POP H Get back unique message location CALL LNEOUT Now, send that out JMP RABT1 Go abort * *----------------------------------------* * If there is an error, abort here. * *----------------------------------------* * ERROR LXI H,DVCFL Screen out device driver errors CPI ERDRI JC ERR1 Not a device driver error, abort here CPI ERNCT JC ABTERR It is a device driver error, abort elsewhere * ERR1 STA ERRCDE Otherwise setup for abort * CALL CLOSE Close the file in case it was open * XRA A Set registers before aborting LXI H,-1 CALL UTIL Do the abort DB UXOP BADABT JMP BADABT Loop forever if bad abort DB -1 ERRCDE DB -1 * *----------------------------------------* * Open the file whose name is pointed * * to by the register pair DE. * * * * On return, zf=1 if error * *----------------------------------------* * OPEN LXI H,0 Give it a static buffer CALL SYS DB OPEOP XRA A Set the zero flag if any errors occur RET . NOP . Don't delete this NOP. It's needed!! * STA FILEN Save the file number in case it was open * MOV A,B Get the file type ORA A If it's zero, then it is a device file LXI H,DVCFL Go abort if so JZ ABTERR * RET . * *----------------------------------------* * Close the current file. * *----------------------------------------* * CLOSE LDA FILEN Close the file CALL SYS DB CLOOP JMP BADABT * CALL REOCMD Go scratch any of the unused command string * RET . * *----------------------------------------* * Calculate the length of the file. * *----------------------------------------* * LNGTH LHLD BFSTT Get the buffer start address XCHG . LHLD BFFNS And subtract it from the end address CALL SBTRCT Do it now INX H Zero, one,... is no good. Make it one, two,... SHLD FLNGTH Store the length * XCHG . Print the length in various messages * LXI H,LCADR Put it in a sign on message CALL PRDE * LXI H,FLECNT Put it in a sign off message JMP PRDE * *----------------------------------------* * GETAT -- get the file attributes of * * the file name pointed to by DE. The * * attribute byte is returned in A. * *----------------------------------------* * GETAT LXI H,BOTTOM Point to receiving area CALL SYS Go get the information DB INFOP STC . On error, return with the carry reset CMC . RET . * LDA BOTTOM+14 Get the attribute byte * STC . Set the carry for no error return RET . * *----------------------------------------* * DELM -- check for a legal delimeter. * * Abort if no good. * *----------------------------------------* * DELM LDA LSTCHR Get the character CPI CHCR If it's a carriage return, then okay RZ . CPI ';' If a semicolon, still okay RZ . CPI ',' If it's not a comma, then it's an illegal character RZ . * LXI H,SYNTX Give a syntax error JMP ABTERR * *----------------------------------------* * Read in the unused portion of the * * command. * *----------------------------------------* * REOCMD LDA LSTCHR Get the last character read * CPI CHCR If it's a carriage return, then all done RZ . CPI ';' A semicolon does it too RZ . * MVI A,PSONE Get the next character LXI D,STORAGE CALL PSCAN JMP REOCMD+3 Loop until the end of the command has been found * *----------------------------------------* * Various sign on/off messages. * *----------------------------------------* * ASCF 0 Assemble with short ASCII printout * FDNE DB CHCR,CHLF ASCZ "File does not exist, create? " * SGNON DB CHCR,CHLF,CHLF ASC "MEDIT 1.1 (mod 0)" DB CHCR,CHLF ASC "PROTEUS Software Library" DB CHCR,CHLF ASC "Written by: Steve & Joe Maguire" DB CHCR,CHLF ASC "********" DB CHCR,CHLF ASC "Last load address: " LLADR ASC "0000" DB CHCR,CHLF ASC "Load count: " LCADR ASC "0000" DB CHCR,CHLF ASC "End of file at: " EOFADR ASC "0000" DB CHCR,CHLF ASC "Bytes free: " BYTFRE ASC "0000" DB CHCR,CHLF,CHCR,CHLF ASCZ "C/R to continue: " * *----------------------------------------* * All of the message printed upon abort * *----------------------------------------* * EDTABT DB CHCR,CHLF ASC "Medit aborted" DB CHCR,CHLF,0 * FTBIG ASCZ "The file is too large" IFLPRT ASCZ "The input file is read protected" * OFLPRT ASC "The output file is protected." DB CHCR,CHLF ASCZ "Load input file for viewing only? " * SYNTX ASCZ "Illegal character in command" DVCFL ASCZ "Device files cannot be edited" ILGVL ASCZ "The offset value is illegal" EXPVL ASCZ "The offset value is missing" ILGIFN ASCZ "The input file name is illegal" EXPIFN ASCZ "The input file name is missing" ILGOFN ASCZ "The output file name is illegal" EXPOFN ASCZ "The output file name is missing" * *----------------------------------------* * Sign off information/verify message. * *----------------------------------------* * SGNOFF DB CHCR,CHLF ASC "*** Meditor exit" DB CHCR,CHLF,CHCR,CHLF BEGADR ASC "0000 " ASC "File start address" DB CHCR,CHLF ENDADR ASC "0000 " ASC "File end address" DB CHCR,CHLF FLECNT ASC "0000 " ASC "File count" DB CHCR,CHLF,CHCR,CHLF ASCZ 'OK to write to "' QUESTN ASCZ '"? ' * *----------------------------------------* * User invoked abort verify message. * *----------------------------------------* * ABORT DB CHCR,CHLF ASCZ "Abort? " *