forked from cvghivebrain/Sonic1sq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMacros - More CPUs.asm
1436 lines (1257 loc) · 23.3 KB
/
Macros - More CPUs.asm
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
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; ---------------------------------------------------------------------------
; Change CPU
; ---------------------------------------------------------------------------
cpu: macro
if strcmp("\1","z80")
pusho ; save previous options
cpu_mode: = 1 ; Z80
opt an+ ; 1234h style numbering
opt ae- ; disable auto evens
else
if def(cpu_mode)
popo ; restore options
endc
cpu_mode: = 0 ; 68000 by default
endc
endm
; ---------------------------------------------------------------------------
; AS compatibility
; ---------------------------------------------------------------------------
phase: macros
obj \1
dephase: macros
objend
listing: macro
if strcmp("\1","on")
list
else
nolist
endc
endm
binclude: macros
incbin \_
; ---------------------------------------------------------------------------
; Z80 instruction set
; ---------------------------------------------------------------------------
getzreg: macro ; convert register to numerical value
if strcmp("\1","a")
zreg: = 7
elseif strcmp("\1","b")
zreg: = 0
elseif strcmp("\1","c")
zreg: = 1
elseif strcmp("\1","d")
zreg: = 2
elseif strcmp("\1","e")
zreg: = 3
elseif strcmp("\1","h")
zreg: = 4
elseif strcmp("\1","l")
zreg: = 5
elseif strcmp("\1","(hl)")
zreg: = 6
else
endc
endm
getindex: macro ; convert index register to register offset and value
if instr("\1","(ix")
ireg: = $dd
elseif instr("\1","(iy")
ireg: = $fd
else
fail
endc
endm
ix: = 0 ; allows (ix+n) to be parsed as n
iy: = 0
adc: macro
local num
if strcmp("\1","hl")
if strcmp("\2","bc")
dc.w $ed4a
elseif strcmp("\2","de")
dc.w $ed5a
elseif strcmp("\2","hl")
dc.w $ed6a
elseif strcmp("\2","sp")
dc.w $ed7a
else
fail
endc
mexit
endc
; "adc a, x" or "adc x"
if narg=2 & strcmp("\1","a")
shift ; ignore a
endc
if (narg=1) | (narg=2)
if instr("a b c d e h l (hl) ","\1\ ")
getzreg \1
dc.b $88+zreg
elseif strcmp("\1","ixh")
dc.w $dd8c
elseif strcmp("\1","ixl")
dc.w $dd8d
elseif strcmp("\1","iyh")
dc.w $fd8c
elseif strcmp("\1","iyl")
dc.w $fd8d
elseif instr("\1","(i") ; adc (ix+n)
num: equ \1
getindex \1
dc.b ireg, $8e, num
else ; adc n
num: equ \1
dc.b $ce, num
endc
else
fail
endc
endm
bit: macro
local num, num2
num: equ \1
if instr("a b c d e h l (hl) ","\2\ ")
getzreg \2
dc.b $cb, $40+(num*8)+zreg
elseif instr("\2","(i") ; bit n,(ix+n)
num2: equ \2
getindex \2
dc.b ireg, $cb, num2, $40+(num*8)
else
fail
endc
endm
call: macro
local num
if narg=1 ; call n
num: equ \1
dc.b $cd
elseif narg=2 ; call x, n
num: equ \2
if strcmp("\1","nz")
dc.b $c4
elseif strcmp("\1","z")
dc.b $cc
elseif strcmp("\1","nc")
dc.b $d4
elseif strcmp("\1","c")
dc.b $dc
elseif strcmp("\1","po")
dc.b $e4
elseif strcmp("\1","pe")
dc.b $ec
elseif strcmp("\1","p")
dc.b $f4
elseif strcmp("\1","m")
dc.b $fc
else
fail
endc
shift
else
fail
endc
dc.b num&$FF, num>>8
endm
ccf: macros
dc.b $3f
cp: macro
local num
if instr("a b c d e h l (hl) ","\1\ ")
getzreg \1
dc.b $b8+zreg
elseif strcmp("\1","ixh")
dc.w $ddbc
elseif strcmp("\1","ixl")
dc.w $ddbd
elseif strcmp("\1","iyh")
dc.w $fdbc
elseif strcmp("\1","iyl")
dc.w $fdbd
elseif instr("\1","(i") ; cp (ix+n)
num: equ \1
getindex \1
dc.b ireg, $be, num
else ; cp n
num: equ \1
dc.b $fe, num
endc
endm
cpd: macros
dc.w $eda9
cpdr: macros
dc.w $edb9
cpi: macros
dc.w $eda1
cpir: macros
dc.w $edb1
cpl: macros
dc.b $2f
daa: macros
dc.b $27
dec: macro
local num
if instr("a b c d e h l ","\1\ ")
getzreg \1
dc.b $5+(zreg*8)
elseif strcmp("\1","ixh")
dc.w $dd25
elseif strcmp("\1","ixl")
dc.w $dd2d
elseif strcmp("\1","iyh")
dc.w $fd25
elseif strcmp("\1","iyl")
dc.w $fd2d
elseif strcmp("\1","bc")
dc.b $b
elseif strcmp("\1","de")
dc.b $1b
elseif strcmp("\1","hl")
dc.b $2b
elseif strcmp("\1","ix")
dc.w $dd2b
elseif strcmp("\1","iy")
dc.w $fd2b
elseif strcmp("\1","sp")
dc.b $3b
elseif instr("\1","(i") ; dec (ix+n)
num: equ \1
getindex \1
dc.b ireg, $35, num
else
fail
endc
endm
di: macros
dc.b $f3
djnz: macro
local num
num: equ \1
dc.b $10, num-*-2
endm
ei: macros
dc.b $fb
ex: macro
if strcmp("\_","af,af") ; ex af,af'
dc.b 8
elseif strcmp("\_","(sp),hl")
dc.b $e3
elseif strcmp("\_","(sp),ix")
dc.w $dde3
elseif strcmp("\_","(sp),iy")
dc.w $fde3
elseif strcmp("\_","de,hl")
dc.b $eb
else
fail
endc
endm
exx: macros
dc.b $d9
halt: macros
dc.b $76
im: macro
if \1=0
dc.w $ed46
elseif \1=1
dc.w $ed56
elseif \1=2
dc.w $ed5e
else
fail
endc
endm
in: macro
local num
if strcmp("\1","a")
if strcmp("\2","(c)")
dc.w $ed78
else ; in a,n
num: equ \2
dc.b $db, num
endc
elseif instr("b c d e h l ","\1\ ")&strcmp("\2","(c)")
getzreg \1
dc.w $ed40+(zreg*8)
elseif strcmp("\1","(c)")
dc.w $ed70
else
fail
endc
endm
inc: macro
local num
if instr("a b c d e h l ","\1\ ")
getzreg \1
dc.b $4+(zreg*8)
elseif strcmp("\1","ixh")
dc.w $dd24
elseif strcmp("\1","ixl")
dc.w $dd2c
elseif strcmp("\1","iyh")
dc.w $fd24
elseif strcmp("\1","iyl")
dc.w $fd2c
elseif strcmp("\1","bc")
dc.b $3
elseif strcmp("\1","de")
dc.b $13
elseif strcmp("\1","hl")
dc.b $23
elseif strcmp("\1","ix")
dc.w $dd23
elseif strcmp("\1","iy")
dc.w $fd23
elseif strcmp("\1","sp")
dc.b $33
elseif instr("\1","(i") ; inc (ix+n)
num: equ \1
getindex \1
dc.b ireg, $34, num
else
fail
endc
endm
ind: macros
dc.w $edaa
indr: macros
dc.w $edba
ini: macros
dc.w $eda2
inir: macros
dc.w $edb2
jp: macro
local num
if strcmp("\1","(hl)")
dc.b $e9
elseif strcmp("\1","(ix)")
dc.w $dde9
elseif strcmp("\1","(iy)")
dc.w $fde9
else
if strcmp("\1","nz")
num: equ \2
dc.b $c2
elseif strcmp("\1","z")
num: equ \2
dc.b $ca
elseif strcmp("\1","nc")
num: equ \2
dc.b $d2
elseif strcmp("\1","c")
num: equ \2
dc.b $da
elseif strcmp("\1","po")
num: equ \2
dc.b $e2
elseif strcmp("\1","pe")
num: equ \2
dc.b $ea
elseif strcmp("\1","p")
num: equ \2
dc.b $f2
elseif strcmp("\1","m")
num: equ \2
dc.b $fa
else ; jp n
num: equ \1
dc.b $c3
endc
if narg=2
shift
endc
dc.b num&$FF, num>>8
endc
endm
jr: macro
local num
if strcmp("\1","nz")
num: equ \2
dc.b $20
elseif strcmp("\1","z")
num: equ \2
dc.b $28
elseif strcmp("\1","nc")
num: equ \2
dc.b $30
elseif strcmp("\1","c")
num: equ \2
dc.b $38
else ; jr n
num: equ \1
dc.b $18
endc
if narg=2
shift
endc
dc.b num-*-1
;if ((num-*)>=-$80)&((num-*)<=$7f)
;fail
;endc
endm
ld: macro
local num, num2
if strcmp("\1","a")
if instr("a b c d e h l (hl) ","\2\ ")
getzreg \2
dc.b $78+zreg
elseif strcmp("\2","i")
dc.w $ed57
elseif strcmp("\2","r")
dc.w $ed5f
elseif strcmp("\2","ixh")
dc.w $dd7c
elseif strcmp("\2","ixl")
dc.w $dd7d
elseif strcmp("\2","iyh")
dc.w $fd7c
elseif strcmp("\2","iyl")
dc.w $fd7d
elseif strcmp("\2","(bc)")
dc.b $0a
elseif strcmp("\2","(de)")
dc.b $1a
elseif instr("\2","(i") ; ld a,(ix+n)
num: equ \2
getindex \2
dc.b ireg, $7e, num
else
num: equ \2
tmp_len: = strlen("\2")
tmp_fc: substr 1,1,"\2"
tmp_lc: substr tmp_len,tmp_len,"\2"
if strcmp("\tmp_fc","(") & strcmp("\tmp_lc",")") ; ld a,(n)
dc.b $3a, num&$ff, num>>8
else ; ld a,n
dc.b $3e, num
endc
endc
elseif strcmp("\1","b")
if instr("a b c d e h l (hl) ","\2\ ")
getzreg \2
dc.b $40+zreg
elseif strcmp("\2","ixh")
dc.w $dd44
elseif strcmp("\2","ixl")
dc.w $dd45
elseif strcmp("\2","iyh")
dc.w $fd44
elseif strcmp("\2","iyl")
dc.w $fd45
elseif instr("\2","(i") ; ld b,(ix+n)
num: equ \2
getindex \2
dc.b ireg, $46, num
else ; ld b,n
num: equ \2
dc.b $6, num
endc
elseif strcmp("\1","c")
if instr("a b c d e h l (hl) ","\2\ ")
getzreg \2
dc.b $48+zreg
elseif strcmp("\2","ixh")
dc.w $dd4c
elseif strcmp("\2","ixl")
dc.w $dd4d
elseif strcmp("\2","iyh")
dc.w $fd4c
elseif strcmp("\2","iyl")
dc.w $fd4d
elseif instr("\2","(i") ; ld c,(ix+n)
num: equ \2
getindex \2
dc.b ireg, $4e, num
else ; ld c,n
num: equ \2
dc.b $e, num
endc
elseif strcmp("\1","d")
if instr("a b c d e h l (hl) ","\2\ ")
getzreg \2
dc.b $50+zreg
elseif strcmp("\2","ixh")
dc.w $dd54
elseif strcmp("\2","ixl")
dc.w $dd55
elseif strcmp("\2","iyh")
dc.w $fd54
elseif strcmp("\2","iyl")
dc.w $fd55
elseif instr("\2","(i") ; ld d,(ix+n)
num: equ \2
getindex \2
dc.b ireg, $56, num
else ; ld d,n
num: equ \2
dc.b $16, num
endc
elseif strcmp("\1","e")
if instr("a b c d e h l (hl) ","\2\ ")
getzreg \2
dc.b $58+zreg
elseif strcmp("\2","ixh")
dc.w $dd5c
elseif strcmp("\2","ixl")
dc.w $dd5d
elseif strcmp("\2","iyh")
dc.w $fd5c
elseif strcmp("\2","iyl")
dc.w $fd5d
elseif instr("\2","(i") ; ld e,(ix+n)
num: equ \2
getindex \2
dc.b ireg, $5e, num
else ; ld e,n
num: equ \2
dc.b $1e, num
endc
elseif strcmp("\1","h")
if instr("a b c d e h l (hl) ","\2\ ")
getzreg \2
dc.b $60+zreg
elseif instr("\2","(i") ; ld h,(ix+n)
num: equ \2
getindex \2
dc.b ireg, $66, num
else ; ld h,n
num: equ \2
dc.b $26, num
endc
elseif strcmp("\1","l")
if instr("a b c d e h l (hl) ","\2\ ")
getzreg \2
dc.b $68+zreg
elseif instr("\2","(i") ; ld l,(ix+n)
num: equ \2
getindex \2
dc.b ireg, $6e, num
else ; ld l,n
num: equ \2
dc.b $2e, num
endc
elseif strcmp("\1","i")
dc.w $ed47
elseif strcmp("\1","r")
dc.w $ed4f
elseif strcmp("\1","ixh")
if instr("a b c d e ","\2\ ")
getzreg \2
dc.w $dd60+zreg
elseif strcmp("\2","ixh")
dc.w $dd64
elseif strcmp("\2","ixl")
dc.w $dd65
else ; ld ixh,n
num: equ \2
dc.b $dd, $26, num
endc
elseif strcmp("\1","ixl")
if instr("a b c d e ","\2\ ")
getzreg \2
dc.w $dd68+zreg
elseif strcmp("\2","ixh")
dc.w $dd6c
elseif strcmp("\2","ixl")
dc.w $dd6d
else ; ld ixl,n
num: equ \2
dc.b $dd, $2e, num
endc
elseif strcmp("\1","iyh")
if instr("a b c d e ","\2\ ")
getzreg \2
dc.w $fd60+zreg
elseif strcmp("\2","iyh")
dc.w $fd64
elseif strcmp("\2","iyl")
dc.w $fd65
else ; ld iyh,n
num: equ \2
dc.b $fd, $26, num
endc
elseif strcmp("\1","iyl")
if instr("a b c d e ","\2\ ")
getzreg \2
dc.w $fd68+zreg
elseif strcmp("\2","iyh")
dc.w $fd6c
elseif strcmp("\2","iyl")
dc.w $fd6d
else ; ld iyl,n
num: equ \2
dc.b $fd, $2e, num
endc
elseif strcmp("\1","bc")
num: equ \2
tmp_len: = strlen("\2")
tmp_fc: substr 1,1,"\2"
tmp_lc: substr tmp_len,tmp_len,"\2"
if strcmp("\tmp_fc","(") & strcmp("\tmp_lc",")") ; ld bc,(n)
dc.b $ed, $4b, num&$ff, num>>8
else ; ld bc,n
dc.b $1, num&$ff, num>>8
endc
elseif strcmp("\1","de")
num: equ \2
tmp_len: = strlen("\2")
tmp_fc: substr 1,1,"\2"
tmp_lc: substr tmp_len,tmp_len,"\2"
if strcmp("\tmp_fc","(") & strcmp("\tmp_lc",")") ; ld de,(n)
dc.b $ed, $5b, num&$ff, num>>8
else ; ld de,n
dc.b $11, num&$ff, num>>8
endc
elseif strcmp("\1","hl")
num: equ \2
tmp_len: = strlen("\2")
tmp_fc: substr 1,1,"\2"
tmp_lc: substr tmp_len,tmp_len,"\2"
if strcmp("\tmp_fc","(") & strcmp("\tmp_lc",")") ; ld hl,(n)
dc.b $ed, $6b, num&$ff, num>>8
else ; ld hl,n
dc.b $21, num&$ff, num>>8
endc
elseif strcmp("\1","sp")
if strcmp("\2","hl")
dc.b $f9
elseif strcmp("\2","ix")
dc.w $ddf9
elseif strcmp("\2","iy")
dc.w $fdf9
else
num: equ \2
tmp_len: = strlen("\2")
tmp_fc: substr 1,1,"\2"
tmp_lc: substr tmp_len,tmp_len,"\2"
if strcmp("\tmp_fc","(") & strcmp("\tmp_lc",")") ; ld sp,(n)
dc.b $ed, $7b, num&$ff, num>>8
else ; ld sp,n
dc.b $31, num&$ff, num>>8
endc
endc
elseif strcmp("\1","ix")
num: equ \2
tmp_len: = strlen("\2")
tmp_fc: substr 1,1,"\2"
tmp_lc: substr tmp_len,tmp_len,"\2"
if strcmp("\tmp_fc","(") & strcmp("\tmp_lc",")") ; ld ix,(n)
dc.b $dd, $2a, num&$ff, num>>8
else ; ld ix,n
dc.b $dd, $21, num&$ff, num>>8
endc
elseif strcmp("\1","iy")
num: equ \2
tmp_len: = strlen("\2")
tmp_fc: substr 1,1,"\2"
tmp_lc: substr tmp_len,tmp_len,"\2"
if strcmp("\tmp_fc","(") & strcmp("\tmp_lc",")") ; ld iy,(n)
dc.b $fd, $2a, num&$ff, num>>8
else ; ld iy,n
dc.b $fd, $21, num&$ff, num>>8
endc
elseif strcmp("\1","(bc)")
dc.b 2
elseif strcmp("\1","(de)")
dc.b $12
elseif strcmp("\1","(hl)")
if instr("a b c d e h l ","\2\ ")
getzreg \2
dc.b $70+zreg
else ; ld (hl),n
num: equ \2
dc.b $36, num
endc
elseif instr("\1","(i") ; ld (ix+n),?
if instr("a b c d e h l ","\2\ ")
num: equ \1
getzreg \2
getindex \1
dc.b ireg, $70|zreg, num
else ; ld (ix+n),n
num: equ \1
num2: equ \2
getindex \1
dc.b ireg, $36, num, num2
endc
else ; ld (n),?
num: equ \1
if strcmp("\2","a")
dc.b $32
elseif strcmp("\2","bc")
dc.w $ed43
elseif strcmp("\2","de")
dc.w $ed53
elseif strcmp("\2","hl")
dc.w $ed63
elseif strcmp("\2","sp")
dc.w $ed73
elseif strcmp("\2","ix")
dc.w $dd22
elseif strcmp("\2","iy")
dc.w $fd22
else
fail
endc
dc.b num&$FF, num>>8
endc
endm
ldd: macros
dc.w $eda8
lddr: macros
dc.w $edb8
ldi: macros
dc.w $eda0
ldir: macros
dc.w $edb0
otdr: macros
dc.w $edbb
otir: macros
dc.w $edb3
out: macro
local num
if strcmp("\1","(c)")&instr("a b c d e h l ","\2\ ")
getzreg \2
dc.w $ed41+(zreg*8)
elseif strcmp("\_","(c),0")
dc.w $ed71
elseif strcmp("\2","a") ; out n,a
num: equ \1
dc.b $d3, num
else
fail
endc
endm
outd: macros
dc.w $edab
outi: macros
dc.w $eda3
pop: macro
if strcmp("\1","bc")
dc.b $c1
elseif strcmp("\1","de")
dc.b $d1
elseif strcmp("\1","hl")
dc.b $e1
elseif strcmp("\1","af")
dc.b $f1
elseif strcmp("\1","ix")
dc.w $dde1
elseif strcmp("\1","iy")
dc.w $fde1
else
fail
endc
endm
push: macro
if strcmp("\1","bc")
dc.b $c5
elseif strcmp("\1","de")
dc.b $d5
elseif strcmp("\1","hl")
dc.b $e5
elseif strcmp("\1","af")
dc.b $f5
elseif strcmp("\1","ix")
dc.w $dde5
elseif strcmp("\1","iy")
dc.w $fde5
else
fail
endc
endm
res: macro
local num, num2
num: equ \1
if instr("a b c d e h l (hl) ","\2\ ")
getzreg \2
dc.b $cb, $80+(num*8)+zreg
elseif instr("\2","(i") ; res n,(ix+n)
num2: equ \2
getindex \2
dc.b ireg, $cb, num2
dc.b $80+(num*8)
else
fail
endc
endm
ret: macro
if strcmp("\1","nz")
dc.b $c0
elseif strcmp("\1","z")
dc.b $c8
elseif strcmp("\1","nc")
dc.b $d0
elseif strcmp("\1","c")
dc.b $d8
elseif strcmp("\1","po")
dc.b $e0
elseif strcmp("\1","pe")
dc.b $e8
elseif strcmp("\1","p")
dc.b $f0
elseif strcmp("\1","m")
dc.b $f8
elseif strlen("\1")=0 ; ret
dc.b $c9
else
fail
endc
endm
reti: macros
dc.w $ed4d
retn: macros
dc.w $ed45
rl: macro
local num
if instr("a b c d e h l (hl) ","\1\ ")
getzreg \1
dc.b $cb, $10+zreg
elseif instr("\1","(i") ; rl (ix+n)
num: equ \1
getindex \1
dc.b ireg, $cb, num
if narg=2 ; rl (ix+n),?
getzreg \2
dc.b $10+zreg
else
dc.b $16
endc
else
fail
endc
endm
rla: macros
dc.b $17
rlc: macro
local num
if instr("a b c d e h l (hl) ","\1\ ")
getzreg \1
dc.b $cb, zreg
elseif instr("\1","(i") ; rlc (ix+n)
num: equ \1
getindex \1
dc.b ireg, $cb, num
if narg=2 ; rlc (ix+n),?
getzreg \2
dc.b zreg
else
dc.b $6
endc
else
fail
endc
endm
rlca: macros
dc.b $7
rld: macros
dc.w $ed6f
rr: macro
local num
if instr("a b c d e h l (hl) ","\1\ ")
getzreg \1
dc.b $cb, $18+zreg
elseif instr("\1","(i") ; rr (ix+n)
num: equ \1
getindex \1
dc.b ireg, $cb, num
if narg=2 ; rr (ix+n),?
getzreg \2
dc.b $18+zreg
else
dc.b $1e
endc
else
fail
endc
endm
rra: macros
dc.b $1f
rrc: macro
local num
if instr("a b c d e h l (hl) ","\1\ ")
getzreg \1
dc.b $cb, $8+zreg
elseif instr("\1","(i") ; rrc (ix+n)
num: equ \1
getindex \1
dc.b ireg, $cb, num