annotate 3rdparty/packages/brainfuck/bf.asm @ 3199:dd553bb32ebb

3rdparty: Changed the names of many disks for easier reading
author Bill Pierce <merlinious999@gmail.com>
date Tue, 06 Jun 2017 23:59:39 +0200
parents 83bf26264aa6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3086
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
1 ********************************************************************
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
2 * bf - Brainfuck Language Interpreter
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
3 *
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
4 * $Id$
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
5 *
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
6 * This is a simple interpreter for the Brainfuck language:
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
7 * https://en.wikipedia.org/wiki/Brainfuck
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
8 *
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
9 * Edt/Rev YYYY/MM/DD Modified by
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
10 * Comment
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
11 * ------------------------------------------------------------------
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
12 * 1 2015/10/02 Boisy G. Pitre
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
13 * Created.
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
14 *
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
15
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
16 ifp1
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
17 use defsfile
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
18 endc
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
19
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
20 tylg set Prgrm+Objct
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
21 atrv set ReEnt+rev
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
22 rev set $00
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
23 edition set 1
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
24
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
25 mod eom,name,tylg,atrv,start,size
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
26
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
27 pSize equ 12000
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
28 dSize equ 3000
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
29
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
30 org 0
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
31 pmem rmb pSize
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
32 dmem rmb dSize
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
33 stack rmb 200
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
34 size equ .
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
35
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
36 name fcs /bfp/
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
37 fcb edition
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
38
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
39 * initialize interpreter
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
40 * clear program memory
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
41 start
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
42 lda #READ.
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
43 os9 I$Open
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
44 lbcs error
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
45 ldy #pSize
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
46 leax pmem,u
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
47 os9 I$Read
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
48 lbcs error
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
49 os9 I$Close
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
50 tfr y,d nul terminate program string in memory
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
51 clr d,x
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
52
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
53 leay dmem,u
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
54 ldd #dSize
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
55 clrloop clr ,y+
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
56 subd #$0001
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
57 bne clrloop
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
58 leay dmem,u
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
59 bra parse
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
60
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
61 ptrInc
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
62 leay 1,y
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
63 bra parse
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
64
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
65 ptrDec
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
66 leay -1,y
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
67 bra parse
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
68
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
69 dataInc
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
70 inc ,y
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
71 bra parse
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
72
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
73 dataDec
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
74 dec ,y
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
75 bra parse
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
76
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
77 putChar
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
78 pshs d,x,y
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
79 lda #1
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
80 tfr y,x
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
81 ldy #1
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
82 os9 I$Write
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
83 puls d,x,y,pc
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
84
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
85 getChar
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
86 pshs d,x,y
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
87 clra
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
88 tfr y,x
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
89 ldy #1
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
90 os9 I$Read
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
91 puls d,x,y,pc
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
92
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
93
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
94 brOpen lda #1
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
95 pshs a
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
96 tst ,y
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
97 bne brOpenBye
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
98 brOpenDo
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
99 lda ,x+
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
100 cmpa #'[
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
101 bne brOpenCkClose
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
102 inc ,s
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
103 bra brOpenDoTest
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
104 brOpenCkClose
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
105 cmpa #']
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
106 bne brOpenDoTest
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
107 dec ,s
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
108 brOpenDoTest
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
109 tst ,s
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
110 bne brOpenDo
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
111 brOpenBye
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
112 puls a,pc
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
113
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
114 brClose
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
115 clr ,-s
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
116 brCloseDo
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
117 lda ,-x
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
118 cmpa #'[
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
119 bne brCloseCkClose
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
120 inc ,s
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
121 bra brCloseDoCont
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
122 brCloseCkClose
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
123 cmpa #']
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
124 bne brCloseDoCont
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
125 dec ,s
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
126 brCloseDoCont
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
127 tst ,s
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
128 bne brCloseDo
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
129 puls a,pc
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
130
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
131 * X = Brainfuck program pointer (nul byte terminates)
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
132 * Y = Brainfuck data pointer
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
133 parse
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
134 lda ,x+
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
135 beq parseEnd
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
136 cmpa #'>
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
137 bne a1
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
138 leay 1,y
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
139 bra parse
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
140 a1 cmpa #'<
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
141 bne a2
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
142 leay -1,y
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
143 bra parse
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
144 a2 cmpa #'+
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
145 bne a3
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
146 inc ,y
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
147 bra parse
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
148 a3 cmpa #'-
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
149 bne a4
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
150 dec ,y
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
151 bra parse
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
152 a4 cmpa #'.
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
153 bne a5
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
154 bsr putChar
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
155 bra parse
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
156 a5 cmpa #',
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
157 bne a6
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
158 bsr getChar
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
159 bra parse
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
160 a6 cmpa #'[
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
161 bne a7
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
162 bsr brOpen
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
163 bra parse
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
164 a7 cmpa #']
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
165 bne parse unrecognized character -- keep parsing
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
166 bsr brClose
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
167 bra parse
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
168
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
169
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
170 parseEnd
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
171 clrb
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
172 error
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
173 os9 F$Exit
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
174
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
175 EMOD
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
176 eom EQU *
83bf26264aa6 Added brainfuck interpreter
boisy@tee-boy.com
parents:
diff changeset
177 END