* *----------------------------------------* * Initialize the MEDIT pointers. * *----------------------------------------* * INIT LHLD BFSTT Initialize the pointers SHLD SCHLOC * INIT0 SHLD MEMLNE SHLD MEMPNT XCHG . LXI H,SCREEN+7 SHLD SCRPNT * INIT1 XRA A Initialize the screen OUT 0FEH OUT 0C8H * LXI SP,STACK Initialize the stack * *----------------------------------------* * This is the main loop of MEDIT * *----------------------------------------* * MAIN LHLD MEMLNE Get the memory address XCHG . Pointer must be in DE CALL PRVDM Put on a new screen of data * MN0 CALL CURON Put on the cursor * PUSH D Go update the information PUSH H CALL PRINFO Do it now POP H Retrieve values POP D * *----------------------------------------* * Check for input of wanted characters. * *----------------------------------------* * MN1 CALL INPUT Wait for a character ANI 7FH * *----------------------------------------* * We've got a character. Find out what * * it does (if anything) * *----------------------------------------* * LOOK LXI B,MN0 Push this on the stack as a return address PUSH B * LXI H,CHTBL Point to the lookup table * LOOK1 CMP M Is this the character? * MOV B,M Save the table character * INX H Get a jump address before acting MOV E,M INX H MOV D,M * JZ LOOK2 Finally, Yes! go to the routine * *----------------------------------------* * Not this time, check for end of table * *----------------------------------------* * MOV C,A Are we at the table end? MOV A,B ORA A MOV A,C JM CNVRT Yes, so input must be changing a memory byte * MOV A,C Get the input character back * INX H Keep looping JMP LOOK1 * *----------------------------------------* * We know the routine address, jump! * *----------------------------------------* * LOOK2 XCHG . Clean up the registers PCHL . Now, execute the routine * *----------------------------------------* * Convert the input to usable binary * * and store it in the proper place. * *----------------------------------------* * CNVRT LHLD SCRPNT * MOV B,A Save the character LDA HXASC Are we in the hex mode? ORA A MOV A,B JM CNVR3 Minus says no * *----------------------------------------* * The hex mode with "window" input. * *----------------------------------------* * CALL CKHEX Check and see if character is legal hex RC . Return now if not * CNVR2 PUSH PSW Save the character * INX H Create a "window" effect MOV A,M Move the right cursor byte left one byte DCX H MOV M,A All done * POP PSW Now, put the new byte in the others old place ORI 80H Inverse it first though * INX H Put it to the screen MOV M,A DCX H Adjust for binary conversion * CALL BINARY Convert the cursor byte for us LHLD MEMPNT MOV M,B Now, save it in memory * LDA CURCHK Is it time to move the cursor? INR A Increment the digit counter ANI 1 If it is greater than one (i.e. two) then move it STA CURCHK JZ ADVCUR Go move it if necessary * RET . * *----------------------------------------* * ASCII mode with minus input allowed. * *----------------------------------------* * CNVR3 CPI 20H We don't want CTRL characters RC . * MOV B,A Save the character * INX H Now, check for minus input MOV A,M Get the old character ANI 7FH Clean it up CPI '-' Is it a minus? DCX H MOV A,B If so, then "window" the minus sign JZ CNVR2 * CNVR4 INX H If not, then clear the display MVI M,0A0H This does it DCX H Now, "window" nothing * CPI '-' Minus input is special JZ CNVR2 * PUSH PSW LDA CURCHK In the ASCII mode, only one letter allowed ORA A before advancing the cursor JNZ CNVR2+1 The exception is minus ("-") input, INR A then two characters are allowed STA CURCHK * JMP CNVR2+1 * *----------------------------------------* * Change ASCII to HEX and vice versa. * *----------------------------------------* * RASHX LDA HXASC Change the mode CMA . STA HXASC * LHLD MEMLNE Now, reprint the screen XCHG . * JMP PRVDM Print the new screenful of data * *----------------------------------------* * All necessary scroll routines. * *----------------------------------------* * * Scroll up one line on the screen. * RSUOL LXI B,16 Scroll forward 16 bytes MVI A,1 Do it one time JMP SCROLL * * Scroll down one line on the screen. * RSDOL LXI B,-16 Scroll backwards 16 bytes JMP RSUOL+3 * * Scroll down one full screen * RSDS LXI B,-16 Scroll backwards 16 bytes MVI A,16 Do it 16 times JMP SCROLL * * Scroll up one full screen. * RSUS LXI B,16 Scroll forward 16 bytes JMP RSDS+3 * *----------------------------------------* * Home the cursor on the screen. * *----------------------------------------* * RCULC LHLD SCRPNT Erase the cursor CALL CURSW * LXI H,SCREEN+7 Initialize the screen pointer SHLD SCRPNT * LHLD MEMLNE Re-initialize the memory pointer SHLD MEMPNT * RET . * *----------------------------------------* * Put cursor at beginning of next line. * *----------------------------------------* * RCBNL CALL RCEOL Erase the cursor JMP ADVCUR * *----------------------------------------* * Move cursor to the end of the line * *----------------------------------------* * RCEOL LHLD SCRPNT Erase the cursor CALL CURSW * MOV A,L Ajust the screen pointer ANI 0C0H ORI 7 MOV L,A SHLD SCRPNT Save it for later CALL CURSW * LHLD MEMPNT Now, adjust the memory pointer MOV A,L ANI 0F0H This does it properly MOV L,A SHLD MEMPNT Save this also * CALL RCLFT Move everything down a line now * RET . * *----------------------------------------* * Insert one NOP into the file. * *----------------------------------------* * RINSRT LDA INMDE Is the insert mode on? ORA A RZ . Say bye if not * LHLD SCRPNT Turn off the cursor CALL CURSW * LHLD BFFNS Get the end of the file address XCHG . LHLD MEMPNT Get the cursor location * PUSH H Are we at the end of the file? PUSH D INX D LHLD FREE If the buffer end exceeds the highest DCX H available memory location, then cannot insert CALL SBTRCT MOV A,H POP D POP H ORA A JP RINS1 Everything is okay, insert the NOP * CALL CLEAR Go print the error message LXI H,BUFUL JMP SBBDER+3 * RINS1 PUSH D Save these pointers PUSH H MOV B,H Destination of block move is HL+1 MOV C,L INX B Add the one CALL MOVE Move the block * POP H Get back the pointers POP D * MVI M,0 Put the NOP in place INX D Add one to the end address * LXI H,0 Disallow use of the "RE" subcommand SHLD LSTEND * XCHG . SHLD BFFNS Save the value * JMP SBEN1 Go reprint the screen * * The error message * BUFUL ASCZ "No room for insert" * *----------------------------------------* * Delete on byte from the file. * *----------------------------------------* * RDELT LDA DEMDE Is the delete mode on? ORA A RZ . Leave if not * LHLD SCRPNT Turn off the cursor CALL CURSW * LHLD BFFNS Get the current end of file location XCHG . * LHLD MEMPNT Is the current location the last byte of the file? XCHG . INX D PUSH H CALL BFEND Go check it out POP H DCX D JC INIT1 Exit if so XCHG . * MOV B,H BC has destination address of block move MOV C,L INX H * PUSH D Go move the block CALL MOVE POP D CALL BFBEG JNC INIT1 * XCHG . DCX H Save the new end address SHLD BFFNS * JMP SBEN1 Go reprint the screen * *----------------------------------------* * Advance the cursor one byte. * *----------------------------------------* * ADVCUR CALL RCRGT Move the cursor right one byte * LHLD SCRPNT Has it wrapped around? MOV A,L Check it ANI 3FH CPI 7 RNZ . Return now if not * MOV A,L Yes, move the cursor down a line now CPI 0C7H Is it at the bottom of the screen? JNZ RCDWN If not, then exit with the cursor-down movement * MOV A,H Otherwise, scroll one line CPI