HP HP12C hp 12c_user's guide_English_E_HDPMBF12E44.pdf - Page 110

HP HP12C - 12c Financial Calculator Manual

Page 110 highlights

110 Section 9: Branching and Looping Keystrokes gi07 :2 gi08 :1 b fs Display 04- 43, 33 05- 45 06- 43, 33 07- 45 08- -12.36 07 If condition is true, branches to program line 07. 2 If condition is false, recalls 25% tax rate to X-register. 08 Branches to program line 08. 1 Recalls 20% tax rate to X-register. 25 Calculates tax. Sets calculator to Run mode. (Display shows results of running of previous program.) Now, we'll store the required numbers in registers R , R , and R , then we'll run the 01 2 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 20000?0 20?1 25?2 15000 Ê Ê Ê Ê Display 20,000.00 20.00 25.00 15,000. 01- 45 20,000.00 0215,000.00 03- 43 15,000.00 04- 43, 33 Stores test value in register R0. Stores 20% tax rate in register R1. Stores 25% tax rate in register R2. Keys income less than test value into display and X-register. 0 Line 01: :0. Test value has been recalled to X-register, moving income to Y-register. 34 Line 02: ~ Income has been placed in X-register and test value has been placed in Y-register. 34 Line 03: go 07 Condition tested by o was true, so program execution continued with line 04: gi07. File name: hp 12c_user's guide_English_HDPMBF12E44 Printered Date: 2005/7/29 Page: 110 of 209 Dimension: 14.8 cm x 21 cm

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211

110 Section 9: Branching and Looping
File name: hp 12c_user's guide_English_HDPMBF12E44
Page: 110 of 209
Printered Date: 2005/7/29
Dimension: 14.8 cm x 21 cm
Keystrokes
Display
gi
07
04- 43, 33
07
If condition is true, branches to
program line 07.
:
2
05-
45
2
If condition is false, recalls 25% tax
rate to X-register.
gi
08
06- 43, 33
08
Branches to program line 08.
:
1
07-
45
1
Recalls 20% tax rate to X-register.
b
08-
25
Calculates tax.
fs
–12.36
Sets calculator to Run mode.
(Display shows results of running of
previous program.)
Now, we'll store the required numbers in registers R
0
, R
1
, and R
2
, 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
Display
20000
?
0
20,000.00
Stores test value in register R
0
.
20
?
1
20.00
Stores 20% tax rate in register R
1
.
25
?
2
25.00
Stores 25% tax rate in register R
2
.
15000
15,000.
Keys income less than test value into
display and X-register.
Ê
01-
45
0
Line 01:
:
0.
20,000.00
Test value has been recalled to
X-register, moving income to
Y-register.
Ê
02-
34
Line 02:
~
15,000.00
Income has been placed in
X-register and test value has been
placed in Y-register.
Ê
03-
43
34
Line 03:
go
15,000.00
Ê
04- 43, 33
07
Condition tested by
o
was true,
so program execution continued
with line 04:
gi
07.