Commit 6619a10

Adrian Siekierka committed on
z80cpu: fix most CB-prefixed [hl] opcodes
commit 6619a10da81f7e76fb295c650417a909ef8fb188 parent c8ae502
1 changed files +36−39
Modifiedsrc/z80cpu.pas +36−39
@@ -20,7 +20,6 @@ uses vars, machine, cpu_tables, LazLoggerBase;
20 20
21 // temporary variables 21 // temporary variables
22 var 22 var
23 addr: Word;
24 qtemp: Quadruple; 23 qtemp: Quadruple;
25 ptemp: Pair; 24 ptemp: Pair;
26 w1, w2: word; 25 w1, w2: word;
@@ -1826,8 +1825,6 @@ var
1826 b: byte; 1825 b: byte;
1827 begin 1826 begin
1828 b := speekb(pc.W - 1); 1827 b := speekb(pc.W - 1);
1829 addr := hl.w;
1830
1831 Result := Z80[b or 256](); 1828 Result := Z80[b or 256]();
1832 end; 1829 end;
1833 1830
@@ -2400,9 +2397,9 @@ function rlc: byte;
2400 var 2397 var
2401 btemp: byte; 2398 btemp: byte;
2402 begin 2399 begin
2403 btemp := speekb(ADDR); 2400 btemp := speekb(hl.w);
2404 af.l := rlcr_f[btemp]; 2401 af.l := rlcr_f[btemp];
2405 spokeb(ADDR, rlcr_a[btemp]); 2402 spokeb(hl.w, rlcr_a[btemp]);
2406 2403
2407 Result := 24; 2404 Result := 24;
2408 end; 2405 end;
@@ -2475,9 +2472,9 @@ function rrc: byte;
2475 var 2472 var
2476 btemp: byte; 2473 btemp: byte;
2477 begin 2474 begin
2478 btemp := speekb(ADDR); 2475 btemp := speekb(hl.w);
2479 af.l := rrcr_f[btemp]; 2476 af.l := rrcr_f[btemp];
2480 spokeb(ADDR, rrcr_a[btemp]); 2477 spokeb(hl.w, rrcr_a[btemp]);
2481 2478
2482 Result := 16; 2479 Result := 16;
2483 end; 2480 end;
@@ -2584,15 +2581,15 @@ var
2584 begin 2581 begin
2585 if af.l and 1 = 0 then 2582 if af.l and 1 = 0 then
2586 begin 2583 begin
2587 btemp := speekb(Addr); 2584 btemp := speekb(hl.w);
2588 af.l := rlr_f[0][btemp]; 2585 af.l := rlr_f[0][btemp];
2589 spokeb(Addr, rlr_a[0][btemp]); 2586 spokeb(hl.w, rlr_a[0][btemp]);
2590 end 2587 end
2591 else 2588 else
2592 begin 2589 begin
2593 btemp := speekb(Addr); 2590 btemp := speekb(hl.w);
2594 af.l := rlr_f[1][btemp]; 2591 af.l := rlr_f[1][btemp];
2595 spokeb(Addr, rlr_a[1][btemp]); 2592 spokeb(hl.w, rlr_a[1][btemp]);
2596 end; 2593 end;
2597 2594
2598 Result := 16; 2595 Result := 16;
@@ -2716,15 +2713,15 @@ var
2716 begin 2713 begin
2717 if af.l and 1 = 0 then 2714 if af.l and 1 = 0 then
2718 begin 2715 begin
2719 btemp := speekb(Addr); 2716 btemp := speekb(hl.w);
2720 af.l := rrr_f[0][btemp]; 2717 af.l := rrr_f[0][btemp];
2721 spokeb(Addr, rrr_a[0][btemp]); 2718 spokeb(hl.w, rrr_a[0][btemp]);
2722 end 2719 end
2723 else 2720 else
2724 begin 2721 begin
2725 btemp := speekb(Addr); 2722 btemp := speekb(hl.w);
2726 af.l := rrr_f[1][btemp]; 2723 af.l := rrr_f[1][btemp];
2727 spokeb(Addr, rrr_a[1][btemp]); 2724 spokeb(hl.w, rrr_a[1][btemp]);
2728 end; 2725 end;
2729 2726
2730 Result := 16; 2727 Result := 16;
@@ -2798,9 +2795,9 @@ function sla: byte;
2798 var 2795 var
2799 btemp: byte; 2796 btemp: byte;
2800 begin 2797 begin
2801 btemp := speekb(Addr); 2798 btemp := speekb(hl.w);
2802 af.l := sla_f[btemp]; 2799 af.l := sla_f[btemp];
2803 spokeb(Addr, sla_a[btemp]); 2800 spokeb(hl.w, sla_a[btemp]);
2804 2801
2805 Result := 16; 2802 Result := 16;
2806 end; 2803 end;
@@ -2865,9 +2862,9 @@ function sra: byte;
2865 var 2862 var
2866 btemp: byte; 2863 btemp: byte;
2867 begin 2864 begin
2868 btemp := speekb(Addr); 2865 btemp := speekb(hl.w);
2869 af.l := sra_f[btemp]; 2866 af.l := sra_f[btemp];
2870 spokeb(Addr, sra_a[btemp]); 2867 spokeb(hl.w, sra_a[btemp]);
2871 2868
2872 Result := 16; 2869 Result := 16;
2873 end; 2870 end;
@@ -2926,9 +2923,9 @@ function sll: byte;
2926 var 2923 var
2927 btemp: byte; 2924 btemp: byte;
2928 begin 2925 begin
2929 btemp := speekb(Addr); 2926 btemp := speekb(hl.w);
2930 swap(btemp); 2927 swap(btemp);
2931 spokeb(Addr, btemp); 2928 spokeb(hl.w, btemp);
2932 2929
2933 Result := 16; 2930 Result := 16;
2934 end; 2931 end;
@@ -2992,9 +2989,9 @@ function srl: byte;
2992 var 2989 var
2993 btemp: byte; 2990 btemp: byte;
2994 begin 2991 begin
2995 btemp := speekb(Addr); 2992 btemp := speekb(hl.w);
2996 af.l := srl_f[btemp]; 2993 af.l := srl_f[btemp];
2997 spokeb(Addr, srl_a[btemp]); 2994 spokeb(hl.w, srl_a[btemp]);
2998 2995
2999 Result := 16; 2996 Result := 16;
3000 end; 2997 end;
@@ -3051,7 +3048,7 @@ end;
3051 3048
3052 function bit0: byte; 3049 function bit0: byte;
3053 begin 3050 begin
3054 af.l := bit_f0[speekb(Addr)] or (af.l and 1); 3051 af.l := bit_f0[speekb(hl.w)] or (af.l and 1);
3055 3052
3056 Result := 12; 3053 Result := 12;
3057 end; 3054 end;
@@ -3107,7 +3104,7 @@ end;
3107 3104
3108 function bit1: byte; 3105 function bit1: byte;
3109 begin 3106 begin
3110 af.l := bit_f1[speekb(Addr)] or (af.l and 1); 3107 af.l := bit_f1[speekb(hl.w)] or (af.l and 1);
3111 3108
3112 Result := 12; 3109 Result := 12;
3113 end; 3110 end;
@@ -3163,7 +3160,7 @@ end;
3163 3160
3164 function bit2: byte; 3161 function bit2: byte;
3165 begin 3162 begin
3166 af.l := bit_f2[speekb(Addr)] or (af.l and 1); 3163 af.l := bit_f2[speekb(hl.w)] or (af.l and 1);
3167 3164
3168 Result := 12; 3165 Result := 12;
3169 end; 3166 end;
@@ -3219,7 +3216,7 @@ end;
3219 3216
3220 function bit3: byte; 3217 function bit3: byte;
3221 begin 3218 begin
3222 af.l := bit_f3[speekb(Addr)] or (af.l and 1); 3219 af.l := bit_f3[speekb(hl.w)] or (af.l and 1);
3223 3220
3224 Result := 12; 3221 Result := 12;
3225 end; 3222 end;
@@ -3275,7 +3272,7 @@ end;
3275 3272
3276 function bit4: byte; 3273 function bit4: byte;
3277 begin 3274 begin
3278 af.l := bit_f4[speekb(Addr)] or (af.l and 1); 3275 af.l := bit_f4[speekb(hl.w)] or (af.l and 1);
3279 3276
3280 Result := 12; 3277 Result := 12;
3281 end; 3278 end;
@@ -3331,7 +3328,7 @@ end;
3331 3328
3332 function bit5: byte; 3329 function bit5: byte;
3333 begin 3330 begin
3334 af.l := bit_f5[speekb(Addr)] or (af.l and 1); 3331 af.l := bit_f5[speekb(hl.w)] or (af.l and 1);
3335 3332
3336 Result := 12; 3333 Result := 12;
3337 end; 3334 end;
@@ -3387,7 +3384,7 @@ end;
3387 3384
3388 function bit6: byte; 3385 function bit6: byte;
3389 begin 3386 begin
3390 af.l := bit_f6[speekb(Addr)] or (af.l and 1); 3387 af.l := bit_f6[speekb(hl.w)] or (af.l and 1);
3391 3388
3392 Result := 12; 3389 Result := 12;
3393 end; 3390 end;
@@ -3443,7 +3440,7 @@ end;
3443 3440
3444 function bit7: byte; 3441 function bit7: byte;
3445 begin 3442 begin
3446 af.l := bit_f7[speekb(Addr)] or (af.l and 1); 3443 af.l := bit_f7[speekb(hl.w)] or (af.l and 1);
3447 3444
3448 Result := 12; 3445 Result := 12;
3449 end; 3446 end;
@@ -3947,7 +3944,7 @@ end;
3947 3944
3948 function set0: byte; 3945 function set0: byte;
3949 begin 3946 begin
3950 spokeb(Addr, speekb(Addr) or 1); 3947 spokeb(hl.w, speekb(hl.w) or 1);
3951 3948
3952 Result := 16; 3949 Result := 16;
3953 end; 3950 end;
@@ -4003,7 +4000,7 @@ end;
4003 4000
4004 function set1: byte; 4001 function set1: byte;
4005 begin 4002 begin
4006 spokeb(Addr, speekb(Addr) or 2); 4003 spokeb(hl.w, speekb(hl.w) or 2);
4007 4004
4008 Result := 16; 4005 Result := 16;
4009 end; 4006 end;
@@ -4059,7 +4056,7 @@ end;
4059 4056
4060 function set2: byte; 4057 function set2: byte;
4061 begin 4058 begin
4062 spokeb(Addr, speekb(Addr) or 4); 4059 spokeb(hl.w, speekb(hl.w) or 4);
4063 4060
4064 Result := 16; 4061 Result := 16;
4065 end; 4062 end;
@@ -4115,7 +4112,7 @@ end;
4115 4112
4116 function set3: byte; 4113 function set3: byte;
4117 begin 4114 begin
4118 spokeb(Addr, speekb(Addr) or 8); 4115 spokeb(hl.w, speekb(hl.w) or 8);
4119 4116
4120 Result := 16; 4117 Result := 16;
4121 end; 4118 end;
@@ -4171,7 +4168,7 @@ end;
4171 4168
4172 function set4: byte; 4169 function set4: byte;
4173 begin 4170 begin
4174 spokeb(Addr, speekb(Addr) or 16); 4171 spokeb(hl.w, speekb(hl.w) or 16);
4175 4172
4176 Result := 16; 4173 Result := 16;
4177 end; 4174 end;
@@ -4227,7 +4224,7 @@ end;
4227 4224
4228 function set5: byte; 4225 function set5: byte;
4229 begin 4226 begin
4230 spokeb(Addr, speekb(Addr) or 32); 4227 spokeb(hl.w, speekb(hl.w) or 32);
4231 4228
4232 Result := 16; 4229 Result := 16;
4233 end; 4230 end;
@@ -4283,7 +4280,7 @@ end;
4283 4280
4284 function set6: byte; 4281 function set6: byte;
4285 begin 4282 begin
4286 spokeb(Addr, speekb(Addr) or 64); 4283 spokeb(hl.w, speekb(hl.w) or 64);
4287 4284
4288 Result := 16; 4285 Result := 16;
4289 end; 4286 end;
@@ -4339,7 +4336,7 @@ end;
4339 4336
4340 function set7: byte; 4337 function set7: byte;
4341 begin 4338 begin
4342 spokeb(Addr, speekb(Addr) or 128); 4339 spokeb(hl.w, speekb(hl.w) or 128);
4343 4340
4344 Result := 16; 4341 Result := 16;
4345 end; 4342 end;