press g P/R
to toggle programming mode, GTO . <nnn>
to jump to a
line, BSP
to delete a line, and g RTN
to end a program.
table of contents
exponent function ¶
(for positive integers only. uses 2 stack and registers I, 0)
borrowed from this blog and modified avoid messing up stack
num | keys | display | description |
001 | LBL E | 43,22, E | convenient entry point |
002 | STO I | 44 I | store in I |
003 | R↓ | 33 | pop old I value |
004 | STO 0 | 44 0 | store in 0 |
005 | DSZ | 43 23 | decrement I and nop branch |
006 | LBL 0 | 43,22, 0 | label for loop target |
007 | RCL 0 | 45 0 | push 0 to stack |
008 | * | 20 | multiply it |
009 | DSZ | 43 23 | decrement and branch unless 0 |
010 | GTO 0 | 22 0 | I is not 0, loop again |
011 | RTN | 43 21 | return |
natural log ¶
(uses 3 stack, flag 0, and registers I, 0)
based on part of an algorithm from Valentín Albillo's Boldly Going article but reworked to not mess up the stack
num | keys | display | description |
012 | LBL 7 | 43,22, 7 | entry point |
013 | ENTER | 36 | dup |
014 | 1/x | 43 26 | inverse |
015 | CF 0 | 43, 5, 0 | default flag |
016 | x>y | 43 3 | input<1? |
017 | SF 0 | 43, 4, 0 | save for later |
018 | + | 40 | add inverse |
019 | 2 | 2 | float mode: |
020 | / | 10 | no shifts ;_; |
021 | 1 | 1 | put 1 |
022 | STO I | 44 32 | into I |
023 | 1 | 1 | |
024 | 5 | 5 | |
025 | EEX | 42 49 | |
026 | CHS | 49 | |
027 | 6 | 6 | make big const |
028 | + | 40 | 1+ from before |
029 | x<->y | 34 | swap for inp n |
030 | LBL 9 | 43,22, 9 | loop target |
031 | STO 0 | 44 0 | store old val |
032 | 1 | 1 | |
033 | + | 40 | increment |
034 | 2 | 2 | |
035 | / | 10 | halve |
036 | sqrt | 43 25 | |
037 | ISZ | 43 24 | increment I |
038 | x>y | 43 3 | x>y? |
039 | GTO 9 | 22 9 | yes, loop |
040 | R↓ | 33 | |
041 | R↓ | 33 | pop unneeded |
042 | RCL 0 | 45 0 | restore old |
043 | 1 | 1 | |
044 | - | 30 | decrement |
045 | ENTER | 36 | |
046 | + | 40 | double |
047 | sqrt | 43 25 | |
048 | DSZ | 43 23 | put I back |
049 | DSZ | 43 23 | decrement I |
050 | LBL 8 | 43,22, 8 | loop target |
051 | ENTER | 36 | |
052 | + | 40 | double |
053 | DSZ | 43 23 | decrement I |
054 | GTO 8 | 22 8 | I not 0, loop |
055 | F? 0 | 43, 6, 0 | recall input<1 |
056 | CHS | 49 | yes, negate |
057 | RTN | 43 21 | return |
factorial ¶
(for integers > 1 only. uses 2 stack and register I)
num | keys | display | description |
058 | LBL F | 43,22, F | entry point |
059 | STO I | 43 32 | store in I |
060 | DSZ | 43 23 | skip first |
061 | LBL 4 | 43,22, 4 | loop target |
062 | RCL I | 45 32 | push I |
063 | * | 20 | multiply I |
064 | DSZ | 43 23 | decrement I |
065 | GTO 4 | 22 4 | not 0? loop |
066 | RTN | 43 21 | return |