127
File name: HP 12c Pt Converted_user's guide_English_HDP0F123E02_080207
Page: 280 of 281
Printed Date:
{
2007/8/2Dimension: 14.8 cm x 21 cm
Section 9
Branching and Looping
Although the instructions in a program normally are executed in order of their
program line numbers, in some situations it is desirable to have program execution
transfer or “branch” to a program line that is not the next line in program memory.
Branching also makes it possible to automatically execute portions of a program
more than once — a process called “looping.”
Simple Branching
The
i
(
go to
) instruction is used in a program to transfer execution to any
program line. The program line desired is specified by keying its three-digit line
number into the program line containing the
i
instruction. When the
i
instruction is executed, program execution branches or “goes to” the program line
specified and then continues sequentially as usual.
You have already seen a common use of branching: the
gi
000 instruction
(that is stored in program memory after the program you key in) transfers execution
to program line 000. A
i
instruction can be used to branch not only backward
in program memory — as in the case of
gi
000 and as illustrated above —
but also forward in program memory. Backward branching is typically done to
create loops (as described next); forward branching is typically done in
conjunction with a
go
or
gm
instruction for conditional branching (as
described afterward).
Summary of Contents for 12C
Page 1: ...HP 12c Platinum Financial Calculator User s guide H Edition 5 HP part number F2231AA 90001 ...
Page 15: ...Part I Problem Solving ...
Page 48: ...48 Section 3 Basic Financial Functions ...
Page 104: ......
Page 105: ...Part II Programming ...
Page 156: ......
Page 157: ...Part III Solutions ...
Page 230: ......
Page 231: ...Appendices ...
Page 277: ......