• Please review our updated Terms and Rules here

ed tutorial

decuser

New Member
Joined
Mar 8, 2005
Messages
6
I have CP/M 2.2 on my TRS 80 Model 100 and I have used ED to create a sample.asm file on disk. It compiles without error, but I get an error when I run it. I suspect my ORG 0CC00H statement is to blame. But, I cannot for the life of me, figure out how to edit the file. So, my question is... do you know of a good tutorial for learning ed. The CP/M documentation might be swell if you have a clue as to what you're doing, but I don't, so I'm hoping you know of a here's an edit session style doc.

- will
 
Found a video, but if you have a good written resource, that'd be great. Here's the link to the video:


Pretty much boiled down to bringing in the source file with 'A', very counter intuitive. The 'A' for append refers to appending lines from the file to the buffer. That said, once you have that working.... 'A' to append, 'I' to insert, 'B' to go to start of buffer, 'V' to turn on line numbers, '-V' to turn 'em off, 'P' and 'T' to print lines, 'K' to kill a line, 'E' to save, 'Q' to abort... seems to work.
 
What bothers me about using ed is that there is nothing like a help overlay.

Wordstar at least had this, so when I haven't used a function recently, I can find it quickly and I know what I need to do to find it. Memory is limited to bringing up the help menu.

And as I use it more, I remember the commands.

This does not exist in ed afaik and having to carry around a piece of paper with instructions is problematic.

I think this is a common issue with editors of old. They all have powerful commands that make life easier, but require detailed familiarity to get there.

So I never really liked any of them before Wordstar.

And then later we got GUI which makes all the options inherently available.

The need to keep memory small makes including any volume of text, without using overlays and swapping memory out to disk, somewhat problematic, but again, it's what I really liked about Wordstar.
 
Ed is described in the CP/M manual. It can be quite powerful, BTW--far more so than MSDOS EDLIN.


Manuals were hard to come by in the early years. They were something people bought with new computers, and were missing from cheaper second-hand sales of said computer, lost or misplaced or the owner didn't really care. Maybe discarded. When I did get a manual, it was like having gold in my hands...

But it doesn't help at all even if you have the manual if it's not around, and you can't practically carry a manual with a luggable.

Wordstar though... it had the manual built in.

I used to use a lot of different editors and a lot of different languages on a lot of different platforms. It taught me to truly appreciate being able to just load up a piece of software and use it without needing to refer to instructions.

Of course, had I had to, I would have used ed as well, but I did very little with early CP/M machines... And yeah, I used edlin on DOS. I've forgotten how to use it, but I still remember the name. And I used debug too and for a while even remembered enough calls to write a disk copy routine in a pinch using debug.

But software that I don't need to remember is preferred :) I truly love good helpscreens.
 
Wordstar was never made to run over a TTY or 300 bps serial cable or on the smallest (20K) CP/M system. And it would not fit easily on the smallest (e.g.90K Osborne I) system disk.

One might as well ask why CP/M 2.2 didn't come with a graphical desktop publishing application as standard. Even MS-DOS only had EDLIN.

Oranges to oranges.
 
Wow, edlin. That's a trip down memory lane. On Unix, it was ed (not to be confused with CP/M ed) and so far as I can tell there's never been a simpler editor to use... once you master i for insert, a for append, and whatnot. No built in help, but man ed worked and still does. I use it's power every day in vi :). Oh, and it works just fine on v6 unix running on a PDP11 w/limited RAM w/an ASR33, etc... Not so sure about 20k though.

As for the CP/M ed manual - ick. Now that I know some things, it's ok, But after quite a bit of perusing it, I still couldn't work out how it actually edited an existing file. When I saw in the video text being brought into the editor from a file, it clicked, but the manual - decidedly unhelpful. Contrast that with the ed tutorial of the Unix Programmer's manual for v6... no comparison, instantly productive. That was 1975 or so though, so maybe they'd worked out the how to write a useful manual by then... or Brian Kernighan might have been a better technical writer :).

Anyhow, the good news is I found vedit and it works as a visual editor and the howto that I found with it seems to help. But... the wordstar idea is even better, if it'll work with 2.2... off to see about that. I seem to remember it having a text file mode or somesuch.
 
Or write your own if you have a memory-mapped video display. I did, around 1978; small, fast and it did what I needed. As pointed out, CP/M was originally intended for use with a TTY and could not even assume that you had an addressable cursor to display. I think that an old issue of Kilobaud from around that time even published the source of a simply WYSIWYG text editor for CP/M.
 
Anyhow, the good news is I found vedit and it works as a visual editor and the howto that I found with it seems to help. But... the wordstar idea is even better, if it'll work with 2.2... off to see about that. I seem to remember it having a text file mode or somesuch.

Yes, Wordstar can edit text as well as documents. It is decided when you open the file what mode you want to edit it in.
 
Or write your own if you have a memory-mapped video display. I did, around 1978; small, fast and it did what I needed. As pointed out, CP/M was originally intended for use with a TTY and could not even assume that you had an addressable cursor to display. I think that an old issue of Kilobaud from around that time even published the source of a simply WYSIWYG text editor for CP/M.

I will likely end up writing a small editor when I finish the assembler, though I've often wondered what data structures are optimal for editing large text files directly from disk, especially when inserting text mid-document. A non-linear structure when using memory is fine, and allows for undoing changes until saved, but I've often wondered what the best data structures are when editing files on disk, and how best to balance disk access, memory access and speed of access.
 
As I recall, the Kilobaud editor simply read in a block of text, with a "split" between the before- and after-cursor sections. Like ED, if the file is too large to hold entirely in memory, you write the old text out and read in a new block of text. On a 64KB 8-bit machine, that rarely happens with a programmer's editor.
 
I will likely end up writing a small editor when I finish the assembler, though I've often wondered what data structures are optimal for editing large text files directly from disk, especially when inserting text mid-document.
There are a few well-known data structures designed for editor uses, such as gap buffers, ropes or piece tables. But the on-disk format of a text file is always linear without gaps, so your options are quite limited. In CP/M, inserting text and saving will always require rewriting the remainder of the file. I don't know if CP/M will create a fragmented file if the amount of data to insert is a multiple of the file system block size, but that is unlikely anyway.

In order to efficiently work with partially loaded files, you could use a temporary file to store blocks of data discontiguously, and then rewrite the output file on saving.

Unfortunately, most editors only allow loading files which fit in memory. I'd like a "vi" clone which can do better than that, but I don't think CP/M offers that.
 
Old thread from Google groups:
and

I've used VEDIT--it's not bad.
 
Back
Top