* *ORG BUFFER * START 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 cc mand 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,LASTB Point to the end of this code 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 HePe'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 . JMP READ Go read in the file * *------------------------* * Some abort messages * *------------------------* * 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" * LASTB EQU $ * END *