summaryrefslogtreecommitdiff
path: root/mem/mem.hex
diff options
context:
space:
mode:
Diffstat (limited to 'mem/mem.hex')
-rw-r--r--mem/mem.hex78
1 files changed, 66 insertions, 12 deletions
diff --git a/mem/mem.hex b/mem/mem.hex
index 63038e3..d30c5b6 100644
--- a/mem/mem.hex
+++ b/mem/mem.hex
@@ -1,25 +1,79 @@
1@0 1@0
2 2
3000 // loop: acc= 0 3// Reset state is acc=0 idx=0
4140 // load 0x40 4
5000 // loop: acc= 0 # Print from 0x70 until we find a 0x00 byte
6170 // ladd 0x70
5300 // ifeq 0 7300 // ifeq 0
6402 // jmp fib 8402 // jmp fib
7f44 // ++idx tx 9f44 // ++idx tx
84fa // jmp loop 104fa // jmp loop
9f20 // fib: idx 11f20 // fib: idx # N.B. acc is 0 at this point (we got here from ifeq 0)
10240 // store 0x40 12270 // store 0x70 # 0x70 is now beginning of Fibonacci sequence (0)
11001 // acc= 1 13001 // acc= 1
12241 // store 0x41 14271 // store 0x71 # 0x71 is 1
13000 // fibloop: acc= 0 15000 // fibloop: acc= 0
14140 // load 0x40 16f10 // swap
15f44 // tx ++idx 17332 // ifeq 50
16140 // load 0x40 1842b // jmp fullydone
17241 // store 0x41 1926f // store 0x6f # 0x6f is current index into Fibonacci sequence
184fa // jmp fibloop 20f10 // swap
21170 // ladd 0x70 # Load next unprinted number in Fibonacci sequence
22f10 // swap
23000 // acc= 0
24f10 // swap
2556b // ascii 0x6b # LSB of ASCII rep
2656c // ascii 0x6c
2756d // ascii 0x6d
2856e // ascii 0x6e # MSB of ASCII rep
29004 // acc= 4
30f10 // swap
31f08 // scan: --idx
32000 // acc= 0
3316b // ladd 0x6b
34f10 // swap
35300 // ifeq 0
36412 // jmp allzeroes
37f10 // swap
38330 // ifeq 0x30
394f7 // jmp scan
40f40 // done: tx
41f10 // swap
42300 // ifeq 0
43404 // jmp space
44f12 // --acc swap
45000 // acc= 0
4616b // ladd 0x6b
474f8 // jmp done
48020 // space: acc= 0x20
49f40 // tx
50000 // acc= 0
51f20 // idx
5216f // ladd 0x6f
53f10 // swap
54402 // jmp nextfib
55f10 // allzeroes: swap
564ef // jmp done
57170 // nextfib: ladd 0x70 # Load just-printed Fibonacci number
58171 // ladd 0x71 # Add about-to-print Fibonacci number
59272 // store 0x72 # Store n+2 Fibonacci number
60f04 // ++idx
614d1 // jmp fibloop
62021 // fullydone: acc= 0x21
63f40 // tx
64f80 // halt
65
66@6c
67
68000 // 6b: LSB of ASCII rep
69000 // 6c: USB of ASCII rep
70000 // 6d: USB of ASCII rep
71000 // 6e: MSB of ASCII rep
72000 // 6f: next index to store in memory image of Fibonacci sequence
19 73
20@40 74@70
21 75
22048 // H 76048 // H # later: start of in-memory Fib sequence
23065 // e 77065 // e
2406c // l 7806c // l
2506c // l 7906c // l