blob: d30c5b694f7eb5d2b53f731ed02c999788fb87f0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
@0
// Reset state is acc=0 idx=0
000 // loop: acc= 0 # Print from 0x70 until we find a 0x00 byte
170 // ladd 0x70
300 // ifeq 0
402 // jmp fib
f44 // ++idx tx
4fa // jmp loop
f20 // fib: idx # N.B. acc is 0 at this point (we got here from ifeq 0)
270 // store 0x70 # 0x70 is now beginning of Fibonacci sequence (0)
001 // acc= 1
271 // store 0x71 # 0x71 is 1
000 // fibloop: acc= 0
f10 // swap
332 // ifeq 50
42b // jmp fullydone
26f // store 0x6f # 0x6f is current index into Fibonacci sequence
f10 // swap
170 // ladd 0x70 # Load next unprinted number in Fibonacci sequence
f10 // swap
000 // acc= 0
f10 // swap
56b // ascii 0x6b # LSB of ASCII rep
56c // ascii 0x6c
56d // ascii 0x6d
56e // ascii 0x6e # MSB of ASCII rep
004 // acc= 4
f10 // swap
f08 // scan: --idx
000 // acc= 0
16b // ladd 0x6b
f10 // swap
300 // ifeq 0
412 // jmp allzeroes
f10 // swap
330 // ifeq 0x30
4f7 // jmp scan
f40 // done: tx
f10 // swap
300 // ifeq 0
404 // jmp space
f12 // --acc swap
000 // acc= 0
16b // ladd 0x6b
4f8 // jmp done
020 // space: acc= 0x20
f40 // tx
000 // acc= 0
f20 // idx
16f // ladd 0x6f
f10 // swap
402 // jmp nextfib
f10 // allzeroes: swap
4ef // jmp done
170 // nextfib: ladd 0x70 # Load just-printed Fibonacci number
171 // ladd 0x71 # Add about-to-print Fibonacci number
272 // store 0x72 # Store n+2 Fibonacci number
f04 // ++idx
4d1 // jmp fibloop
021 // fullydone: acc= 0x21
f40 // tx
f80 // halt
@6c
000 // 6b: LSB of ASCII rep
000 // 6c: USB of ASCII rep
000 // 6d: USB of ASCII rep
000 // 6e: MSB of ASCII rep
000 // 6f: next index to store in memory image of Fibonacci sequence
@70
048 // H # later: start of in-memory Fib sequence
065 // e
06c // l
06c // l
06f // o
02c // ,
020 // ' '
077 // w
06f // o
072 // r
06c // l
064 // d
021 // !
00a // \n
000
|