Editing Files on a PDP-8 using OS/8 EDIT

(all PDP-8 blog entries can be seen by clicking here)

I’ve made good strides toward my goal of assembling a test PDP-8 assembler program. Before I can assemble a program though, first I have to get it onto the PDP-8’s disk. Now I could just paste the program after making edits on my PC, but that is kind of cheating. I really should be able to edit the program on the PDP-8.

There are two editors on the PDP-8: EDIT and TECO. TECO is what I used when I worked on the DEC-10 at TSU, and I hated it enough to still recall how much I hated it. For fun we would type our names into the command prompt and try to guess what might happen to our text file.

Unfortunately EDIT is really not much better. If you ever used edlin in DOS, EDIT is about as ugly.

EDIT is documented in the PDP-8 OS/8 Reference Manual, Section 4. I believe I already mentioned where to find this manual. The PDF file name is AA-H607A-TA_OS8_V3D_sysMan.pdf.

The idea behind EDIT (and TECO for that matter), is you read a page of text from disk into the edit buffer (pages are separated by form feed characters which I will call FF). The edit buffer is about 3000 bytes, so you work on the program page by page.

To create a new file simply type:

CREATE <filename>

to edit an existing file, type:

EDIT <filename>

you will be presented with the ‘#’ prompt. If this is an existing file, you must read the first page into the buffer by typing

#R

To insert text at the top of the buffer, use I. To append to the end, use A. You can start inserting before any line by typing <n>I where <n> is the line number (which is never displayed) such as

#1I
TYPED TEXT 1
TYPED TEXT 2
TYPED TEXT 3
TYPED TEXT 4
TYPED TEXT 5
<control-L> to terminate input
#

The [m[,n]]L command will list the buffer. L by itself displays the entire buffer. 5L displays line 5 and 1,5L displays lines 1 through 5:

#1,5L
TYPED TEXT 1
TYPED TEXT 2
TYPED TEXT 3
TYPED TEXT 4
TYPED TEXT 5

. indicates the current line.  If you type .L the current line is displayed:

#.L
TYPED TEXT 3

. can be used with offsets such as .+1 or .-1.

You can use < and > to move up and down lines of the buffer:

#<TYPED TEXT 2

#<TYPED TEXT 1

#>TYPED TEXT 2

#>TYPED TEXT 3

This lets you easily get the current line set if you don’t have too many lines in the buffer.

To delete a line, use nD where <n> is . or a line number.

#.D

#L
TYPED TEXT 1
TYPED TEXT 2
TYPED TEXT 4
TYPED TEXT 5

To change a line, nC is brute force. It deletes the line indicated by <n>, then waits for you to type in a replacement:

#1C
FIXED TEXT 1
<control-L> typed here
#L
FIXED TEXT 1
TYPED TEXT 2
TYPED TEXT 4
TYPED TEXT 5

As I mentioned, EDIT reads a page from disk into the buffer. When you are done with that page and ready to move to the next type N. This writes the existing page to the output file (P command), clears the buffer (K command), and reads the next page from the input file (R command). You can use the P, K, and R commands individually, but be careful. Doing these commands out of sequence can mess up your file.

When you are done editing, use the E command to exit. This will write the current buffer to the output file, then copy all remaining pages from the input to the output file if you aren’t already on the last page.

As I said, the C command is brute force for fixing a line. There is also the S command (single character search). It has more finesse but is screwy to use even for people like me used to using command line editing.

To invoke the S command, simply type nS where <n> is a line number or .

Then type a single character to find. Assume I have the line

ABC DEF GHI

and . points to that line. I want to start editing at E so I type:

.S
E

When I type the E I actually see:

#.S
ABC DE

The S command is now waiting for me to edit the line. I’m going to just list all of the possibilities here:

  • ctl-G ctl-G stops the editing and returns to the # prompt
  • Typing characters starts inserting them after the displayed text
  • pressing backspace (ctl-H) deletes characters that you see from right to left
  • pressing return deletes everything AFTER what you see
  • pressing ctl-J ctl-L splits the line
  • pressing ctl-L finds the next matching character
  • pressing ctl-G then another character starts searching for the new character

Like I said, screwy.

Last thing to cover is searching. There are two types of searching – intrabuffer (inside the buffer) and interbuffer (across the entire file).

The format of the intrabuffer search is

$<string>'|"L

where $ is actually the escape key. ‘ indicates to start searching at the top of the buffer where ” indicates to search at the next line. To find the line with TEXT in it, I type:

#$TEXT'L
FIXED TEXT 1

To find the next occurrence, simply type:

#"L
TYPED TEXT 2

The interbuffer search is about the same. To invoke it, type the J command first, use the $<string>’ form:

#J
$TEXT'
#.L
FIXED TEXT 1

That covers most of the commands for the PDP-8’s EDIT. Using EDIT I was able to enter the source to my first assembler program:

.TYPE ASM1.PA
/ TEST PROGRAM THAT ADDS 3 AND 4 AND LEAVES THE SUM IN THE ACCUMULATOR
*200
    CLA
    TAD A
    TAD B
    HLT
    JMP I [7600 / RETURN TO MONITOR
A,  0003
B,  0004

.

The next blog installment will be to actually assemble this little test program.

This entry was posted in c-retro and tagged . Bookmark the permalink.

2 Responses to Editing Files on a PDP-8 using OS/8 EDIT

  1. Neil Higgins says:

    Hi Dan. This was very useful – got me off to a quick start. Thank you! I have further reduced it to a cheat sheet, which I am about to post on the PiDP-8 Google Group.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.