Section 10: Program Editing 115Adding Instructions Within a Program

If an instruction is to be added within a program, simply keying it in will replace the instruction previously stored in that program line, as described above; the contents of all higher-numbered program lines remain unchanged.

To add instructions within a program, you could simply key in the new instructions, beginning at the proper program line, followed by the original instructions from that program line through the end of the program. This method is described below under Adding Instructions by Replacement. When instructions must be added in the middle of a long program, however, using this method will require you to key in numerous instructions — namely, the original instructions from the point at which the new instructions are added through the end of program memory. Since keying in these instructions may require a significant amount of time, in such situations you may prefer to use the method described below under Adding Instructions by Branching.

That method basically involves branching to the new instructions which are stored at the end of program memory, then branching back to the program line immediately following the line from which you branched out. Adding instructions by branching is not so simple as adding instructions by replacement; however, it generally will require fewer keystrokes whenever there are more than four program lines between (and including) the first line to be executed after the new instruction(s) and the last line you keyed into program memory. Furthermore, if program memory includes branches to program lines following the point at which the new instruction(s) are being added, adding instructions by branching will not require that you change the line numbers specified in the i instructions, which may be necessary when you add instructions by replacement.

Adding Instructions by Replacement

1.Press fsto set the calculator to Program mode.

2.Press gi. followed by two digits that specify the last program line to be executed before the added instruction(s). This sets the calculator to the proper program line for adding the new instruction(s) in the next step.

3.Key in the new instruction or instructions.

4.Key in the original instruction or instructions, beginning with the first instruction to be executed after the added instruction(s), and continuing through the last instruction you keyed into program memory.

Note: If program memory includes branches to program lines following that

at which the first new instruction is being added, remember to change the line number(s) specified in the i instruction(s) — as described above under Changing the Instruction in a Program Line — to the actual new line number(s).

File name: hp 12c_user's guide_English_HDPMBF12E44

Page: 115 of 209

Printered Date: 2005/7/29

Dimension: 14.8 cm x 21 cm