• Keine Ergebnisse gefunden

Getting to know ED

Im Dokument been In (Seite 126-130)

The CP/M manuals for ED, ASM, and DDT are complete and detailed, but you will not have to memorize all of their contents in order to get started writing, assembling, and debugging programs.

111

112 Learning by Doing

We will start this section with a short tutorial on these operations.

This will not be a replacement for the CP/M manuals, but an introduction to them. You will have to learn most of their contents eventually, but you can get started with the simplified subset of commands that we will be presenting in this chapter.

Since we have become familiar with the little test program first presented in the Introduction, it is the obvious choice for your first exercise in learning ED and ASM. It constitutes a stand-alone program, that can be edited, assembled, and then executed in the TP A all by itself. As soon as we have done that we will finally abandon that program, and begin compiling the library of sub-routines that you will use in all future programs as a means of separating the user from the system, as was discussed in the pre-ceding section.

There are only two control keys you will have to learn to enter the text of the exercise using ED. These are CTRL Z and CTRL 1.

"CTRL" implies that the computer operator holds down the con-trol key while typing the designated letter. In other words, press and hold the key marked CTRL or CONTROL, then press and release the designated letter key, and then release the control key.

The designated letters were here shown in capitals, but the control code delivered by the keyboard will be the same even if the key-board is not in the all caps mode.

Assembly language programs should all be typed in upper case only, if for no other reason than to make the resulting source programs more portable. All computer systems will recognize the caps only mode, since only a few years ago lower case was a rarity on inexpensive terminals like our old friend the TTY. So start by setting your keyboard to the ALL CAPS or ALPHA LOCK mode or its equivalent.

Let's get started. Fire up your CP/M based computer and insert a diskette into drive A: that includes ED. COM, ASM.COM, LOAD.COM and DDT.COM, along with lots of workspace. When CP/M prompts for a command input, enter:

ED TEST.ASMcr

where "cr" indicates your pressing the carriage return key. The editor will be loaded and will inform you that this is a new file, and then will sign on with the prompt"*" showing that it is in the command mode.

Learning by Doing 113 The first command you may have to enter is "-Y" to turn off ED's automatic line numbering. If the "*" prompt appears in-dented 8 spaces from the left edge of your terminal display, your version of ED comes up with line numbering enabled. For con-sistency with the examples in this book, turn it off with the "minus . Y" command.

Now, since you want to be in the input mode, enter the command ''I'' and a carriage return (CR). The cursor will return to the left column of the next line on the screen. This is the only the cursor to space over to the eighth column on the screen. Here enter EQU and another tab (since CTRL I = TAB we will refer to it simply as "tab" from now on). ED moves the cursor to column 16 following the second tab, and here you enter 5 and terminate the line with a carriage return. Now you are off and running as an assembly language programmer.

Enter the second line the same way:

WCONFtabEQUtab2er

and to keep things lined up the way they are in Listing 11-1, enter the third line starting with the tab:

tabORGtab 1 DDHer

114 Learning by Doing

since it doesn't start with a label. And so on through the prograJTl.

When all of the lines are entered, the cursor should be at the left column of the line following END. Now enter CTRL Z to exit the input mode and return to the editor command mode. Enter the command sequence:

B8Ter

and ED will return his text pointer to the Beginning of the text buffer, and Type eight lines: your program.

If you make a mistake while typing, and catch it as soon as you make it, you can use the DEL, RUB, or RUBOUT key on your terminal to erase the last character entered. On most terminals you will not see the cursor back up over the deleted character, but instead will see the character duplicated, indicating that ED has erased it internally.

If you don't catch the mistake until you list the whole program (B8Tcr), then you will have to skip down in the text to where the mistake is and correct it by substituting the correct word or replac-ing the entire line. Suppose your line 4 got entered as:

MIV C,WCONF

You can skip down from the beginning of the text buffer where the pointer is now sitting (following your command of B) and type the bad line by entering the command sequence:

3LT

which tells ED to move down 3 Lines and Type one line. It is always a good idea to Type the line before you try to change it, as then you will know you are starting with the text buffer pointer pointing at the beginning of the correct line. No, the incorrect line.

Now use the Substitute command to fix the error:

SMIV etr lzMVIctr lzOL Ter

by entering

"s"

for the Substitute command, a copy of the bad text (MIV), a terminator (CTRL Z), the desired text (MVI) and another terminator. Since ED allows you to string command sequences

Learning by Doing 115 together, we have added "0" (zero, not Oh) and LT before the carriage return. This says to ED that after substituting MVI for MIV we want him to point back at the beginning of the Line and Type it. Always include the OLT to make sure you changed what you wanted to change.

In these examples we have been using lower case letters to indicate control key keystrokes, like ctrlz and cr. The usual control keys CR and LF and RUBOUT or DELETE will produce actions, while the two-keystroke CTRL keys will be shown on your termi-nal as an up arrow followed by the designated letter. To make the lines more readable in this text, we have spelled out these controls.

What you see on your CON: screen will differ slightly.

When the text of our example program is all correct, rewind the buffer pointer to the Beginning (Bcr) and exit ED by typing the single command E and a carriage return. The text will be written to the disk as file TEST.ASM, and CP/M will be reloaded. Enter the CCP command DIRcr and you should see two new directory entries:

TEST BAK TEST ASM

created by ED. The .ASM file will contain your program, and the . BAK file will be empty, since this was a new file creation and not an update. You can use the CCP command TYPE to verify this (see Chap. 5).

You have now entered, and maybe corrected, an assembler source program. This has been done with an absolute minimum of ED commands and controls. In most of your work you will not be using very many more of the facilities offered by ED. All the complicated goodies that come with ED, like multiple find and replace command sequences, are nice to have when you need them, but there is no need to spend the effort to learn them for awhile yet. So let's get on to the assembler.

Im Dokument been In (Seite 126-130)