Keys income less than test value into display and X-register.
Line 001: :0.
Stores test value in register R0.

Keystrokes (ALG mode)

:0

~

§

go

gi009

:2

gi010

:1 b

}

fs

Section 9: Branching and Looping 133

Display

 

 

 

002,

45

0

Recalls test value into X-register

 

 

 

and places income in Y-register.

003,

 

34

Places income in X-register and

 

 

 

test value in Y-register.

004,

 

20

Prepares for multiplication.

005,

43

34

Tests whether number in X-register

 

 

 

(income) is less than or equal to

 

 

 

number in Y-register (20,000).

006,43,33,009

If condition is true, branches to

 

 

 

program line 009.

007,

45

2

If condition is false, recalls 25%

 

 

 

tax rate to X-register.

008,43,33,010

Branches to program line 010.

009,

45

1

Recalls 20% tax rate to X-register.

010,

 

25

Divides tax rate by 100.

011,

 

36

Calculates tax.

–190.22

 

 

Sets calculator to Run mode.

 

 

 

(Display shows results of running

 

 

 

of previous program.)

Now, we'll store the required numbers in registers R0, R1, and R2, then we’ll run the program, using Ç so that we can check that the branching occurs properly. It’s good practice with programs containing conditional test instructions to check that the program branches correctly for all possible conditions: in this case, if the income is less than, equal to, or greater than the test value.

Keystrokes (RPN mode)

20000?0

20?1

25?2

15000

Ê

Display

20,000.00

20.00Stores 20% tax rate in register R1.

25.00Stores 25% tax rate in register R2.

15,000.

001, 45 0

File name: hp 12c pt_user's guide_English_HDPMF123E27

Page: 133 of 275

Printed Date: 2005/8/1

Dimension: 14.8 cm x 21 cm

Page 133
Image 133
HP 12C Financial 12C manual 006,43,33,009, 008,43,33,010, 20,000.00, 15,000 001, 45