forked from koron-go/z80
-
Notifications
You must be signed in to change notification settings - Fork 0
/
operation.go
2672 lines (2414 loc) · 45.7 KB
/
operation.go
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
package z80
type fetcher interface {
fetch() uint8
}
// executeOne executes only an op-code.
func (cpu *CPU) executeOne(f fetcher) {
if cpu.HALT {
return
}
c0 := f.fetch()
switch c0 {
case 0x00:
oopNOP(cpu)
case 0x01:
l := f.fetch()
h := f.fetch()
xopLDbcnn(cpu, l, h)
case 0x11:
l := f.fetch()
h := f.fetch()
xopLDdenn(cpu, l, h)
case 0x21:
l := f.fetch()
h := f.fetch()
xopLDhlnn(cpu, l, h)
case 0x31:
l := f.fetch()
h := f.fetch()
xopLDspnn(cpu, l, h)
case 0x02:
oopLDBCPA(cpu)
case 0x03:
xopINCbc(cpu)
case 0x13:
xopINCde(cpu)
case 0x23:
xopINChl(cpu)
case 0x33:
xopINCsp(cpu)
case 0x04:
xopINCb(cpu)
case 0x0c:
xopINCc(cpu)
case 0x14:
xopINCd(cpu)
case 0x1c:
xopINCe(cpu)
case 0x24:
xopINCh(cpu)
case 0x2c:
xopINCl(cpu)
case 0x3c:
xopINCa(cpu)
case 0x05:
xopDECb(cpu)
case 0x0d:
xopDECc(cpu)
case 0x15:
xopDECd(cpu)
case 0x1d:
xopDECe(cpu)
case 0x25:
xopDECh(cpu)
case 0x2d:
xopDECl(cpu)
case 0x3d:
xopDECa(cpu)
// LD r, n
case 0x06:
n := f.fetch()
xopLDbn(cpu, n)
case 0x0e:
n := f.fetch()
xopLDcn(cpu, n)
case 0x16:
n := f.fetch()
xopLDdn(cpu, n)
case 0x1e:
n := f.fetch()
xopLDen(cpu, n)
case 0x26:
n := f.fetch()
xopLDhn(cpu, n)
case 0x2e:
n := f.fetch()
xopLDln(cpu, n)
case 0x3e:
n := f.fetch()
xopLDan(cpu, n)
case 0x07:
oopRLCA(cpu)
case 0x08:
oopEXAFAF(cpu)
case 0x09:
xopADDHLbc(cpu)
case 0x19:
xopADDHLde(cpu)
case 0x29:
xopADDHLhl(cpu)
case 0x39:
xopADDHLsp(cpu)
case 0x0a:
oopLDABCP(cpu)
case 0x0b:
xopDECbc(cpu)
case 0x1b:
xopDECde(cpu)
case 0x2b:
xopDEChl(cpu)
case 0x3b:
xopDECsp(cpu)
case 0x0f:
oopRRCA(cpu)
case 0x10:
off := f.fetch()
oopDJNZe(cpu, off)
case 0x12:
oopLDDEPA(cpu)
case 0x17:
oopRLA(cpu)
case 0x18:
off := f.fetch()
oopJRe(cpu, off)
case 0x1a:
oopLDADEP(cpu)
case 0x1f:
oopRRA(cpu)
case 0x20:
off := f.fetch()
oopJRNZe(cpu, off)
case 0x22:
l := f.fetch()
h := f.fetch()
oopLDnnPHL(cpu, l, h)
case 0x27:
oopDAA(cpu)
case 0x28:
off := f.fetch()
oopJRZe(cpu, off)
case 0x2a:
l := f.fetch()
h := f.fetch()
oopLDHLnnP(cpu, l, h)
case 0x2f:
oopCPL(cpu)
case 0x30:
off := f.fetch()
oopJRNCe(cpu, off)
case 0x32:
l := f.fetch()
h := f.fetch()
oopLDnnPA(cpu, l, h)
case 0x34:
oopINCHLP(cpu)
case 0x35:
oopDECHLP(cpu)
case 0x36:
n := f.fetch()
oopLDHLPn(cpu, n)
case 0x37:
oopSCF(cpu)
case 0x38:
off := f.fetch()
oopJRCe(cpu, off)
case 0x3a:
l := f.fetch()
h := f.fetch()
oopLDAnnP(cpu, l, h)
case 0x3f:
oopCCF(cpu)
// LD r1, r2
case 0x40:
//cpu.BC.Hi = cpu.BC.Hi
//cpu.LastOpCycles = 4
case 0x41:
cpu.BC.Hi = cpu.BC.Lo
cpu.LastOpCycles = 4
case 0x42:
cpu.BC.Hi = cpu.DE.Hi
cpu.LastOpCycles = 4
case 0x43:
cpu.BC.Hi = cpu.DE.Lo
cpu.LastOpCycles = 4
case 0x44:
cpu.BC.Hi = cpu.HL.Hi
cpu.LastOpCycles = 4
case 0x45:
cpu.BC.Hi = cpu.HL.Lo
cpu.LastOpCycles = 4
case 0x47:
cpu.BC.Hi = cpu.AF.Hi
cpu.LastOpCycles = 4
case 0x48:
cpu.BC.Lo = cpu.BC.Hi
cpu.LastOpCycles = 4
case 0x49:
//cpu.BC.Lo = cpu.BC.Lo
//cpu.LastOpCycles = 4
case 0x4a:
cpu.BC.Lo = cpu.DE.Hi
cpu.LastOpCycles = 4
case 0x4b:
cpu.BC.Lo = cpu.DE.Lo
cpu.LastOpCycles = 4
case 0x4c:
cpu.BC.Lo = cpu.HL.Hi
cpu.LastOpCycles = 4
case 0x4d:
cpu.BC.Lo = cpu.HL.Lo
cpu.LastOpCycles = 4
case 0x4f:
cpu.BC.Lo = cpu.AF.Hi
cpu.LastOpCycles = 4
case 0x50:
cpu.DE.Hi = cpu.BC.Hi
cpu.LastOpCycles = 4
case 0x51:
cpu.DE.Hi = cpu.BC.Lo
cpu.LastOpCycles = 4
case 0x52:
//cpu.DE.Hi = cpu.DE.Hi
//cpu.LastOpCycles = 4
case 0x53:
cpu.DE.Hi = cpu.DE.Lo
cpu.LastOpCycles = 4
case 0x54:
cpu.DE.Hi = cpu.HL.Hi
cpu.LastOpCycles = 4
case 0x55:
cpu.DE.Hi = cpu.HL.Lo
cpu.LastOpCycles = 4
case 0x57:
cpu.DE.Hi = cpu.AF.Hi
cpu.LastOpCycles = 4
case 0x58:
cpu.DE.Lo = cpu.BC.Hi
cpu.LastOpCycles = 4
case 0x59:
cpu.DE.Lo = cpu.BC.Lo
cpu.LastOpCycles = 4
case 0x5a:
cpu.DE.Lo = cpu.DE.Hi
cpu.LastOpCycles = 4
case 0x5b:
//cpu.DE.Lo = cpu.DE.Lo
//cpu.LastOpCycles = 4
case 0x5c:
cpu.DE.Lo = cpu.HL.Hi
cpu.LastOpCycles = 4
case 0x5d:
cpu.DE.Lo = cpu.HL.Lo
cpu.LastOpCycles = 4
case 0x5f:
cpu.DE.Lo = cpu.AF.Hi
cpu.LastOpCycles = 4
case 0x60:
cpu.HL.Hi = cpu.BC.Hi
cpu.LastOpCycles = 4
case 0x61:
cpu.HL.Hi = cpu.BC.Lo
cpu.LastOpCycles = 4
case 0x62:
cpu.HL.Hi = cpu.DE.Hi
cpu.LastOpCycles = 4
case 0x63:
cpu.HL.Hi = cpu.DE.Lo
cpu.LastOpCycles = 4
case 0x64:
//cpu.HL.Hi = cpu.HL.Hi
//cpu.LastOpCycles = 4
case 0x65:
cpu.HL.Hi = cpu.HL.Lo
cpu.LastOpCycles = 4
case 0x67:
cpu.HL.Hi = cpu.AF.Hi
cpu.LastOpCycles = 4
case 0x68:
cpu.HL.Lo = cpu.BC.Hi
cpu.LastOpCycles = 4
case 0x69:
cpu.HL.Lo = cpu.BC.Lo
cpu.LastOpCycles = 4
case 0x6a:
cpu.HL.Lo = cpu.DE.Hi
cpu.LastOpCycles = 4
case 0x6b:
cpu.HL.Lo = cpu.DE.Lo
cpu.LastOpCycles = 4
case 0x6c:
cpu.HL.Lo = cpu.HL.Hi
cpu.LastOpCycles = 4
case 0x6d:
//cpu.HL.Lo = cpu.HL.Lo
//cpu.LastOpCycles = 4
case 0x6f:
cpu.HL.Lo = cpu.AF.Hi
cpu.LastOpCycles = 4
case 0x78:
cpu.AF.Hi = cpu.BC.Hi
cpu.LastOpCycles = 4
case 0x79:
cpu.AF.Hi = cpu.BC.Lo
cpu.LastOpCycles = 4
case 0x7a:
cpu.AF.Hi = cpu.DE.Hi
cpu.LastOpCycles = 4
case 0x7b:
cpu.AF.Hi = cpu.DE.Lo
cpu.LastOpCycles = 4
case 0x7c:
cpu.AF.Hi = cpu.HL.Hi
cpu.LastOpCycles = 4
case 0x7d:
cpu.AF.Hi = cpu.HL.Lo
cpu.LastOpCycles = 4
case 0x7f:
//cpu.AF.Hi = cpu.AF.Hi
//cpu.LastOpCycles = 4
case 0x46:
xopLDbHLP(cpu)
case 0x4e:
xopLDcHLP(cpu)
case 0x56:
xopLDdHLP(cpu)
case 0x5e:
xopLDeHLP(cpu)
case 0x66:
xopLDhHLP(cpu)
case 0x6e:
xopLDlHLP(cpu)
case 0x7e:
xopLDaHLP(cpu)
case 0x70:
xopLDHLPb(cpu)
case 0x71:
xopLDHLPc(cpu)
case 0x72:
xopLDHLPd(cpu)
case 0x73:
xopLDHLPe(cpu)
case 0x74:
xopLDHLPh(cpu)
case 0x75:
xopLDHLPl(cpu)
case 0x77:
xopLDHLPa(cpu)
case 0x76:
oopHALT(cpu)
// ADD A, r
case 0x80:
xopADDAb(cpu)
case 0x81:
xopADDAc(cpu)
case 0x82:
xopADDAd(cpu)
case 0x83:
xopADDAe(cpu)
case 0x84:
xopADDAh(cpu)
case 0x85:
xopADDAl(cpu)
case 0x87:
xopADDAa(cpu)
// ADD A, (HL)
case 0x86:
oopADDAHLP(cpu)
// ADC A, r
case 0x88:
xopADCAb(cpu)
case 0x89:
xopADCAc(cpu)
case 0x8a:
xopADCAd(cpu)
case 0x8b:
xopADCAe(cpu)
case 0x8c:
xopADCAh(cpu)
case 0x8d:
xopADCAl(cpu)
case 0x8f:
xopADCAa(cpu)
case 0x8e:
oopADCAHLP(cpu)
// SUB A, r
case 0x90:
xopSUBAb(cpu)
case 0x91:
xopSUBAc(cpu)
case 0x92:
xopSUBAd(cpu)
case 0x93:
xopSUBAe(cpu)
case 0x94:
xopSUBAh(cpu)
case 0x95:
xopSUBAl(cpu)
case 0x97:
xopSUBAa(cpu)
case 0x96:
oopSUBAHLP(cpu)
// SBC A, r
case 0x98:
xopSBCAb(cpu)
case 0x99:
xopSBCAc(cpu)
case 0x9a:
xopSBCAd(cpu)
case 0x9b:
xopSBCAe(cpu)
case 0x9c:
xopSBCAh(cpu)
case 0x9d:
xopSBCAl(cpu)
case 0x9f:
xopSBCAa(cpu)
case 0x9e:
oopSBCAHLP(cpu)
// ADD r
case 0xa0:
xopANDAb(cpu)
case 0xa1:
xopANDAc(cpu)
case 0xa2:
xopANDAd(cpu)
case 0xa3:
xopANDAe(cpu)
case 0xa4:
xopANDAh(cpu)
case 0xa5:
xopANDAl(cpu)
case 0xa7:
xopANDAa(cpu)
case 0xa6:
oopANDHLP(cpu)
// XOR r
case 0xa8:
xopXORb(cpu)
case 0xa9:
xopXORc(cpu)
case 0xaa:
xopXORd(cpu)
case 0xab:
xopXORe(cpu)
case 0xac:
xopXORh(cpu)
case 0xad:
xopXORl(cpu)
case 0xaf:
xopXORa(cpu)
case 0xae:
oopXORHLP(cpu)
// OR r
case 0xb0:
xopORb(cpu)
case 0xb1:
xopORc(cpu)
case 0xb2:
xopORd(cpu)
case 0xb3:
xopORe(cpu)
case 0xb4:
xopORh(cpu)
case 0xb5:
xopORl(cpu)
case 0xb7:
xopORa(cpu)
case 0xb6:
oopORHLP(cpu)
// CP r
case 0xb8:
xopCPb(cpu)
case 0xb9:
xopCPc(cpu)
case 0xba:
xopCPd(cpu)
case 0xbb:
xopCPe(cpu)
case 0xbc:
xopCPh(cpu)
case 0xbd:
xopCPl(cpu)
case 0xbf:
xopCPa(cpu)
case 0xbe:
oopCPHLP(cpu)
case 0xc0:
xopRETnZ(cpu)
case 0xc8:
xopRETfZ(cpu)
case 0xd0:
xopRETnC(cpu)
case 0xd8:
xopRETfC(cpu)
case 0xe0:
xopRETnPV(cpu)
case 0xe8:
xopRETfPV(cpu)
case 0xf0:
xopRETnS(cpu)
case 0xf8:
xopRETfS(cpu)
case 0xc1:
xopPOPbc(cpu)
case 0xd1:
xopPOPde(cpu)
case 0xe1:
xopPOPhl(cpu)
case 0xf1:
xopPOPaf(cpu)
case 0xc2:
l := f.fetch()
h := f.fetch()
xopJPnZnn(cpu, l, h)
case 0xca:
l := f.fetch()
h := f.fetch()
xopJPfZnn(cpu, l, h)
case 0xd2:
l := f.fetch()
h := f.fetch()
xopJPnCnn(cpu, l, h)
case 0xda:
l := f.fetch()
h := f.fetch()
xopJPfCnn(cpu, l, h)
case 0xe2:
l := f.fetch()
h := f.fetch()
xopJPnPVnn(cpu, l, h)
case 0xea:
l := f.fetch()
h := f.fetch()
xopJPfPVnn(cpu, l, h)
case 0xf2:
l := f.fetch()
h := f.fetch()
xopJPnSnn(cpu, l, h)
case 0xfa:
l := f.fetch()
h := f.fetch()
xopJPfSnn(cpu, l, h)
case 0xc3:
l := f.fetch()
h := f.fetch()
oopJPnn(cpu, l, h)
case 0xc4:
l := f.fetch()
h := f.fetch()
xopCALLnZnn(cpu, l, h)
case 0xcc:
l := f.fetch()
h := f.fetch()
xopCALLfZnn(cpu, l, h)
case 0xd4:
l := f.fetch()
h := f.fetch()
xopCALLnCnn(cpu, l, h)
case 0xdc:
l := f.fetch()
h := f.fetch()
xopCALLfCnn(cpu, l, h)
case 0xe4:
l := f.fetch()
h := f.fetch()
xopCALLnPVnn(cpu, l, h)
case 0xec:
l := f.fetch()
h := f.fetch()
xopCALLfPVnn(cpu, l, h)
case 0xf4:
l := f.fetch()
h := f.fetch()
xopCALLnSnn(cpu, l, h)
case 0xfc:
l := f.fetch()
h := f.fetch()
xopCALLfSnn(cpu, l, h)
case 0xc5:
xopPUSHbc(cpu)
case 0xd5:
xopPUSHde(cpu)
case 0xe5:
xopPUSHhl(cpu)
case 0xf5:
xopPUSHaf(cpu)
case 0xc6:
n := f.fetch()
oopADDAn(cpu, n)
case 0xc7:
xopRST00(cpu)
case 0xcf:
xopRST08(cpu)
case 0xd7:
xopRST10(cpu)
case 0xdf:
xopRST18(cpu)
case 0xe7:
xopRST20(cpu)
case 0xef:
xopRST28(cpu)
case 0xf7:
xopRST30(cpu)
case 0xff:
xopRST38(cpu)
case 0xc9:
oopRET(cpu)
case 0xcd:
l := f.fetch()
h := f.fetch()
xopCALLnn(cpu, l, h)
case 0xce:
n := f.fetch()
oopADCAn(cpu, n)
case 0xd3:
n := f.fetch()
oopOUTnPA(cpu, n)
case 0xd6:
n := f.fetch()
oopSUBAn(cpu, n)
case 0xd9:
oopEXX(cpu)
case 0xdb:
n := f.fetch()
oopINAnP(cpu, n)
case 0xde:
n := f.fetch()
oopSBCAn(cpu, n)
case 0xe3:
oopEXSPPHL(cpu)
case 0xe6:
n := f.fetch()
oopANDn(cpu, n)
case 0xe9:
oopJPHLP(cpu)
case 0xeb:
oopEXDEHL(cpu)
case 0xee:
n := f.fetch()
oopXORn(cpu, n)
case 0xf3:
oopDI(cpu)
case 0xf6:
n := f.fetch()
oopORn(cpu, n)
case 0xf9:
oopLDSPHL(cpu)
case 0xfb:
oopEI(cpu)
case 0xfe:
n := f.fetch()
oopCPn(cpu, n)
case 0xcb:
c1 := f.fetch()
switch c1 {
// RLC r / RLC (HL)
case 0x00:
xopRLCb(cpu)
case 0x01:
xopRLCc(cpu)
case 0x02:
xopRLCd(cpu)
case 0x03:
xopRLCe(cpu)
case 0x04:
xopRLCh(cpu)
case 0x05:
xopRLCl(cpu)
case 0x06:
xopRLCHLP(cpu)
case 0x07:
xopRLCa(cpu)
// RRC r / RRC (HL)
case 0x08:
xopRRCb(cpu)
case 0x09:
xopRRCc(cpu)
case 0x0a:
xopRRCd(cpu)
case 0x0b:
xopRRCe(cpu)
case 0x0c:
xopRRCh(cpu)
case 0x0d:
xopRRCl(cpu)
case 0x0e:
xopRRCHLP(cpu)
case 0x0f:
xopRRCa(cpu)
// RL r / RL (HL)
case 0x10:
xopRLb(cpu)
case 0x11:
xopRLc(cpu)
case 0x12:
xopRLd(cpu)
case 0x13:
xopRLe(cpu)
case 0x14:
xopRLh(cpu)
case 0x15:
xopRLl(cpu)
case 0x16:
xopRLHLP(cpu)
case 0x17:
xopRLa(cpu)
// RR r / RR (HL)
case 0x18:
xopRRb(cpu)
case 0x19:
xopRRc(cpu)
case 0x1a:
xopRRd(cpu)
case 0x1b:
xopRRe(cpu)
case 0x1c:
xopRRh(cpu)
case 0x1d:
xopRRl(cpu)
case 0x1e:
xopRRHLP(cpu)
case 0x1f:
xopRRa(cpu)
// SLA r / SLA (HL)
case 0x20:
xopSLAb(cpu)
case 0x21:
xopSLAc(cpu)
case 0x22:
xopSLAd(cpu)
case 0x23:
xopSLAe(cpu)
case 0x24:
xopSLAh(cpu)
case 0x25:
xopSLAl(cpu)
case 0x26:
xopSLAHLP(cpu)
case 0x27:
xopSLAa(cpu)
// SRA r / SRA (HL)
case 0x28:
xopSRAb(cpu)
case 0x29:
xopSRAc(cpu)
case 0x2a:
xopSRAd(cpu)
case 0x2b:
xopSRAe(cpu)
case 0x2c:
xopSRAh(cpu)
case 0x2d:
xopSRAl(cpu)
case 0x2e:
xopSRAHLP(cpu)
case 0x2f:
xopSRAa(cpu)
// SL1 r / SL1 (HL) (undocumented)
case 0x30:
xopSL1b(cpu)
case 0x31:
xopSL1c(cpu)
case 0x32:
xopSL1d(cpu)
case 0x33:
xopSL1e(cpu)
case 0x34:
xopSL1h(cpu)
case 0x35:
xopSL1l(cpu)
case 0x36:
xopSL1HLP(cpu)
case 0x37:
xopSL1a(cpu)
// SRL r / SRL (HL)
case 0x38:
xopSRLb(cpu)
case 0x39:
xopSRLc(cpu)
case 0x3a:
xopSRLd(cpu)
case 0x3b:
xopSRLe(cpu)
case 0x3c:
xopSRLh(cpu)
case 0x3d:
xopSRLl(cpu)
case 0x3e:
xopSRLHLP(cpu)
case 0x3f:
xopSRLa(cpu)
// BIT 0, r|(HL)
case 0x40:
cpu.bitchk8(0, cpu.BC.Hi)
case 0x41:
cpu.bitchk8(0, cpu.BC.Lo)
case 0x42:
cpu.bitchk8(0, cpu.DE.Hi)
case 0x43:
cpu.bitchk8(0, cpu.DE.Lo)
case 0x44:
cpu.bitchk8(0, cpu.HL.Hi)
case 0x45:
cpu.bitchk8(0, cpu.HL.Lo)
case 0x46:
cpu.bitchk8b(0, cpu.Memory.Get(cpu.HL.U16()))
case 0x47:
cpu.bitchk8(0, cpu.AF.Hi)
// BIT 1, r|(HL)
case 0x48:
cpu.bitchk8(1, cpu.BC.Hi)
case 0x49:
cpu.bitchk8(1, cpu.BC.Lo)
case 0x4a:
cpu.bitchk8(1, cpu.DE.Hi)
case 0x4b:
cpu.bitchk8(1, cpu.DE.Lo)
case 0x4c:
cpu.bitchk8(1, cpu.HL.Hi)
case 0x4d:
cpu.bitchk8(1, cpu.HL.Lo)
case 0x4e:
cpu.bitchk8b(1, cpu.Memory.Get(cpu.HL.U16()))
case 0x4f:
cpu.bitchk8(1, cpu.AF.Hi)
// BIT 2, r|(HL)
case 0x50:
cpu.bitchk8(2, cpu.BC.Hi)
case 0x51:
cpu.bitchk8(2, cpu.BC.Lo)
case 0x52:
cpu.bitchk8(2, cpu.DE.Hi)
case 0x53:
cpu.bitchk8(2, cpu.DE.Lo)
case 0x54:
cpu.bitchk8(2, cpu.HL.Hi)
case 0x55:
cpu.bitchk8(2, cpu.HL.Lo)
case 0x56:
cpu.bitchk8b(2, cpu.Memory.Get(cpu.HL.U16()))
case 0x57:
cpu.bitchk8(2, cpu.AF.Hi)
// BIT 3, r|(HL)
case 0x58:
cpu.bitchk8(3, cpu.BC.Hi)
case 0x59:
cpu.bitchk8(3, cpu.BC.Lo)
case 0x5a:
cpu.bitchk8(3, cpu.DE.Hi)
case 0x5b:
cpu.bitchk8(3, cpu.DE.Lo)
case 0x5c:
cpu.bitchk8(3, cpu.HL.Hi)
case 0x5d:
cpu.bitchk8(3, cpu.HL.Lo)
case 0x5e:
cpu.bitchk8b(3, cpu.Memory.Get(cpu.HL.U16()))
case 0x5f:
cpu.bitchk8(3, cpu.AF.Hi)
// BIT 4, r|(HL)
case 0x60:
cpu.bitchk8(4, cpu.BC.Hi)
case 0x61:
cpu.bitchk8(4, cpu.BC.Lo)
case 0x62:
cpu.bitchk8(4, cpu.DE.Hi)
case 0x63:
cpu.bitchk8(4, cpu.DE.Lo)
case 0x64:
cpu.bitchk8(4, cpu.HL.Hi)
case 0x65:
cpu.bitchk8(4, cpu.HL.Lo)
case 0x66:
cpu.bitchk8b(4, cpu.Memory.Get(cpu.HL.U16()))
case 0x67:
cpu.bitchk8(4, cpu.AF.Hi)
// BIT 5, r|(HL)
case 0x68:
cpu.bitchk8(5, cpu.BC.Hi)
case 0x69:
cpu.bitchk8(5, cpu.BC.Lo)
case 0x6a:
cpu.bitchk8(5, cpu.DE.Hi)
case 0x6b:
cpu.bitchk8(5, cpu.DE.Lo)
case 0x6c:
cpu.bitchk8(5, cpu.HL.Hi)
case 0x6d:
cpu.bitchk8(5, cpu.HL.Lo)
case 0x6e:
cpu.bitchk8b(5, cpu.Memory.Get(cpu.HL.U16()))
case 0x6f:
cpu.bitchk8(5, cpu.AF.Hi)
// BIT 6, r|(HL)
case 0x70:
cpu.bitchk8(6, cpu.BC.Hi)
case 0x71:
cpu.bitchk8(6, cpu.BC.Lo)
case 0x72:
cpu.bitchk8(6, cpu.DE.Hi)
case 0x73:
cpu.bitchk8(6, cpu.DE.Lo)
case 0x74:
cpu.bitchk8(6, cpu.HL.Hi)