Micro Vibe

My Micro Hobby Projects

  • Increase font size
  • Default font size
  • Decrease font size
Home CPM 80 Using CPM ED Utility

ED Utility

Print
The ED.COM utility program is used to edit ASCII text files. The program is a line based editor and can be used to modify or create text files when a screen based text editor is not available. One of the uses of ED.COM is to patch assembler language files and Intel hex formatted files. This is usually done using the SUBMIT.COM and XSUB.COM utility programs and a patch file containing the changes to be made to the text file. The ED.COM program accepts two parameters; the name of the file to edit followed by an optional work drive code. If the work drive code is omitted the drive that contains the file to edit will be used as the work drive code. Editing starts by first erasing any file with the same file name as the edit file with the file extension of ".BAK". Next a file with the same name as the edit file but with the file extension ".$$$" is created on the work drive. IF the work file already exists the ED.COM program will terminate with the message "FILE EXISTS, ERASE IT.". If the edit file does not exist the ED.COM program reports "NEW FILE". The ED.COM program then await for the user to enter an edit sub command.
newfile ED.COM is used to create a new file called TEST.TXT.The "i" command at the ED command prompt starts insert mode.The three lines of text are entered and at the prompt for line 4 a Ctrl-Z or ASCII SUB is used to return to command mode. The "e" command saves the changes to the file TEST.TXT
When editing a file only the text lines in the memory buffer of ED.COM may be changed. The source edit file is copied line for line starting at the first line of the edit file to the memory buffer. Once the memory buffer is full you must write some or all of the memory buffer to the temporary work file. Once text lines are copied to the temporary disk file you can append the next text lines from the edit file into the memory buffer. The cycle of editing text then writing the memory buffer to the temporary disk file is repeated over and over as you make your way through the edit file. While you can save all your changes and restart the edit session there is no way to retrieve text lines copied to the temporary work file. Once text lines are copied from the memory buffer to the temporary disk file the text lines can not be copied back to the memory buffer without restarting the edit session.
editfile ED.COM is used to edit the file TEST.TXT to correct an error on line 1.The "10a" command appends up to 10 text lines to the memory buffer. The "#t" command displays all the lines from the current line. The "7c" command moves the line position forward 7 characters. The "i" command puts us into insert mode. A space is typed followed by a Ctrl-Z character to return to command mode. The "b" command moves us to the start of the memory buffer. The "t" command is used to check the changes. Finally the "e" command is used to save the changes
When editing a text file ED.COM is in one of two modes; bulk input mode or command mode. Once bulk input mode is started all console input is saved to the memory buffer. When a Ctrl-Z (ASCII SUB) character is read ED.COM exits bulk input mode and enters command mode. The following table contains a list of ED.COM command options:
n A number alone will move the line position by the value of n and then display the current line. If n is negative the line position will move toward the start of the file.
n: A number followed by a full colon will move to the line numbered n if it is in the memory buffer.
:n If used before a command means from the current line to line n.
nA Append up to the next n lines from the edit file to the memory buffer.
B Move to the start of the first line in the memory buffer.
-B Move to the end of the last line in the memory buffer.
nC Move n characters to the right if positive or left if negative in the memory buffer.
nD Delete n character from the current file position. If n is negative the n prior characters are deleted. The first character deleted is the current one.
E End the current edit session. Write all remaining text to the temporary work file. Rename the original edit file with the file extension ".BAK" and rename the work file to the name of the edit file.
nFstring Search the memory buffer for the nth occurrence of the string. If n is positive the search is forward if negative the the search is done in reverse. When the string is found the current position is the character following the matched string. If the "F" is typed upper case the string is treated as all upper case if "F" is typed lower case string is treated as it is typed.
H Save the current edit session exactly as done by the "E" command. Then reopen the saved edit file and start a new edit session.
I Start input mode and insert the lines input from the console device until a Ctrl-Z (ASCII SUB, 1Ah) is read. If a capital "I" is typed then all input is converted to upper case ASCII. If a lower case "i" is typed text is added in the case it is typed.
Istring Insert the string of ASCII characters before the current character.
nJstring1 string2string3 The "J" command is used to do search and replace or search and insert on the lines in the memory buffer.A search is made for string1 the same as the "F" command. IF string1 is found string2 is inserted same as the "Istring" command. Finally delete all characters up to string3. If string3 is not found no delete will be done. If string2 is blank all text between string1 and string3 will be deleted.Each of the three strings is entered on a new line with the first parameter beside the "j" command.
nK The "K" command deletes n lines of text starting from the current line in the memory buffer. If n is negative the lines prior to and including the current lines are deleted.
nL The "L" command move the current position n lines from the current position. If n is negative the current line is moved back toward the start of the memory buffer.
nM The "M" command is used to repeat a series of commands n times.
nNstring The "N" command is used to search for the nth occurrence of string in the entire edit file starting at the currently selected line. The "N" command will execute the equivalent of the "W" and "A" commands in order to scan thru the remaining edit file. This search only operates in the forward direction.
O Restart the edit session abandoning all changes made to the edit file. The work file is deleted and the memory buffer is cleared. The ".BAK" file is lost.
Rfilename The "R" command is used to read a file and insert it into the current edit buffer. The text from the file filename.LIB is added to the edit session as the "I" command does. if filename is not supplied the file $$$$$$$$.LIB will be used.
nSstring1string2 The "S" command is used to perform search and replace. The string1 is found as performed by the "F" command. The string1 is replaced by string2. IF the command is invoked with uppercase "S", string1 and string2 are treated as all uppercase.
nT The "T" command is used to display n lines of text including the current line from the memory buffer. If the n parameter is not supplied a value of one is assumed. If n is negative the text lines prior to the current line are displayed.A special form of the "T" command "#T" will display all the text lines in the memory buffer from the current line.
U The "U" command forces all inserted text to ASCII upper case text. To set no case conversion the "-U" command is used
V The "V" command is used to display line numbers before the asterisk prompt. To display only the asterisk prompt used the "-V" command.A special form of the command "0V" will display the memory buffer free space and total size.
nW The "W" command writes the first n lines from the memory buffer to the work file. This frees space in the memory buffer to read the next lines from the edit file using the "A" command. The n parameter must be a positive number.
nX The "X" command is used to write a copy of the memory buffer text lines to the temporary file "$$$$$$$$.LIB". The line copy starts at the current text line and will copy up to n text lines. The n parameter must be a positive number.The "R" command is used to insert the temporary file into the memory buffer.
nZ The "Z" command will pause for n seconds on a four mega-hertz 8080.