Post Reply 
Programming Exercise (HP-15C, 15C LE - and others)
03-26-2014, 02:04 PM
Post: #39
RE: Programming Exercise (HP-15C, 15C LE - and others)
Alright, I've managed to implement this on what may be the weakest possible machine that can still handle the algorithm: the Sinclair Cambridge Programmable. The manual is available on Katie's site, but allow me to summarize the notable points for this barely-programmable calculator:

1. Precision is awful. Trig functions are often only accurate to 2 or 3 figures.
2. There's no built-in PI constant, but you can get about 5 digits from 2 * arccos 0 (all trig functions operate in radians). Or just key it in manually for better accuracy.
3. There's no y^x operator. You have to do e^(y * ln x), and like trig, it isn't particularly accurate.
4. You only get 36 completely unmerged program steps to work with. About half the available operations require two steps because of the down-shift key. Constant entry requires an additional 'escape' key.
5. There's only a single storage register. Thankfully, there's an operator to exchange the display with the register, otherwise I don't think this would have been possible.
6. Branching is all absolute, and requires FOUR steps (shift, go to/go if neg, two-digit step number).
7. 'go if neg' is the only conditional test available. If the display is negative, it acts like go to, otherwise skips the next two steps (the line number).

To use, enter the desired number of iterations (e.g. 10000) in the display, and press RUN.

Code:
00    sto
01    #        Escape key to begin constant entry (terminated by any operator)
02    0
03    +
04    (
05    rcl
06    -
07    #
08    1
09    x        Calculator has no operator precedence. This becomes (n - 1) * n.
10    rcl
11    /        The four operators change meaning when followed by another operator.
12    )        Division changes to 1/x from the ).
13    =
14    v        The downshift key.
15    MEx        Swap display with storage register.
16    -
17    #
18    3
19    =
20    v
21    go if neg        Exit loop if n = 2. (n - 3 < 0)
22    3
23    4
24    +
25    #
26    1
27    =
28    v
29    MEx        Put loop counter back in storage and bring back accumulator.
30    v
31    go to        Go again.
32    0
33    3
34    rcl        Get the accumulated result and stop execution.
35    stop

100 iterations (50 actual passes through the loop) takes 18.5 seconds. A full run of 10000 iterations would clock in at about 30 minutes.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Programming Exercise (HP-15C, 15C LE - and others) - Dave Britten - 03-26-2014 02:04 PM



User(s) browsing this thread: 1 Guest(s)