• Keine Ergebnisse gefunden

Even more ED

Im Dokument been In (Seite 145-148)

In Chapter 11 we learned enough ED controls and commands to enable us to key in a simple little test program. If you are an expert touch typist you could do the same with CPMIO.ASM using only those simple editor facilities. But sooner or later you will have to learn some additional ED commands, as the demands made on you by the exercises in this book become greater.

In that first ED session, we skipped ahead a bunch of lines using the command 3L for skip forward 3 Lines. The number of lines can be either positive, to skip ahead, or negative, to skip backward, as in -3LT which would move us back three lines, and type one line. It is always a good idea to add the T to make sure you are on the line you think you are on.

Console Input/Output 131 We moved all the way back to the Beginning of the editor buffer with the command B and, just as with the other commands, we can reverse this and enter -B to move all the way in the op-posite direction. In this case the opop-posite of beginning is ending, and -B will move us past the last line of text to the end of the buffer, which is the logical place to start adding stufl'.

Since CPMIO has more lines than will fit on the screen of your CON:, you will have to skip back and forth a lot to review the program. When you think it is complete, you can view successive screenfuls of text by going back to the beginning and "typing" 22 lines at a time: B22T. Then 22L22T will display the next screenful.

The 22 is easy to type, and works fine for a 24 line screen. Just make sure you type 22L and not 22K each time.

A dangerous editor command is nK for Kill n lines. You will have to use this command later when you start adding more sub-routines to CPMIO and will want to replace the first test program with another. To do the replacement, you will move the buffer pointer to the beginning of the line labeled ST ARTl: and enter 5K to kill the five lines starting at the buffer pointer position. Then the I command will put you in the insert mode so you can type in a new test program.

When you are ready for that exercise, you will want to use the F for Find command. After loading in CPMIO (#A) you could enter FSTARTlcr and the editor would find the first occurrence of the string STARTl and leave the pointer at the next character following the string. That is not where you want to be! Try FSTARTlctrlzOLT instead. Now ED will find the desired string (terminated by CTRL Z), rewind the pointer to the beginning of the line, and type the line so you can make sure it is the right one.

Remember, ED will do what you say, not always what you want.

For example, suppose you wanted to get from the beginning of the text to the subroutine CO. If you had entered the command FCOctrlzOLT you would see the line:

RCONF EQU 1 ; READ CON: INTO (A)

because the first occurrence of the string "CO" appears in that line, as does the second. To keep from getting lost in words con-taining CO, you could have specified FCO:ctrlzOLT and you would probably get to where you wanted to be. If you hadn't written any

132 Console Input/Output

labels like OUTCO: in the meantime. Now you should be able to appreciate the desirability of always appending the ctrlzOLT to all your Find commands.

Finding your way around large programs is made easier by appending the colon to all program labels. Some assemblers re-quire the colon, so you should always use it to make your programs portable. The CP/M assembler is happy with or without the colon.

Use it to make ED's Find command just as happy.

The combination oflabels with colons and the Find command is a safer way to skip around in a program listing than the use of numbered lines. This is why we disabled line numbering with the

TABLE 12-1. While the CP/M editor ED also provides a number of more powerful text editing features. the subset of commands and controls listed here will be enough to permit entering.

correcting. merging. and splitting up assembler source files.

Keystroke(s)

Append complete file onto editor buffer Enter insert mode

Exit insert mode

Point to beginning of editor buffer Point to end of editor buffer Turn on automatic line numbering Turn off automatic line numbering Write editor buffer to disk and exit Exit ED without writing buffer to disk Move back (-) or ahead (+) n lines Type n lines on console

Kill n lines following current pointer

Find the first occurrence of "string" following current pointer position

Substitute "new" string for "old"

Tab forward to next tab stop (each 8 characters)

Erase and echo last character

Console Input/Output 133

"-V" command in the last chapter. Line numbers are dangerous-they change with every insertion and deletion. Find your way around by labels. They don't change on you.

When you find the text you want to modify, you can kill lines and insert, or substitute one string for another. There are lots of other ED commands, but those discussed in these two chapters and listed in Table 12-1 are all you will need for most of your assembly language work. These form a completely usable subset of what is available, and a set of commands that can do everything you will ever want an editor to do. So get busy and key in CPMIO, so we can assemble and test it and get on to the more fun kind of programs.

Im Dokument been In (Seite 145-148)