
Page 21-55
2. A zero is entered, moving n to stack level 2.
3. The command DUP, which can be typed in as
~~dup~
,
copies the contents of stack level 1, moves all the stack levels upwards,
and places the copy just made in stack level 1. Thus, after DUP is
executed, n is in stack level 3, and zeroes fill stack levels 1 and 2.
4. The piece of code
→
n S k
stores the values of n, 0, and 0, respectively
into local variables n, S, k. We say that the variables n, S, and k have
been initialized (S and k to zero, n to whatever value the user chooses).
5. The piece of code
0. n START
identifies a START loop whose index
will take values of 0, 1, 2, …, n
6.
The sum S is incremented by k
2
in the piece of code that reads:
k SQ S
+
7.
The index k is incremented by 1 in the piece of code that reads:
1. k +
8. At this point, the updated values of S and k are available in stack levels 2
and 1, respectively. The piece of code
‘
k
‘
STO
stores the value from
stack level 1 into local variable k. The updated value of S now occupies
stack level 1.
9. The piece of code
‘
S
‘
STO
stores the value from stack level 1 into local
variable k. The stack is now empty.
10. The particle NEXT increases the index by one and sends the control to
the beginning of the loop (step 6).
11. The loop is repeated until the loop index reaches the maximum value, n.
12. The last part of the program recalls the last value of S (the summation),
tags it, and places it in stack level 1 to be viewed by the user as the
program output.
To see the program in action, step by step, you can use the debugger as
follows (use n = 2). Let SL1 mean stack level 1:
J2
[‘]
@@@S1@@
`
Place a 2 in level 2, and the
program name, ‘S1’, in level 1
„°LL
@)@RUN@ @@DBG@
Start the debugger. SL1 = 2.
@SST
↓
@
SL1 = 0., SL2 = 2.
@SST
↓
@
SL1 = 0., SL2 = 0., SL3 = 2. (DUP)
@SST
↓
@
Empty stack (-> n S k)
@SST
↓
@
Empty
stack
(
«
- start subprogram)
Содержание 48GII
Страница 1: ...hp 48gII graphing calculator user s guide H Edition 4 HP part number F2226 90020 ...
Страница 162: ...Page 3 37 Define this function by any of the means presented above and check that g 3 3 g 1 0 g 1 0 g 3 9 ...
Страница 201: ...Page 5 30 LIN LNCOLLECT POWEREXPAND SIMPLIFY ...
Страница 381: ...Page 11 55 Function KER Function MKISOM ...
Страница 461: ...Page 13 26 In the right hand side figure above we are using the line editor to see the series expansion in detail ...
Страница 777: ...Page 26 8 ...
Страница 840: ...Page L 5 ...