* *----------------------------------------* * BINARY converts the current cursor * * bytes to their binary equivalent. * * * * On Entry: HL = address of bytes * * * * On Return: A = garbage * * B = binary value * * HL = last byte + 1 * *----------------------------------------* * BINARY LDA HXASC Is the current mode hex or ASCII? ORA A JNZ BNYASC It is ASCII * BNYHEX MVI B,0 MOV A,M It is hex CALL BYHX1 ORA B MOV B,A MOV A,M If at end of value, exit now CPI 20H RZ . CPI CHCR RZ . * MOV A,B ANI 0FH Strip off any high bits RLC . Convert it now RLC . RLC . RLC . MOV B,A JMP BNYHEX+2 * BYHX1 INX H Convert the next byte ANI 7FH Strip extra bits SUI 30H Convert for letters CPI 0AH RC . SUI 7 Combine the results RET . * BNYASC MOV A,M Do the conversion ANI 7FH CPI '-' Minus means high bit must be set MVI A,80H JZ $+1 XRA A MOV B,A Save this partial result INX H MOV A,M ANI 7FH ORA B Combine the results * MOV B,A Answer goes back in "B" INX H Bump the pointer RET . * *----------------------------------------* * COMPB -- complement the BC registers * * * * On Return: A register destroyed * *----------------------------------------* * COMPB MOV A,C Complement the C register CMA . MOV C,A MOV A,B Now the B register CMA . MOV B,A INX B Now, make it the two's complement RET . * *----------------------------------------* * COMPS -- compare two strings of data. * * In the ASCII mode, the high * * order bit is ignored. * * * * On Entry: B = length of string * * DE = addr. of 1st string * * HL = addr. of 2nd string * * * * On Return: B = unchanged * * C = 7FH if in ACSII mode * * 0FFH if in Hex mode * * DE = unchanged * * HL = unchanged * * * * zf = 1 if identical * *----------------------------------------* * COMPS PUSH B Save registers PUSH D PUSH H * LDA SRMOD Load the mode stripper MOV C,A This value takes care of the high bit problem * CMP1 DCR B Are we done? JZ CMP0 Yes, so exit INR D Point to wild card buffer LDAX D Get the byte DCR D Restore D CPI '*' See if wild card MOV A,M Force a match JZ WC1 LDAX D Get the byte to check WC1 SUB M If (byte1 - byte2) AND C = 0 they match ANA C Do the ANDing INX D Bump both string pointers INX H JZ CMP1 If still the same, keep checking * CMP0 POP H Otherwise, abort POP D POP B RET . * *----------------------------------------* * SKPBLK -- skip over all blanks. * * * * On Entry: HL = string to be scanned * * * * On Return: A = last char. checked * * HL = points to 1st non- * * blank encounter * * * * zf = 1 if A is a C/R * *----------------------------------------* * SKPBLK MOV A,M Get the character CPI 20H Is it a blank? JNZ SKP1 Leave if not INX H Bump pointer to next character JMP SKPBLK Loop back * SKP1 CPI CHCR RET . * *----------------------------------------* * INPUT -- get some keyboard input. * *----------------------------------------* * INPUT CALL CONIN Call the PTDOS input routine RET . * *----------------------------------------* * OUTPUT -- send a character out. * *----------------------------------------* * OUTPUT PUSH B Save registers PUSH D PUSH H CALL CONOUT Send out the character POP H Restore all registers POP D POP B RET . * *----------------------------------------* * GETLN -- get one line of input. * *----------------------------------------* * GETLN LXI H,LINE * CALL INPUT Get a character MOV M,A * CPI CHCR Is it a carriage return? JZ GETDNE Finish up if so CPI 20H Check for the blank JC GETLN+3 If it's a control character, then ignore it JZ GET2 If it's a blank, skip hex check CPI CHDEL-20H Ignore underlines JZ GETLN+3 CPI CHDEL Is it the delete? JNZ GET0 No, must be some ather character * * The delete routine * DCX H Adjust pointer to reflect the delete MOV A,M Have we backed up too far? ORA A If the memory location contains zero, then yes JZ GETLN Start completely over if so * MVI A,CHDEL-20H Send out the back-up character CALL OUTPUT JMP GETLN+3 Go back and wait for more input * * Check legality of entered character * GET0 LDA SRMOD Are we getting hex? ORA A JP GET2 If not, ignore legal hex entry check * MOV A,M We want hex CPI '*' Check for wild card JZ GET2 Bypass hex test CPI 'A' JC GET1 ANI 5FH Convert to uppercase MOV M,A * GET1 CALL CKHEX Go check if it's good hex JC GETLN+3 Loop back up if bad hex * GET2 LXI D,LINEND-2 Are we at the end of the buffer? PUSH H If present-location minus end-of-buffer = 0 then yes XCHG CALL SBTRCT Do the subtraction XCHG POP H Get back the present location in case it's legal MOV A,D If DE is zero, then disallow input ORA E JZ GETLN+3 No input allowed, go wait for a C/R * MOV A,M Output the character CALL OUTPUT INX H Bump the memory pointer JMP GETLN+3 * * All done receiving, check whether to return or to abort * GETDNE INX H Bump the pointer SHLD ENDLNE Save it for later * LXI H,LINE Is the line blank? PUSH H CALL SKPBLK Skip over any leading blanks POP H RNZ . Is the first non-blank character the carriage return? * SHLD ENDLNE Otherwise, abort POP H Remove the return address JMP INIT1 Abort now * *----------------------------------------* * Collect three hex addresses. The * * first address is stored in ADDR1, the * * second in ADDR2, and the third comes * * back in DE with the offset not re- * * removed. * *----------------------------------------* * * Pick up the first address. It is stored in ADDR1 * GETADR CALL SKPBLK Get the first address JZ GTADER If none, give an error CALL GETHEX Go get the address JC GTADER * LHLD OFFSET Remove the offset from the address XCHG . CALL SBTRCT SHLD ADDR1 Save the first address * * Pick up the second address. It is stored in ADDR2 * LHLD NXTVAL Get second address CALL SKPBLK JZ GTADER Abort on errors CALL GETHEX JC GTADER * LHLD OFFSET Remove the offset XCHG . CALL SBTRCT SHLD ADDR2 * * Pick up the last address. It goes back in DE * LHLD NXTVAL Get last address CALL SKPBLK JZ GTADER Report any errors CALL GETHEX JC GTADER * RET . * * Report any errors that occurr * GTADER POP H Remove the return address JZ SBSNER JMP SBVLER * *----------------------------------------* * Routine to check that HL and DE * * contain legal addresses. * *----------------------------------------* * CHKAD PUSH D Make sure HL <= DE PUSH H XCHG . CALL SBTRCT MOV A,H POP H POP D ORA A RM . Return now if not * PUSH D Make sure HL >= BUFFER PUSH H LXI D,BUFFER CALL SBTRCT MOV A,H POP H POP D ORA A RM . Return now if not * PUSH D Make sure DE <= BFFNS PUSH H LHLD BFFNS CALL SBTRCT MOV A,H POP H POP D ORA A RET . Return with result in hand * *----------------------------------------* * Send the string pointed to by HL to * * OUTPUT. The string must be term- * * inated with a NOP. * *----------------------------------------* * LNEOUT MOV A,M Get the character ORA A All done? RZ . Leave if so * INX H Bump the string pointer CALL OUTPUT Send out the character JMP LNEOUT Loop back up * *----------------------------------------* * Print a text message to the screen * *----------------------------------------* * PRMES LDAX D Are we done printing? ORA A RZ . Return if so * MOV M,A Put the character to the screen INX H Bump the screen pointer INX D Bump the memory pointer JMP PRMES Loop * *----------------------------------------* * CLEAR the video screen. * *----------------------------------------* * CLEAR LXI H,SCREEN Point to the top of the screen MVI M,20H Push in a blank INX H Bump the screen pointer MOV A,H All done? CPI 0D0H If below the bottom of the screen, yes JNZ CLEAR+3 Loop up if not done * RET . Bye, bye * *----------------------------------------* * Subtract DE from HL with result in HL * *----------------------------------------* * SBTRCT MOV A,D First, take the two's complement of DE CMA . MOV D,A In other words, LET DE = -DE MOV A,E CMA . MOV E,A INX D DAD D Now, Add DE to HL RET . * *----------------------------------------* * Set parity of the cursor byte high. * * HL contains the cursor location. * *----------------------------------------* * CURON LHLD SCRPNT MOV A,M Get the first byte ORI 80H Inverse it MOV M,A Put it back INX H MOV A,M Now do the second ORI 80H MOV M,A DCX H RET . * *----------------------------------------* * Reset the parity of the cursor byte. * * HL contains the cursor location. * *----------------------------------------* * CURSW MOV A,M Get the first byte ANI 7FH MOV M,A Put it back on the screen INX H MOV A,M Get the second byte ANI 7FH MOV M,A DCX H Restore pointer * XRA A If the cursor is fussed with, STA CURCHK set the digit count to zero * RET . * *----------------------------------------* * This is the Char./address table. * *----------------------------------------* * CHTBL DB SUOL Scroll up one line DW RSUOL * DB SDOL Scroll down one line DW RSDOL * DB SUS Scroll up one screenful of data DW RSUS * DB SDS Scroll down one screenful of data DW RSDS * DB ASHX ASCII/HEX toggle routine DW RASHX * DB CUP Move cursor up DW RCUP * DB CDWN Move cursor down DW RCDWN * DB CLFT Move cursor left DW RCLFT * DB CRGT Move cursor right DW RCRGT * DB CULC Move the cursor the the upper-lefthand corner DW RCULC * DB EXIT Write the file to the disk and exit to PTDOS DW REXIT * DB ABRT Abort to the PTDOS monitor DW RABRT * DB CEOL Put cursor at end of current line DW RCEOL * DB CBNL Put cursor at beginning of next line DW RCBNL * DB CBNL1 Put cursor at beginning of next line DW RCBNL * DB INSRT Insert one NOP at the current cursor location DW RINSRT * DB DELT Remove the current byte from the file DW RDELT * DB SRCH Search for a specified set of bytes DW RSRCH * DB CSRCH Continue search DW RCSRCH * DB SBCMD Enter the sub-command routine DW RSBCMD * DB 0FFH End of table mark * *----------------------------------------* * Data storage area * *----------------------------------------* * BFSTT DW BUFFER Buffer start address BFFNS DW 0 Buffer end address HXASC DB 0 Current display mode MEMPNT DW 0 Current cursor location MEMLNE DW 0 Address of first byte on screen SCRPNT DW 0 Address of cursor on screen OFFSET DW 100H-BUFFER Value range offset FREE DW 0 Highest free memory location LSTCHR DB 0 The last character read after a disk operation * DB 0 A zero for delete test LINE DS 127 Input line buffer LINEND EQU $ FILEN DB 0 File number of the currently open file FLNGTH DW 0 FLAT1 DB 0FFH FLAT2 DB 0FFH OUTFIL DW 0 Address of the output file name PRTCT DB 0 Is the output file protect check on? 0=Y * * Input file storage (in case none is given) * DB '.'+80H File type DW 100H Block size of 100H DB 0 No attribute protection FNAM1 DS 20 * * Output file storage (if one is given) * DB '.'+80H File type DW 100H Block size of 100H DB 0 No attribute protection FNAM2 DS 20 * CURCHK DB 0 The number of digits entered * SRMOD DB 0 Data for the search operation SCHLOC DW 0 ENDLNE DW LINE * INMDE DB 0 The insert mode is off DEMDE DB 0 The delete mode is off LSTEND DW 0 The "RE" subcommand is off * FRST DW 0 Data for the move operation SCND DW 0 DEST DW 0 COUNT DW 0 DSTEND DW 0 Same as the original value of count * ADDR1 DW 0 Data for the fill operation ADDR2 DW 0 NXTVAL DW 0 * STORAGE DS 20 * DS 25 Some stack space STACK DB 0 * WILDBUF ORG LINE+100H Wild card buffer DS 127 BOTTOM EQU $ The buffer must lie on a page boundry BOTHGH EQU