-
Notifications
You must be signed in to change notification settings - Fork 0
/
instr_cb.c
2848 lines (2548 loc) · 54.1 KB
/
instr_cb.c
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
/*
* Z80SIM - a Z80-CPU simulator
*
* Copyright (C) 1987-2008 by Udo Munk
*
* History:
* 28-SEP-87 Development on TARGON/35 with AT&T Unix System V.3
* 11-JAN-89 Release 1.1
* 08-FEB-89 Release 1.2
* 13-MAR-89 Release 1.3
* 09-FEB-90 Release 1.4 Ported to TARGON/31 M10/30
* 20-DEC-90 Release 1.5 Ported to COHERENT 3.0
* 10-JUN-92 Release 1.6 long casting problem solved with COHERENT 3.2
* and some optimization
* 25-JUN-92 Release 1.7 comments in english and ported to COHERENT 4.0
* 02-OCT-06 Release 1.8 modified to compile on modern POSIX OS's
* 18-NOV-06 Release 1.9 modified to work with CP/M sources
* 08-DEC-06 Release 1.10 modified MMU for working with CP/NET
* 17-DEC-06 Release 1.11 TCP/IP sockets for CP/NET
* 25-DEC-06 Release 1.12 CPU speed option
* 19-FEB-07 Release 1.13 various improvements
* 06-OCT-07 Release 1.14 bug fixes and improvements
* 06-AUG-08 Release 1.15 many improvements and Windows support via Cygwin
* 25-AUG-08 Release 1.16 console status I/O loop detection and line discipline
* 20-OCT-08 Release 1.17 frontpanel integrated and Altair/IMSAI emulations
*/
/*
* Like the function "cpu()" this one emulates multi byte opcodes
* starting with 0xcb
*/
#include "config.h"
#include "global.h"
#ifdef FRONTPANEL
#include "../../frontpanel/frontpanel.h"
#endif
static int trap_cb(void);
static int op_srla(void), op_srlb(void), op_srlc(void);
static int op_srld(void), op_srle(void);
static int op_srlh(void), op_srll(void), op_srlhl(void);
static int op_slaa(void), op_slab(void), op_slac(void);
static int op_slad(void), op_slae(void);
static int op_slah(void), op_slal(void), op_slahl(void);
static int op_rlra(void), op_rlb(void), op_rlc(void);
static int op_rld(void), op_rle(void);
static int op_rlh(void), op_rll(void), op_rlhl(void);
static int op_rrra(void), op_rrb(void), op_rrc(void);
static int op_rrd(void), op_rre(void);
static int op_rrh(void), op_rrl(void), op_rrhl(void);
static int op_rrcra(void), op_rrcb(void), op_rrcc(void);
static int op_rrcd(void), op_rrce(void);
static int op_rrch(void), op_rrcl(void), op_rrchl(void);
static int op_rlcra(void), op_rlcb(void), op_rlcc(void);
static int op_rlcd(void), op_rlce(void);
static int op_rlch(void), op_rlcl(void), op_rlchl(void);
static int op_sraa(void), op_srab(void), op_srac(void);
static int op_srad(void), op_srae(void);
static int op_srah(void), op_sral(void), op_srahl(void);
static int op_sb0a(void), op_sb1a(void), op_sb2a(void), op_sb3a(void);
static int op_sb4a(void), op_sb5a(void), op_sb6a(void), op_sb7a(void);
static int op_sb0b(void), op_sb1b(void), op_sb2b(void), op_sb3b(void);
static int op_sb4b(void), op_sb5b(void), op_sb6b(void), op_sb7b(void);
static int op_sb0c(void), op_sb1c(void), op_sb2c(void), op_sb3c(void);
static int op_sb4c(void), op_sb5c(void), op_sb6c(void), op_sb7c(void);
static int op_sb0d(void), op_sb1d(void), op_sb2d(void), op_sb3d(void);
static int op_sb4d(void), op_sb5d(void), op_sb6d(void), op_sb7d(void);
static int op_sb0e(void), op_sb1e(void), op_sb2e(void), op_sb3e(void);
static int op_sb4e(void), op_sb5e(void), op_sb6e(void), op_sb7e(void);
static int op_sb0h(void), op_sb1h(void), op_sb2h(void), op_sb3h(void);
static int op_sb4h(void), op_sb5h(void), op_sb6h(void), op_sb7h(void);
static int op_sb0l(void), op_sb1l(void), op_sb2l(void), op_sb3l(void);
static int op_sb4l(void), op_sb5l(void), op_sb6l(void), op_sb7l(void);
static int op_sb0hl(void), op_sb1hl(void), op_sb2hl(void), op_sb3hl(void);
static int op_sb4hl(void), op_sb5hl(void), op_sb6hl(void), op_sb7hl(void);
static int op_rb0a(void), op_rb1a(void), op_rb2a(void), op_rb3a(void);
static int op_rb4a(void), op_rb5a(void), op_rb6a(void), op_rb7a(void);
static int op_rb0b(void), op_rb1b(void), op_rb2b(void), op_rb3b(void);
static int op_rb4b(void), op_rb5b(void), op_rb6b(void), op_rb7b(void);
static int op_rb0c(void), op_rb1c(void), op_rb2c(void), op_rb3c(void);
static int op_rb4c(void), op_rb5c(void), op_rb6c(void), op_rb7c(void);
static int op_rb0d(void), op_rb1d(void), op_rb2d(void), op_rb3d(void);
static int op_rb4d(void), op_rb5d(void), op_rb6d(void), op_rb7d(void);
static int op_rb0e(void), op_rb1e(void), op_rb2e(void), op_rb3e(void);
static int op_rb4e(void), op_rb5e(void), op_rb6e(void), op_rb7e(void);
static int op_rb0h(void), op_rb1h(void), op_rb2h(void), op_rb3h(void);
static int op_rb4h(void), op_rb5h(void), op_rb6h(void), op_rb7h(void);
static int op_rb0l(void), op_rb1l(void), op_rb2l(void), op_rb3l(void);
static int op_rb4l(void), op_rb5l(void), op_rb6l(void), op_rb7l(void);
static int op_rb0hl(void), op_rb1hl(void), op_rb2hl(void), op_rb3hl(void);
static int op_rb4hl(void), op_rb5hl(void), op_rb6hl(void), op_rb7hl(void);
static int op_tb0a(void), op_tb1a(void), op_tb2a(void), op_tb3a(void);
static int op_tb4a(void), op_tb5a(void), op_tb6a(void), op_tb7a(void);
static int op_tb0b(void), op_tb1b(void), op_tb2b(void), op_tb3b(void);
static int op_tb4b(void), op_tb5b(void), op_tb6b(void), op_tb7b(void);
static int op_tb0c(void), op_tb1c(void), op_tb2c(void), op_tb3c(void);
static int op_tb4c(void), op_tb5c(void), op_tb6c(void), op_tb7c(void);
static int op_tb0d(void), op_tb1d(void), op_tb2d(void), op_tb3d(void);
static int op_tb4d(void), op_tb5d(void), op_tb6d(void), op_tb7d(void);
static int op_tb0e(void), op_tb1e(void), op_tb2e(void), op_tb3e(void);
static int op_tb4e(void), op_tb5e(void), op_tb6e(void), op_tb7e(void);
static int op_tb0h(void), op_tb1h(void), op_tb2h(void), op_tb3h(void);
static int op_tb4h(void), op_tb5h(void), op_tb6h(void), op_tb7h(void);
static int op_tb0l(void), op_tb1l(void), op_tb2l(void), op_tb3l(void);
static int op_tb4l(void), op_tb5l(void), op_tb6l(void), op_tb7l(void);
static int op_tb0hl(void), op_tb1hl(void), op_tb2hl(void), op_tb3hl(void);
static int op_tb4hl(void), op_tb5hl(void), op_tb6hl(void), op_tb7hl(void);
int op_cb_handel(void)
{
register int t;
static int (*op_cb[256]) (void) = {
op_rlcb, /* 0x00 */
op_rlcc, /* 0x01 */
op_rlcd, /* 0x02 */
op_rlce, /* 0x03 */
op_rlch, /* 0x04 */
op_rlcl, /* 0x05 */
op_rlchl, /* 0x06 */
op_rlcra, /* 0x07 */
op_rrcb, /* 0x08 */
op_rrcc, /* 0x09 */
op_rrcd, /* 0x0a */
op_rrce, /* 0x0b */
op_rrch, /* 0x0c */
op_rrcl, /* 0x0d */
op_rrchl, /* 0x0e */
op_rrcra, /* 0x0f */
op_rlb, /* 0x10 */
op_rlc, /* 0x11 */
op_rld, /* 0x12 */
op_rle, /* 0x13 */
op_rlh, /* 0x14 */
op_rll, /* 0x15 */
op_rlhl, /* 0x16 */
op_rlra, /* 0x17 */
op_rrb, /* 0x18 */
op_rrc, /* 0x19 */
op_rrd, /* 0x1a */
op_rre, /* 0x1b */
op_rrh, /* 0x1c */
op_rrl, /* 0x1d */
op_rrhl, /* 0x1e */
op_rrra, /* 0x1f */
op_slab, /* 0x20 */
op_slac, /* 0x21 */
op_slad, /* 0x22 */
op_slae, /* 0x23 */
op_slah, /* 0x24 */
op_slal, /* 0x25 */
op_slahl, /* 0x26 */
op_slaa, /* 0x27 */
op_srab, /* 0x28 */
op_srac, /* 0x29 */
op_srad, /* 0x2a */
op_srae, /* 0x2b */
op_srah, /* 0x2c */
op_sral, /* 0x2d */
op_srahl, /* 0x2e */
op_sraa, /* 0x2f */
trap_cb, /* 0x30 */
trap_cb, /* 0x31 */
trap_cb, /* 0x32 */
trap_cb, /* 0x33 */
trap_cb, /* 0x34 */
trap_cb, /* 0x35 */
trap_cb, /* 0x36 */
trap_cb, /* 0x37 */
op_srlb, /* 0x38 */
op_srlc, /* 0x39 */
op_srld, /* 0x3a */
op_srle, /* 0x3b */
op_srlh, /* 0x3c */
op_srll, /* 0x3d */
op_srlhl, /* 0x3e */
op_srla, /* 0x3f */
op_tb0b, /* 0x40 */
op_tb0c, /* 0x41 */
op_tb0d, /* 0x42 */
op_tb0e, /* 0x43 */
op_tb0h, /* 0x44 */
op_tb0l, /* 0x45 */
op_tb0hl, /* 0x46 */
op_tb0a, /* 0x47 */
op_tb1b, /* 0x48 */
op_tb1c, /* 0x49 */
op_tb1d, /* 0x4a */
op_tb1e, /* 0x4b */
op_tb1h, /* 0x4c */
op_tb1l, /* 0x4d */
op_tb1hl, /* 0x4e */
op_tb1a, /* 0x4f */
op_tb2b, /* 0x50 */
op_tb2c, /* 0x51 */
op_tb2d, /* 0x52 */
op_tb2e, /* 0x53 */
op_tb2h, /* 0x54 */
op_tb2l, /* 0x55 */
op_tb2hl, /* 0x56 */
op_tb2a, /* 0x57 */
op_tb3b, /* 0x58 */
op_tb3c, /* 0x59 */
op_tb3d, /* 0x5a */
op_tb3e, /* 0x5b */
op_tb3h, /* 0x5c */
op_tb3l, /* 0x5d */
op_tb3hl, /* 0x5e */
op_tb3a, /* 0x5f */
op_tb4b, /* 0x60 */
op_tb4c, /* 0x61 */
op_tb4d, /* 0x62 */
op_tb4e, /* 0x63 */
op_tb4h, /* 0x64 */
op_tb4l, /* 0x65 */
op_tb4hl, /* 0x66 */
op_tb4a, /* 0x67 */
op_tb5b, /* 0x68 */
op_tb5c, /* 0x69 */
op_tb5d, /* 0x6a */
op_tb5e, /* 0x6b */
op_tb5h, /* 0x6c */
op_tb5l, /* 0x6d */
op_tb5hl, /* 0x6e */
op_tb5a, /* 0x6f */
op_tb6b, /* 0x70 */
op_tb6c, /* 0x71 */
op_tb6d, /* 0x72 */
op_tb6e, /* 0x73 */
op_tb6h, /* 0x74 */
op_tb6l, /* 0x75 */
op_tb6hl, /* 0x76 */
op_tb6a, /* 0x77 */
op_tb7b, /* 0x78 */
op_tb7c, /* 0x79 */
op_tb7d, /* 0x7a */
op_tb7e, /* 0x7b */
op_tb7h, /* 0x7c */
op_tb7l, /* 0x7d */
op_tb7hl, /* 0x7e */
op_tb7a, /* 0x7f */
op_rb0b, /* 0x80 */
op_rb0c, /* 0x81 */
op_rb0d, /* 0x82 */
op_rb0e, /* 0x83 */
op_rb0h, /* 0x84 */
op_rb0l, /* 0x85 */
op_rb0hl, /* 0x86 */
op_rb0a, /* 0x87 */
op_rb1b, /* 0x88 */
op_rb1c, /* 0x89 */
op_rb1d, /* 0x8a */
op_rb1e, /* 0x8b */
op_rb1h, /* 0x8c */
op_rb1l, /* 0x8d */
op_rb1hl, /* 0x8e */
op_rb1a, /* 0x8f */
op_rb2b, /* 0x90 */
op_rb2c, /* 0x91 */
op_rb2d, /* 0x92 */
op_rb2e, /* 0x93 */
op_rb2h, /* 0x94 */
op_rb2l, /* 0x95 */
op_rb2hl, /* 0x96 */
op_rb2a, /* 0x97 */
op_rb3b, /* 0x98 */
op_rb3c, /* 0x99 */
op_rb3d, /* 0x9a */
op_rb3e, /* 0x9b */
op_rb3h, /* 0x9c */
op_rb3l, /* 0x9d */
op_rb3hl, /* 0x9e */
op_rb3a, /* 0x9f */
op_rb4b, /* 0xa0 */
op_rb4c, /* 0xa1 */
op_rb4d, /* 0xa2 */
op_rb4e, /* 0xa3 */
op_rb4h, /* 0xa4 */
op_rb4l, /* 0xa5 */
op_rb4hl, /* 0xa6 */
op_rb4a, /* 0xa7 */
op_rb5b, /* 0xa8 */
op_rb5c, /* 0xa9 */
op_rb5d, /* 0xaa */
op_rb5e, /* 0xab */
op_rb5h, /* 0xac */
op_rb5l, /* 0xad */
op_rb5hl, /* 0xae */
op_rb5a, /* 0xaf */
op_rb6b, /* 0xb0 */
op_rb6c, /* 0xb1 */
op_rb6d, /* 0xb2 */
op_rb6e, /* 0xb3 */
op_rb6h, /* 0xb4 */
op_rb6l, /* 0xb5 */
op_rb6hl, /* 0xb6 */
op_rb6a, /* 0xb7 */
op_rb7b, /* 0xb8 */
op_rb7c, /* 0xb9 */
op_rb7d, /* 0xba */
op_rb7e, /* 0xbb */
op_rb7h, /* 0xbc */
op_rb7l, /* 0xbd */
op_rb7hl, /* 0xbe */
op_rb7a, /* 0xbf */
op_sb0b, /* 0xc0 */
op_sb0c, /* 0xc1 */
op_sb0d, /* 0xc2 */
op_sb0e, /* 0xc3 */
op_sb0h, /* 0xc4 */
op_sb0l, /* 0xc5 */
op_sb0hl, /* 0xc6 */
op_sb0a, /* 0xc7 */
op_sb1b, /* 0xc8 */
op_sb1c, /* 0xc9 */
op_sb1d, /* 0xca */
op_sb1e, /* 0xcb */
op_sb1h, /* 0xcc */
op_sb1l, /* 0xcd */
op_sb1hl, /* 0xce */
op_sb1a, /* 0xcf */
op_sb2b, /* 0xd0 */
op_sb2c, /* 0xd1 */
op_sb2d, /* 0xd2 */
op_sb2e, /* 0xd3 */
op_sb2h, /* 0xd4 */
op_sb2l, /* 0xd5 */
op_sb2hl, /* 0xd6 */
op_sb2a, /* 0xd7 */
op_sb3b, /* 0xd8 */
op_sb3c, /* 0xd9 */
op_sb3d, /* 0xda */
op_sb3e, /* 0xdb */
op_sb3h, /* 0xdc */
op_sb3l, /* 0xdd */
op_sb3hl, /* 0xde */
op_sb3a, /* 0xdf */
op_sb4b, /* 0xe0 */
op_sb4c, /* 0xe1 */
op_sb4d, /* 0xe2 */
op_sb4e, /* 0xe3 */
op_sb4h, /* 0xe4 */
op_sb4l, /* 0xe5 */
op_sb4hl, /* 0xe6 */
op_sb4a, /* 0xe7 */
op_sb5b, /* 0xe8 */
op_sb5c, /* 0xe9 */
op_sb5d, /* 0xea */
op_sb5e, /* 0xeb */
op_sb5h, /* 0xec */
op_sb5l, /* 0xed */
op_sb5hl, /* 0xee */
op_sb5a, /* 0xef */
op_sb6b, /* 0xf0 */
op_sb6c, /* 0xf1 */
op_sb6d, /* 0xf2 */
op_sb6e, /* 0xf3 */
op_sb6h, /* 0xf4 */
op_sb6l, /* 0xf5 */
op_sb6hl, /* 0xf6 */
op_sb6a, /* 0xf7 */
op_sb7b, /* 0xf8 */
op_sb7c, /* 0xf9 */
op_sb7d, /* 0xfa */
op_sb7e, /* 0xfb */
op_sb7h, /* 0xfc */
op_sb7l, /* 0xfd */
op_sb7hl, /* 0xfe */
op_sb7a /* 0xff */
};
#ifdef WANT_TIM
t = (*op_cb[*PC++]) (); /* execute next opcode */
#else
(*op_cb[*PC++]) ();
#endif
#ifdef WANT_PCC
if (PC > ram + 65535) /* correct PC overrun */
PC = ram;
#endif
return(t);
}
/*
* This function traps all illegal opcodes following the
* initial 0xcb of a multi byte opcode.
*/
static int trap_cb(void)
{
cpu_error = OPTRAP2;
cpu_state = STOPPED;
return(0);
}
static int op_srla(void) /* SRL A */
{
(A & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
A >>= 1;
F &= ~(H_FLAG | N_FLAG);
(A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[A]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_srlb(void) /* SRL B */
{
(B & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
B >>= 1;
F &= ~(H_FLAG | N_FLAG);
(B) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(B & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[B]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_srlc(void) /* SRL C */
{
(C & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
C >>= 1;
F &= ~(H_FLAG | N_FLAG);
(C) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(C & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[C]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_srld(void) /* SRL D */
{
(D & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
D >>= 1;
F &= ~(H_FLAG | N_FLAG);
(D) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(D & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[D]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_srle(void) /* SRL E */
{
(E & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
E >>= 1;
F &= ~(H_FLAG | N_FLAG);
(E) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(E & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[E]) ? (F &= ~P_FLAG) :(F |= P_FLAG);
return(8);
}
static int op_srlh(void) /* SRL H */
{
(H & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
H >>= 1;
F &= ~(H_FLAG | N_FLAG);
(H) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(H & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[H]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_srll(void) /* SRL L */
{
(L & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
L >>= 1;
F &= ~(H_FLAG | N_FLAG);
(L) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(L & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[L]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_srlhl(void) /* SRL (HL) */
{
register BYTE *p;
#ifdef BUS_8080
cpu_bus = CPU_WO | CPU_MEMR;
#endif
#ifdef FRONTPANEL
fp_sampleLightGroup(0, 0);
#endif
p = ram + (H << 8) + L;
(*p & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
*p >>= 1;
F &= ~(H_FLAG | N_FLAG);
(*p) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(*p & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[*p]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
#ifdef BUS_8080
cpu_bus = 0;
#endif
#ifdef FRONTPANEL
fp_sampleLightGroup(0, 0);
#endif
return(15);
}
static int op_slaa(void) /* SLA A */
{
(A & 128) ? (F |= C_FLAG) : (F &= ~C_FLAG);
A <<= 1;
F &= ~(H_FLAG | N_FLAG);
(A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[A]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_slab(void) /* SLA B */
{
(B & 128) ? (F |= C_FLAG) : (F &= ~C_FLAG);
B <<= 1;
F &= ~(H_FLAG | N_FLAG);
(B) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(B & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[B]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_slac(void) /* SLA C */
{
(C & 128) ? (F |= C_FLAG) : (F &= ~C_FLAG);
C <<= 1;
F &= ~(H_FLAG | N_FLAG);
(C) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(C & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[C]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_slad(void) /* SLA D */
{
(D & 128) ? (F |= C_FLAG) : (F &= ~C_FLAG);
D <<= 1;
F &= ~(H_FLAG | N_FLAG);
(D) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(D & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[D]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_slae(void) /* SLA E */
{
(E & 128) ? (F |= C_FLAG) : (F &= ~C_FLAG);
E <<= 1;
F &= ~(H_FLAG | N_FLAG);
(E) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(E & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[E]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_slah(void) /* SLA H */
{
(H & 128) ? (F |= C_FLAG) : (F &= ~C_FLAG);
H <<= 1;
F &= ~(H_FLAG | N_FLAG);
(H) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(H & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[H]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_slal(void) /* SLA L */
{
(L & 128) ? (F |= C_FLAG) : (F &= ~C_FLAG);
L <<= 1;
F &= ~(H_FLAG | N_FLAG);
(L) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(L & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[L]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_slahl(void) /* SLA (HL) */
{
register BYTE *p;
#ifdef BUS_8080
cpu_bus = CPU_WO | CPU_MEMR;
#endif
#ifdef FRONTPANEL
fp_sampleLightGroup(0, 0);
#endif
p = ram + (H << 8) + L;
(*p & 128) ? (F |= C_FLAG) : (F &= ~C_FLAG);
*p <<= 1;
F &= ~(H_FLAG | N_FLAG);
(*p) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(*p & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[*p]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
#ifdef BUS_8080
cpu_bus = 0;
#endif
#ifdef FRONTPANEL
fp_sampleLightGroup(0, 0);
#endif
return(15);
}
static int op_rlra(void) /* RL A */
{
register int old_c_flag;
old_c_flag = F & C_FLAG;
(A & 128) ? (F |= C_FLAG) : (F &= ~C_FLAG);
A <<= 1;
if (old_c_flag) A |= 1;
F &= ~(H_FLAG | N_FLAG);
(A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[A]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rlb(void) /* RL B */
{
register int old_c_flag;
old_c_flag = F & C_FLAG;
(B & 128) ? (F |= C_FLAG) : (F &= ~C_FLAG);
B <<= 1;
if (old_c_flag) B |= 1;
F &= ~(H_FLAG | N_FLAG);
(B) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(B & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[B]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rlc(void) /* RL C */
{
register int old_c_flag;
old_c_flag = F & C_FLAG;
(C & 128) ? (F |= C_FLAG) : (F &= ~C_FLAG);
C <<= 1;
if (old_c_flag) C |= 1;
F &= ~(H_FLAG | N_FLAG);
(C) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(C & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[C]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rld(void) /* RL D */
{
register int old_c_flag;
old_c_flag = F & C_FLAG;
(D & 128) ? (F |= C_FLAG) : (F &= ~C_FLAG);
D <<= 1;
if (old_c_flag) D |= 1;
F &= ~(H_FLAG | N_FLAG);
(D) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(D & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[D]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rle(void) /* RL E */
{
register int old_c_flag;
old_c_flag = F & C_FLAG;
(E & 128) ? (F |= C_FLAG) : (F &= ~C_FLAG);
E <<= 1;
if (old_c_flag) E |= 1;
F &= ~(H_FLAG | N_FLAG);
(E) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(E & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[E]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rlh(void) /* RL H */
{
register int old_c_flag;
old_c_flag = F & C_FLAG;
(H & 128) ? (F |= C_FLAG) : (F &= ~C_FLAG);
H <<= 1;
if (old_c_flag) H |= 1;
F &= ~(H_FLAG | N_FLAG);
(H) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(H & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[H]) ? (F &= ~P_FLAG) :(F |= P_FLAG);
return(8);
}
static int op_rll(void) /* RL L */
{
register int old_c_flag;
old_c_flag = F & C_FLAG;
(L & 128) ? (F |= C_FLAG) : (F &= ~C_FLAG);
L <<= 1;
if (old_c_flag) L |= 1;
F &= ~(H_FLAG | N_FLAG);
(L) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(L & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[L]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rlhl(void) /* RL (HL) */
{
register int old_c_flag;
register BYTE *p;
#ifdef BUS_8080
cpu_bus = CPU_WO | CPU_MEMR;
#endif
#ifdef FRONTPANEL
fp_sampleLightGroup(0, 0);
#endif
p = ram + (H << 8) + L;
old_c_flag = F & C_FLAG;
(*p & 128) ? (F |= C_FLAG) : (F &= ~C_FLAG);
*p <<= 1;
if (old_c_flag) *p |= 1;
F &= ~(H_FLAG | N_FLAG);
(*p) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(*p & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[*p]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
#ifdef BUS_8080
cpu_bus = 0;
#endif
#ifdef FRONTPANEL
fp_sampleLightGroup(0, 0);
#endif
return(15);
}
static int op_rrra(void) /* RR A */
{
register int old_c_flag;
old_c_flag = F & C_FLAG;
(A & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
A >>= 1;
if (old_c_flag) A |= 128;
F &= ~(H_FLAG | N_FLAG);
(A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[A]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rrb(void) /* RR B */
{
register int old_c_flag;
old_c_flag = F & C_FLAG;
(B & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
B >>= 1;
if (old_c_flag) B |= 128;
F &= ~(H_FLAG | N_FLAG);
(B) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(B & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[B]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rrc(void) /* RR C */
{
register int old_c_flag;
old_c_flag = F & C_FLAG;
(C & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
C >>= 1;
if (old_c_flag) C |= 128;
F &= ~(H_FLAG | N_FLAG);
(C) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(C & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[C]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rrd(void) /* RR D */
{
register int old_c_flag;
old_c_flag = F & C_FLAG;
(D & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
D >>= 1;
if (old_c_flag) D |= 128;
F &= ~(H_FLAG | N_FLAG);
(D) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(D & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[D]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rre(void) /* RR E */
{
register int old_c_flag;
old_c_flag = F & C_FLAG;
(E & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
E >>= 1;
if (old_c_flag) E |= 128;
F &= ~(H_FLAG | N_FLAG);
(E) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(E & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[E]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rrh(void) /* RR H */
{
register int old_c_flag;
old_c_flag = F & C_FLAG;
(H & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
H >>= 1;
if (old_c_flag) H |= 128;
F &= ~(H_FLAG | N_FLAG);
(H) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(H & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[H]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rrl(void) /* RR L */
{
register int old_c_flag;
old_c_flag = F & C_FLAG;
(L & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
L >>= 1;
if (old_c_flag) L |= 128;
F &= ~(H_FLAG | N_FLAG);
(L) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(L & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[L]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rrhl(void) /* RR (HL) */
{
register int old_c_flag;
register BYTE *p;
#ifdef BUS_8080
cpu_bus = CPU_WO | CPU_MEMR;
#endif
#ifdef FRONTPANEL
fp_sampleLightGroup(0, 0);
#endif
old_c_flag = F & C_FLAG;
p = ram + (H << 8) + L;
(*p & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
*p >>= 1;
if (old_c_flag) *p |= 128;
F &= ~(H_FLAG | N_FLAG);
(*p) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(*p & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[*p]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
#ifdef BUS_8080
cpu_bus = 0;
#endif
#ifdef FRONTPANEL
fp_sampleLightGroup(0, 0);
#endif
return(15);
}
static int op_rrcra(void) /* RRC A */
{
register int i;
i = A & 1;
(i) ? (F |= C_FLAG) : (F &= ~C_FLAG);
F &= ~(H_FLAG | N_FLAG);
A >>= 1;
if (i) A |= 128;
(A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[A]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rrcb(void) /* RRC B */
{
register int i;
i = B & 1;
(i) ? (F |= C_FLAG) : (F &= ~C_FLAG);
F &= ~(H_FLAG | N_FLAG);
B >>= 1;
if (i) B |= 128;
(B) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(B & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[B]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rrcc(void) /* RRC C */
{
register int i;
i = C & 1;
(i) ? (F |= C_FLAG) : (F &= ~C_FLAG);
F &= ~(H_FLAG | N_FLAG);
C >>= 1;
if (i) C |= 128;
(C) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(C & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[C]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rrcd(void) /* RRC D */
{
register int i;
i = D & 1;
(i) ? (F |= C_FLAG) : (F &= ~C_FLAG);
F &= ~(H_FLAG | N_FLAG);
D >>= 1;
if (i) D |= 128;
(D) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(D & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[D]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rrce(void) /* RRC E */
{
register int i;
i = E & 1;
(i) ? (F |= C_FLAG) : (F &= ~C_FLAG);
F &= ~(H_FLAG | N_FLAG);
E >>= 1;
if (i) E |= 128;
(E) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(E & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[E]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rrch(void) /* RRC H */
{
register int i;
i = H & 1;
(i) ? (F |= C_FLAG) : (F &= ~C_FLAG);
F &= ~(H_FLAG | N_FLAG);
H >>= 1;
if (i) H |= 128;
(H) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(H & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[H]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rrcl(void) /* RRC L */
{
register int i;
i = L & 1;
(i) ? (F |= C_FLAG) : (F &= ~C_FLAG);
F &= ~(H_FLAG | N_FLAG);
L >>= 1;
if (i) L |= 128;
(L) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(L & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[L]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
return(8);
}
static int op_rrchl(void) /* RRC (HL) */
{
register int i;
register BYTE *p;
#ifdef BUS_8080
cpu_bus = CPU_WO | CPU_MEMR;
#endif
#ifdef FRONTPANEL
fp_sampleLightGroup(0, 0);
#endif
p = ram + (H << 8) + L;
i = *p & 1;
(i) ? (F |= C_FLAG) : (F &= ~C_FLAG);
F &= ~(H_FLAG | N_FLAG);
*p >>= 1;
if (i) *p |= 128;
(*p) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
(*p & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
(parrity[*p]) ? (F &= ~P_FLAG) : (F |= P_FLAG);
#ifdef BUS_8080
cpu_bus = 0;
#endif