Adding Instructions by Branching. HP 12C Platinum Financial Calculator, 12c

Add to My manuals
278 Pages

advertisement

Adding Instructions by Branching. HP 12C Platinum Financial Calculator, 12c | Manualzz

144 Section 10: Program Editing

Keystrokes

(ALG mode)

Þ

Display

+

:9

} fs

15000t t

013, Keys new instruction into program line 013.

014, Keys new instruction into program line 014.

015, 45 9 Keys new instruction into program line 015.

016, Keys new instruction into program line 016.

12,000.00

Sets calculator back to Run mode.

3,000.00

12,000.00

Twenty percent tax on $15,000 income.

Net income after 20% tax is subtracted from $15,000 income.

Adding Instructions by Branching

1. Press fs to set the calculator to Program mode.

2. Press gi. followed by three digits that specify the program line immediately preceding the point at which the new instruction(s) are being added — usually, the last program line to be executed before the added instruction(s). This sets the calculator to the proper program line for inserting a i instruction in the next step. This i instruction will replace whatever instruction was already stored there, but that instruction will be keyed back into program memory, to be executed just after the new instructions, in step

7.

3. Press gi followed by three digits that specify the second line after the last line you keyed into program memory. (Branching to the second line rather than to the first is necessary because the first line following the last program in program memory must contain a i000 instruction. The i000 instruction ensures that program execution will branch to line 000 and halt after the program is run.) For example, if the last line you keyed into program memory was line 010, you would press gi012 at this step, preserving the gi000 in line 011.

4. Press gi. followed by three digits that specify the last line you keyed into program memory.

5. Press gi000. This automatically converts a data storage register into seven additional lines of program memory (if there was not already a gi000 instruction remaining at the end of program memory), and it

File name: hp 12c pt_user's guide_English_HDPMF123E27 Page: 144 of 275

Printed Date: 2005/8/1 Dimension: 14.8 cm x 21 cm

Section 10: Program Editing 145

ensures that program execution will branch to line 000 after the program is run.

6. Key in the instruction(s) being added.

7. Key in the instruction that originally immediately followed the point at which the new instruction(s) are being added — that is, the first instruction to be executed after the added instruction(s). (This instruction was replaced by the i instruction keyed in at step 3.)

8. Press gi followed by three digits that specify the second line following the point at which the new instruction(s) are being added. This i instruction will cause program execution to branch back to the proper line within the original program.

Example: Continuing with the preceding example, suppose incomes less than or equal to $7,500 were not to be taxed. You could modify the program to check for this condition and stop at line 000, displaying the original income keyed in, by storing 7,500 in register R

3

and adding the following instructions between lines

000 and 001 (the added lines are the same in RPN and ALG modes):

:3~gogi000. Since there are more than four instructions between

(and including) the first line to be executed after the added instructions (line 001) and the last line you keyed into program memory (line 010 in RPN and line 016 in

ALG), it will require fewer keystrokes to add the new instructions by branching than to add them by replacement.

Keystrokes

(RPN mode)

Display fs gi.000 gi012 gi.010 gi000

Sets calculator to Program mode.

000, Sets calculator to program line immediately preceding point at which new instructions are being added. (In this particular example, this step could have been skipped since calculator was already set at the proper program line.)

001,43, 33, Branches to program line 012, the second line after last line of program.

010, Sets calculator to last line of program so that the gi000 instruction keyed in next will be stored as the last line of the current program.

011,43, 33, Ends the current program with a gi000.

File name: hp 12c pt_user's guide_English_HDPMF123E27 Page: 145 of 275

Printed Date: 2005/8/1 Dimension: 14.8 cm x 21 cm

146 Section 10: Program Editing

Keystrokes

(RPN mode)

:3

~ go gi000

:0

Display

43 34

Added instructions. gi002 fs

7500?3

6500t

15000t t

45 Keys in instruction immediately following point at which new instructions are being added. (This instruction was replaced in line

001 by gi012 instruction.)

017,43, 33, Branches back to second line (line

002) following point at which new instructions are being added.

12,000.00 Sets calculator back to Run mode.

7,500.00

6,500.00

3,000.00

12,000.00

Stores test value in register R

3

.

Runs program for income less than

$7,500. Display shows original income keyed in, indicating that tax is zero.

Tax on $15,000 income.

Net income after tax. This shows program still works for an income greater than $7,500 and less than

$20,000.

Keystrokes

(ALG mode) fs gi.000

Display

000,

Sets calculator to Program mode.

Sets calculator to program line immediately preceding point at which new instructions are being added. (In this particular example, this step could have been skipped since calculator was already set at the proper program line.)

File name: hp 12c pt_user's guide_English_HDPMF123E27 Page: 146 of 275

Printed Date: 2005/8/1 Dimension: 14.8 cm x 21 cm

Keystrokes

(ALG mode) gi018 gi.016 gi000

:3

~ go gi000

?9 gi002 fs

7500?3

6500t

15000t t

Section 10: Program Editing 147

Display

001,43, 33, Branches to program line 018, the second line after last line of program.

016, Sets calculator to last line of program so that the gi000 instruction keyed in next will be stored as the last line of the current program.

017,43, 33, Ends the current program with a gi000.

45

019,

43 34

Added instructions.

021,43, 33,

44 Keys in instruction immediately following point at which new instructions are being added. (This instruction was replaced in line

001 by gi018 instruction.)

023,43, 33, Branches back to second line (line

002) following point at which new instructions are being added.

12,000.00

7,500.00

Sets calculator back to Run mode.

6,500.00

Stores test value in register R

3

.

Runs program for income less than

$7,500. Display shows original income keyed in, indicating that tax is zero.

3,000.00

Tax on $15,000 income.

12,000.00

Net income after tax. This shows program still works for an income greater than $7,500 and less than

$20,000.

File name: hp 12c pt_user's guide_English_HDPMF123E27 Page: 147 of 275

Printed Date: 2005/8/1 Dimension: 14.8 cm x 21 cm

148 Section 10: Program Editing

The following illustration of the edited RPN program shows how program execution branches to the instructions added at the end of program memory, then branches back. While the actual program in ALG mode is different, the illustration does indicate the method used.

File name: hp 12c pt_user's guide_English_HDPMF123E27 Page: 148 of 275

Printed Date: 2005/8/1 Dimension: 14.8 cm x 21 cm

advertisement

Key Features

  • Financial Pocket Black, Silver
  • 10 digits
  • Memory registers: 20

Related manuals

advertisement

Table of contents