summaryrefslogtreecommitdiff
path: root/web/spiderweb/src/68k/68k.spider
blob: b3f7a8943a0ed68d56a796e4547c87b901d23843 (plain)
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
# 68k.spider
# Copyright (C) 1991,1992 by Izumi Watanabe, FUJI PHOTO FILM co., ltd.
# email address nabe@miya.fujifilm.co.jp 
# This source is trial to generate an assembler-WEB.
#
# For Assembler weave, I use simple idea;
# label, opecode and operands are in a TeX's \hbox.

language asm-68K extension 68k
at_sign @

comment begin <";"> end newline
line begin <";"-space-"line"> end <"">

default translation <*> mathness yes

token identifier category sym mathness yes
token number category math mathness yes
token newline category ignore_scrap mathness no translation <>
token pseudo_semi category ignore_scrap mathness maybe translation <>

module definition stmt use pure_stmt

macros begin
\def\opsize{6em}
\def\opbox#1{\hbox to\opsize{#1\hfill}} % Use in code
\def\popbox#1{#1\quad}			% Use in comments
\def\OPbox#1{{\let\&=\. \opbox{#1}}}
#\def\REGbox#1{\let\&=\. \hbox{#1}}
\def\REGbox#1{#1}
\def\Lbox{\hbox to 1em{}}
\def\C#1{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi % redefine: comments
  \XX\hfil\penalty-1\hfilneg\quad
	$\commentbegin\,${\let\opbox=\popbox #1}$\,\commentend$\XX}
macros end

default translation <*> mathness yes
token . category dot
token + category unorbinop tangleto <space-"+">
token - category unorbinop tangleto <space-dash>
token * category binop
token / category binop
token , category camma translation <",\\;">
token ( category open tangleto <space-"(">
token [ category open tangleto <space-"[">
token { translation <"\\{"> category open tangleto <space-"{">
token ) category close
token ] category close
token } translation <"\\}"> category close
token : category colon tangleto <":"-space>
token # category unop translation <"\\#"> tangleto <space-"#">
#token ` category unop translation <"'"> mathness yes
#token ; category semi
token < category open tangleto <space-"<">
token > category close
#token = category binop
#token ! category unop translation <"\\lnot">
#token & category binop translation <"\\land">
#token || category binop translation <"\\lor">
#token | category unop
#token != name not_eq translation <"\\I"> category binop
#token <= name lt_eq translation <"\\L"> category binop
#token >= name gt_eq translation <"\\G"> category binop
#token == name eq_eq translation <"\\S"> category binop
#token >> translation <"\\rangle"> category close
#token << translation <"\\langle"> category open


#macros begin
#\def\LRA{\Longrightarrow}
#\def\IFF{\Longleftrightarrow}
#\def\FF{\Longleftarrow}
#\def\DEF{\buildrel\triangle\over=}
#\def\CE{\mathrel{{:}{=}}}
#\def\CC{\mathrel{{:}{:}}}
#\let\RA\rightarrow
#\let\openbraces=\{
#\let\closebraces=\}
#\def\{{\ifmmode\openbraces\else$\openbraces$\fi}
#\def\}{\ifmmode\closebraces\else$\closebraces$\fi}
#macros end





## definition of reserved
##############################################
##  Pseudo Instructions			    ##
##  (should be changed for your assembler)  ##
##############################################

ilk equ_like category equ mathness yes
ilk dw_like category dw mathness yes
reserved equ ilk equ_like
reserved set ilk equ_like
reserved EQU ilk equ_like
reserved SET ilk equ_like
reserved dc ilk dw_like
reserved db ilk dw_like
reserved dw ilk dw_like
reserved ds ilk dw_like
reserved dd ilk dw_like
reserved float ilk dw_like
reserved dfloat ilk dw_like
reserved DC ilk dw_like
reserved DB ilk dw_like
reserved DW ilk dw_like
reserved DS ilk dw_like
reserved DD ilk dw_like
reserved FLOAT ilk dw_like
reserved DFLOAT ilk dw_like

ilk pseudo_like category pseudo mathness yes
reserved name ilk pseudo_like
reserved include ilk pseudo_like
reserved end ilk pseudo_like
reserved org ilk pseudo_like
reserved aorg ilk pseudo_like
reserved bnd ilk pseudo_like
reserved sect ilk pseudo_like
reserved NAME ilk pseudo_like
reserved INCLUDE ilk pseudo_like
reserved END ilk pseudo_like
reserved ORG ilk pseudo_like
reserved AORG ilk pseudo_like
reserved BND ilk pseudo_like
reserved SECT ilk pseudo_like

ilk glo_like category glo mathness yes
reserved global ilk glo_like
reserved GLOBAL ilk glo_like

ilk ext_like category ext mathness yes
reserved extnal ilk ext_like
reserved EXTNAL ilk ext_like

default translation <*-"\\"-space> tangleto <*-space>
ilk if_like category if
ilk else_like category else
ilk endif_like category endif
reserved if ilk if_like
reserved ifdef ilk if_like
reserved ifndef ilk if_like
reserved else ilk else_like
reserved endif ilk endif_like
reserved IF ilk if_like
reserved IFDEF ilk if_like
reserved IFNDEF ilk if_like
reserved ELSE ilk else_like
reserved ENDIF ilk endif_like

########################
##  All 68000 postfix ##
########################
default mathness maybe
ilk post_b_like category post translation <*> tangleto <*-space>
ilk post_w_like category post translation <*> tangleto <*-space>
ilk post_l_like category post translation <*> tangleto <*-space>
ilk post_x_like category post translation <*> tangleto <*-space>
reserved b ilk post_b_like
reserved B ilk post_b_like
reserved w ilk post_w_like
reserved W ilk post_w_like
reserved l ilk post_l_like
reserved L ilk post_l_like
reserved x ilk post_x_like
reserved X ilk post_x_like

##########################
##  All 68000 registers ##
##########################
ilk reg_like category reg mathness yes
reserved a0 ilk reg_like
reserved a1 ilk reg_like
reserved a2 ilk reg_like
reserved a3 ilk reg_like
reserved a4 ilk reg_like
reserved a5 ilk reg_like
reserved a6 ilk reg_like
reserved a7 ilk reg_like
reserved d0 ilk reg_like
reserved d1 ilk reg_like
reserved d2 ilk reg_like
reserved d3 ilk reg_like
reserved d4 ilk reg_like
reserved d5 ilk reg_like
reserved d6 ilk reg_like
reserved d7 ilk reg_like
reserved pc ilk reg_like
reserved sr ilk reg_like
reserved ccr ilk reg_like
reserved ssp ilk reg_like
reserved usp ilk reg_like
reserved A0 ilk reg_like
reserved A1 ilk reg_like
reserved A2 ilk reg_like
reserved A3 ilk reg_like
reserved A4 ilk reg_like
reserved A5 ilk reg_like
reserved A6 ilk reg_like
reserved A7 ilk reg_like
reserved D0 ilk reg_like
reserved D1 ilk reg_like
reserved D2 ilk reg_like
reserved D3 ilk reg_like
reserved D4 ilk reg_like
reserved D5 ilk reg_like
reserved D6 ilk reg_like
reserved D7 ilk reg_like
reserved PC ilk reg_like
reserved SR ilk reg_like
reserved CCR ilk reg_like
reserved SSP ilk reg_like
reserved USP ilk reg_like

##############################
##  All 68000 Instructions  ##
##############################
default translation <*> mathness yes
ilk opcode_like category opcode tangleto <space-*-space> mathness yes
reserved ABCD ilk opcode_like
reserved ADD ilk opcode_like
reserved ADDA ilk opcode_like
reserved ADDI ilk opcode_like
reserved ADDQ ilk opcode_like
reserved ADDX ilk opcode_like
reserved AND ilk opcode_like
reserved ANDI ilk opcode_like
reserved ASL ilk opcode_like
reserved ASR ilk opcode_like
reserved BCC ilk opcode_like
reserved BCS ilk opcode_like
reserved BEQ ilk opcode_like
reserved BGE ilk opcode_like
reserved BGT ilk opcode_like
reserved BHI ilk opcode_like
reserved BLE ilk opcode_like
reserved BLS ilk opcode_like
reserved BLT ilk opcode_like
reserved BMI ilk opcode_like
reserved BNE ilk opcode_like
reserved BPL ilk opcode_like
reserved BVC ilk opcode_like
reserved BVS ilk opcode_like
reserved BCHG ilk opcode_like
reserved BCLR ilk opcode_like
reserved BKPT ilk opcode_like
reserved BRA ilk opcode_like
reserved BSET ilk opcode_like
reserved BSR ilk opcode_like
reserved BTST ilk opcode_like
reserved CHK ilk opcode_like
reserved CLR ilk opcode_like
reserved CMP ilk opcode_like
reserved CMPA ilk opcode_like
reserved CMPI ilk opcode_like
reserved CMPM ilk opcode_like
reserved DBCC ilk opcode_like
reserved DBCS ilk opcode_like
reserved DBEQ ilk opcode_like
reserved DBF ilk opcode_like
reserved DBGE ilk opcode_like
reserved DBGE ilk opcode_like
reserved DBGT ilk opcode_like
reserved DBHI ilk opcode_like
reserved DBLE ilk opcode_like
reserved DBLS ilk opcode_like
reserved DBLT ilk opcode_like
reserved DBMI ilk opcode_like
reserved DBMI ilk opcode_like
reserved DBNE ilk opcode_like
reserved DBPL ilk opcode_like
reserved DBT ilk opcode_like
reserved DBVC ilk opcode_like
reserved DBVS ilk opcode_like
reserved DIVS ilk opcode_like
reserved DIVU ilk opcode_like
reserved EOR ilk opcode_like
reserved EORI ilk opcode_like
reserved EXG ilk opcode_like
reserved EXT ilk opcode_like
reserved ILLEGAL ilk opcode_like
reserved JMP ilk opcode_like
reserved JSR ilk opcode_like
reserved LEA ilk opcode_like
reserved LINK ilk opcode_like
reserved LSL ilk opcode_like
reserved LSR ilk opcode_like
reserved MOVE ilk opcode_like
reserved MOVEA ilk opcode_like
reserved MOVEC ilk opcode_like
reserved MOVEM ilk opcode_like
reserved MOVEP ilk opcode_like
reserved MOVEQ ilk opcode_like
reserved MOVES ilk opcode_like
reserved MULS ilk opcode_like
reserved MULU ilk opcode_like
reserved NBCD ilk opcode_like
reserved NEG ilk opcode_like
reserved NEGX ilk opcode_like
reserved NOP ilk opcode_like
reserved NOT ilk opcode_like
reserved OR ilk opcode_like
reserved ORI ilk opcode_like
reserved PEA ilk opcode_like
reserved RESET ilk opcode_like
reserved ROL ilk opcode_like
reserved ROR ilk opcode_like
reserved ROXL ilk opcode_like
reserved ROXR ilk opcode_like
reserved RTD ilk opcode_like
reserved RTE ilk opcode_like
reserved RTR ilk opcode_like
reserved RTS ilk opcode_like
reserved SBCD ilk opcode_like
reserved SCC ilk opcode_like
reserved SCS ilk opcode_like
reserved SEQ ilk opcode_like
reserved SF ilk opcode_like
reserved SGE ilk opcode_like
reserved SGT ilk opcode_like
reserved SHI ilk opcode_like
reserved SLE ilk opcode_like
reserved SLS ilk opcode_like
reserved SLT ilk opcode_like
reserved SMI ilk opcode_like
reserved SNE ilk opcode_like
reserved SPL ilk opcode_like
reserved ST ilk opcode_like
reserved SVC ilk opcode_like
reserved SVS ilk opcode_like
reserved STOP ilk opcode_like
reserved SUB ilk opcode_like
reserved SUBA ilk opcode_like
reserved SUBI ilk opcode_like
reserved SUBQ ilk opcode_like
reserved SUBX ilk opcode_like
reserved SWAP ilk opcode_like
reserved TAS ilk opcode_like
reserved TRAP ilk opcode_like
reserved TRAPV ilk opcode_like
reserved TST ilk opcode_like
reserved UNLK ilk opcode_like
reserved abcd ilk opcode_like
reserved add ilk opcode_like
reserved adda ilk opcode_like
reserved addi ilk opcode_like
reserved addq ilk opcode_like
reserved addx ilk opcode_like
reserved and ilk opcode_like
reserved andi ilk opcode_like
reserved asl ilk opcode_like
reserved asr ilk opcode_like
reserved bcc ilk opcode_like
reserved bcs ilk opcode_like
reserved beq ilk opcode_like
reserved bge ilk opcode_like
reserved bgt ilk opcode_like
reserved bhi ilk opcode_like
reserved ble ilk opcode_like
reserved bls ilk opcode_like
reserved blt ilk opcode_like
reserved bmi ilk opcode_like
reserved bne ilk opcode_like
reserved bpl ilk opcode_like
reserved bvc ilk opcode_like
reserved bvs ilk opcode_like
reserved bchg ilk opcode_like
reserved bclr ilk opcode_like
reserved bkpt ilk opcode_like
reserved bra ilk opcode_like
reserved bset ilk opcode_like
reserved bsr ilk opcode_like
reserved btst ilk opcode_like
reserved chk ilk opcode_like
reserved clr ilk opcode_like
reserved cmp ilk opcode_like
reserved cmpa ilk opcode_like
reserved cmpi ilk opcode_like
reserved cmpm ilk opcode_like
reserved dbcc ilk opcode_like
reserved dbcs ilk opcode_like
reserved dbeq ilk opcode_like
reserved dbf ilk opcode_like
reserved dbge ilk opcode_like
reserved dbge ilk opcode_like
reserved dbgt ilk opcode_like
reserved dbhi ilk opcode_like
reserved dble ilk opcode_like
reserved dbls ilk opcode_like
reserved dblt ilk opcode_like
reserved dbmi ilk opcode_like
reserved dbmi ilk opcode_like
reserved dbne ilk opcode_like
reserved dbpl ilk opcode_like
reserved dbt ilk opcode_like
reserved dbvc ilk opcode_like
reserved dbvs ilk opcode_like
reserved divs ilk opcode_like
reserved divu ilk opcode_like
reserved eor ilk opcode_like
reserved eori ilk opcode_like
reserved exg ilk opcode_like
reserved ext ilk opcode_like
reserved illegal ilk opcode_like
reserved jmp ilk opcode_like
reserved jsr ilk opcode_like
reserved lea ilk opcode_like
reserved link ilk opcode_like
reserved lsl ilk opcode_like
reserved lsr ilk opcode_like
reserved move ilk opcode_like
reserved movea ilk opcode_like
reserved movec ilk opcode_like
reserved movem ilk opcode_like
reserved movep ilk opcode_like
reserved moveq ilk opcode_like
reserved moves ilk opcode_like
reserved muls ilk opcode_like
reserved mulu ilk opcode_like
reserved nbcd ilk opcode_like
reserved neg ilk opcode_like
reserved negx ilk opcode_like
reserved nop ilk opcode_like
reserved not ilk opcode_like
reserved or ilk opcode_like
reserved ori ilk opcode_like
reserved pea ilk opcode_like
reserved reset ilk opcode_like
reserved rol ilk opcode_like
reserved ror ilk opcode_like
reserved roxl ilk opcode_like
reserved roxr ilk opcode_like
reserved rtd ilk opcode_like
reserved rte ilk opcode_like
reserved rtr ilk opcode_like
reserved rts ilk opcode_like
reserved sbcd ilk opcode_like
reserved scc ilk opcode_like
reserved scs ilk opcode_like
reserved seq ilk opcode_like
reserved sf ilk opcode_like
reserved sge ilk opcode_like
reserved sgt ilk opcode_like
reserved shi ilk opcode_like
reserved sle ilk opcode_like
reserved sls ilk opcode_like
reserved slt ilk opcode_like
reserved smi ilk opcode_like
reserved sne ilk opcode_like
reserved spl ilk opcode_like
reserved st ilk opcode_like
reserved svc ilk opcode_like
reserved svs ilk opcode_like
reserved stop ilk opcode_like
reserved sub ilk opcode_like
reserved suba ilk opcode_like
reserved subi ilk opcode_like
reserved subq ilk opcode_like
reserved subx ilk opcode_like
reserved swap ilk opcode_like
reserved tas ilk opcode_like
reserved trap ilk opcode_like
reserved trapv ilk opcode_like
reserved tst ilk opcode_like
reserved unlk ilk opcode_like

################################
## Production roles for weave ##
################################

# For register
#
#[ <"\\REGbox{"> reg <"}"> ] --> math
<"\\REGbox{"> reg dot post <"}"> --> math
[ <"\\REGbox{"> reg <"}"> ] open --> math open
[ <"\\REGbox{"> reg <"}"> ] close --> math close
[ <"\\REGbox{"> reg <"}"> ] binop --> math binop
[ <"\\REGbox{"> reg <"}"> ] camma --> math camma
[ <"\\REGbox{"> reg <"}"> ] unorbinop --> math unorbinop
[ <"\\REGbox{"> reg <"}"> ] ignore_scrap --> math ignore_scrap

<"\\REGbox{"> reg <"}"> (math|sym) --> math

# For math
#
(sym|math) (binop|unorbinop|camma) (sym|math) --> math
(unop|unorbinop) (sym|math) --> math
(sym|math) (unop|unorbinop) --> math
open (sym|math) close --> math
(sym|math) <space> (sym|math) --> math

#open close --> math
#math semi <force> --> unop
#math <force> lbrace --> lbrace
#lbrace math close --> math
#lbrace math close <force> --> unop

# There are rules for if-pseudo-instructions
#
<force> if (sym|math) --> ifmath
ifmath math ignore_scrap --> ifmath
ifmath <indent> stmt ignore_scrap --> ifstmt
ifstmt stmt --> ifstmt
ifstmt <outdent-force> else if --> if
ifstmt <outdent-force> endif --> stmt

ifmath <force> else --> ifels
ifstmt <outdent-force> else ignore_scrap --> ifels
ifels <indent> stmt --> ifelstmt
ifelstmt stmt --> ifelstmt
ifelstmt <outdent-force> endif --> stmt
ifels <force> endif --> stmt

# For instructions
#
#-- pseudo instructions
(dw|pseudo) <"\\"-space> --> inst
<force> sym* <"\\"-space> (equ|dw) <"\\"-space> (sym|math) ignore_scrap --> stmt
#<force> dw <"\\"-space> (sym|math) ignore_scrap --> stmt
#-- CPU instructions
<"\\OPbox{"> opcode dot post <"}"-space> --> inst
<"\\OPbox{"> opcode <"}"-space> --> inst

#-- ext instructions
#
<force> ext <"\\"-space> sym* --> extsym
extsym camma <break_space> sym* --> extsym
extsym ignore_scrap --> stmt

<force> glo <"\\"-space> sym --> glosym
glosym camma <break_space> sym --> glosym
glosym ignore_scrap --> stmt

#sym* camma sym* --> symlist
#symlist camma sym* --> symlist
#<indent-force> (ext|glo) <"\\"-space> symlist <outdent> ignore_scrap --> stmt

#-- instructions
#
[ inst (sym|math) ] ignore_scrap --> pure_stmt ignore_scrap
[ inst ] ignore_scrap --> pure_stmt ignore_scrap
#[ inst  math (unop|unorbinop) ] ignore_scrap --> pure_stmt ignore_scrap

# reducing label
#
<"\\hbox{"> sym* colon <"}"> --> label
<big_force> label <force> label --> sub_label
<big_force> sub_label <force> label --> sub_label

# Statements
#
sub_label <force-"\\Lbox"-space> pure_stmt --> stmt
<big_force> label <force-"\\Lbox"-space> pure_stmt --> stmt
<force-"\\Lbox"-space> pure_stmt --> stmt
#stmt <force-"\\Lbox"-space> pure_stmt --> stmt

stmt stmt --> stmt

#labeled_stmt <force> pure_stmt --> stmt
#stmt labeled_stmt --> stmt
#<force> pure_stmt labeled_stmt --> stmt

? ignore_scrap --> #1

# end of file