-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeadFish In Gray Snail With Prompt Commented
274 lines (260 loc) · 6.01 KB
/
DeadFish In Gray Snail With Prompt Commented
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
"#This is the number DeadFish works on."
POP a number a000
"#This shows the number during output and is updated when the command is o."
POP a "show number" a
"#I use carry to indicate repetition for incrementing (9 to 0) and decrementing (0 to 9)."
POP a carry a0
"#This makes the code vertically smaller and easier to scroll over.
#I don't want to use this except for that reason."
POP a newline a"
"
"#This is the only thing that is output. All input goes in here."
POP a "all input" a">>"
"input more commands"
OUTPUT "[all input]"
INPUT commands
"analyse commands"
OUTPUT "[all input]"
POP instruction commands [commands]
GOTO "input more commands" [instruction] ""
"#These are all the digits of the number."
"#Temp is used in case the command is not valid."
POP a temp a[number]
POP hundreds temp [temp]
POP tens temp [temp]
POP ones temp [temp]
GOTO "o command" [instruction] o
GOTO "s command" [instruction] s
GOTO "di command" [instruction] d
GOTO "di command" [instruction] i
"#It was not a valid command."
POP a "all input" a"[all input][instruction][newline]>>"
GOTO "analyse commands"
"o command"
GOTO "skip hundreds" [hundreds] 0
POP a "all input" a"[all input]o[newline][number][newline]>>"
GOTO "analyse commands"
"skip hundreds"
GOTO "skip tens" [tens] 0
POP a "all input" a"[all input]o[newline][tens][ones][newline]>>"
GOTO "analyse commands"
"skip tens"
POP a "all input" a"[all input]o[newline][ones][newline]>>"
GOTO "analyse commands"
"di command"
POP a "all input" a"[all input][instruction][newline]>>"
POP a digit aones
"#This will go to i 1, d 1, i 2, d 2, etc. depending on what instruction and ones are."
GOTO "[instruction] [ones]"
"finished with one operation"
"#If carry = 0, I can stop doing this."
GOTO "completely finished" [carry] 0
"#If digit is hundreds, no more changing is possible."
GOTO "completely finished" [digit] hundreds
"#This is in case we have just changed tens, so we have to change hundreds."
GOTO "digit is tens" [digit] tens
POP a digit atens
GOTO "[instruction] [tens]"
"digit is tens"
POP a digit ahundreds
GOTO "[instruction] [hundreds]"
"completely finished"
"#In DeadFish implementation, 256 and 0-1 (999 in this case) become 0."
GOTO "to 000" [hundreds][tens][ones] 256
GOTO "to 000" [instruction][hundreds][tens][ones] d999
POP a number a[hundreds][tens][ones]
"number is changed"
POP a carry a0
GOTO "analyse commands"
"#Number is just set to 000."
"to 000"
POP a number a000
GOTO "number is changed"
"#From here on out, the code consists of single commands which do one or two operations."
"#The variable carry becomes 1 here."
"d 0"
POP a [digit] a9
POP a carry a1
GOTO "finished with one operation"
"d 1"
POP a [digit] a0
POP a carry a0
GOTO "finished with one operation"
"d 2"
POP a [digit] a1
POP a carry a0
GOTO "finished with one operation"
"d 3"
POP a [digit] a2
POP a carry a0
GOTO "finished with one operation"
"d 4"
POP a [digit] a3
POP a carry a0
GOTO "finished with one operation"
"d 5"
POP a [digit] a4
POP a carry a0
GOTO "finished with one operation"
"d 6"
POP a [digit] a5
POP a carry a0
GOTO "finished with one operation"
"d 7"
POP a [digit] a6
POP a carry a0
GOTO "finished with one operation"
"d 8"
POP a [digit] a7
POP a carry a0
GOTO "finished with one operation"
"d 9"
POP a [digit] a8
POP a carry a0
GOTO "finished with one operation"
"#The variable carry becomes 1 here."
"i 0"
POP a [digit] a1
POP a carry a0
GOTO "finished with one operation"
"i 1"
POP a [digit] a2
POP a carry a0
GOTO "finished with one operation"
"i 2"
POP a [digit] a3
POP a carry a0
GOTO "finished with one operation"
"i 3"
POP a [digit] a4
POP a carry a0
GOTO "finished with one operation"
"i 4"
POP a [digit] a5
POP a carry a0
GOTO "finished with one operation"
"i 5"
POP a [digit] a6
POP a carry a0
GOTO "finished with one operation"
"i 6"
POP a [digit] a7
POP a carry a0
GOTO "finished with one operation"
"i 7"
POP a [digit] a8
POP a carry a0
GOTO "finished with one operation"
"i 8"
POP a [digit] a9
POP a carry a0
GOTO "finished with one operation"
"i 9"
POP a [digit] a0
POP a carry a1
GOTO "finished with one operation"
"s command"
POP a "all input" a"[all input]s[newline]>>"
GOTO "square 0[ones]" [number] 00[ones]
GOTO "square 1[ones]" [number] 01[ones]
GOTO "square 2[ones]" [number] 02[ones]
GOTO "square 30" [number] 030
GOTO "square 31" [number] 031
GOTO "to 000"
"square 00"
POP a number a000
GOTO "analyse commands"
"square 01"
POP a number a001
GOTO "analyse commands"
"square 02"
POP a number a004
GOTO "analyse commands"
"square 03"
POP a number a009
GOTO "analyse commands"
"square 04"
POP a number a016
GOTO "analyse commands"
"square 05"
POP a number a025
GOTO "analyse commands"
"square 06"
POP a number a036
GOTO "analyse commands"
"square 07"
POP a number a049
GOTO "analyse commands"
"square 08"
POP a number a064
GOTO "analyse commands"
"square 09"
POP a number a081
GOTO "analyse commands"
"square 10"
POP a number a100
GOTO "analyse commands"
"square 11"
POP a number a121
GOTO "analyse commands"
"square 12"
POP a number a144
GOTO "analyse commands"
"square 13"
POP a number a169
GOTO "analyse commands"
"square 14"
POP a number a196
GOTO "analyse commands"
"square 15"
POP a number a225
GOTO "analyse commands"
"square 16"
GOTO "to 000"
"square 17"
POP a number a289
GOTO "analyse commands"
"square 18"
POP a number a324
GOTO "analyse commands"
"square 19"
POP a number a361
GOTO "analyse commands"
"square 20"
POP a number a400
GOTO "analyse commands"
"square 21"
POP a number a441
GOTO "analyse commands"
"square 22"
POP a number a484
GOTO "analyse commands"
"square 23"
POP a number a529
GOTO "analyse commands"
"square 24"
POP a number a576
GOTO "analyse commands"
"square 25"
POP a number a625
GOTO "analyse commands"
"square 26"
POP a number a676
GOTO "analyse commands"
"square 27"
POP a number a729
GOTO "analyse commands"
"square 28"
POP a number a784
GOTO "analyse commands"
"square 29"
POP a number a841
GOTO "analyse commands"
"square 30"
POP a number a900
GOTO "analyse commands"
"square 31"
POP a number a961
GOTO "analyse commands"
"#I put end here because the interpreter stops reading when it reaches the end of the file."
end