Commit 857c778

Nick committed on
Implement swap instructions
commit 857c77827c5587aa5e69892e6dd06566ee9066f4 parent 20f299b
2 changed files +22−16
ModifiedCpu/PROCS.INC +13−0
@@ -161,6 +161,19 @@ begin
161 af.l:=af.l and 251 ;(* reset Pf *) 161 af.l:=af.l and 251 ;(* reset Pf *)
162 end; 162 end;
163 163
164 procedure swap(var bval: Byte);
165 var
166 h: Byte;
167 begin
168 h := hi(bval);
169 bval := (bval shl 4) or h;
170
171 if bval = 0 then
172 af.l := 64
173 else
174 af.l := 0;
175 end;
176
164 procedure anda(bval:Byte); 177 procedure anda(bval:Byte);
165 begin 178 begin
166 af.h:=af.h and bval; 179 af.h:=af.h and bval;
ModifiedCpu/z80cpu.pas +9−16
@@ -2630,48 +2630,42 @@ end;
2630 2630
2631 function sll_b: byte; 2631 function sll_b: byte;
2632 begin 2632 begin
2633 af.l := sll_f[bc.h]; 2633 swap(bc.h);
2634 bc.h := sll_a[bc.h];
2635 2634
2636 Result := 8; 2635 Result := 8;
2637 end; 2636 end;
2638 2637
2639 function sll_c: byte; 2638 function sll_c: byte;
2640 begin 2639 begin
2641 af.l := sll_f[bc.l]; 2640 swap(bc.l);
2642 bc.l := sll_a[bc.l];
2643 2641
2644 Result := 8; 2642 Result := 8;
2645 end; 2643 end;
2646 2644
2647 function sll_d: byte; 2645 function sll_d: byte;
2648 begin 2646 begin
2649 af.l := sll_f[de.h]; 2647 swap(de.h);
2650 de.h := sll_a[de.h];
2651 2648
2652 Result := 8; 2649 Result := 8;
2653 end; 2650 end;
2654 2651
2655 function sll_e: byte; 2652 function sll_e: byte;
2656 begin 2653 begin
2657 af.l := sll_f[de.l]; 2654 swap(de.l);
2658 de.l := sll_a[de.l];
2659 2655
2660 Result := 8; 2656 Result := 8;
2661 end; 2657 end;
2662 2658
2663 function sll_h: byte; 2659 function sll_h: byte;
2664 begin 2660 begin
2665 af.l := sll_f[hl.h]; 2661 swap(hl.h);
2666 hl.h := sll_a[hl.h];
2667 2662
2668 Result := 8; 2663 Result := 8;
2669 end; 2664 end;
2670 2665
2671 function sll_l: byte; 2666 function sll_l: byte;
2672 begin 2667 begin
2673 af.l := sll_f[hl.l]; 2668 swap(hl.l);
2674 hl.l := sll_a[hl.l];
2675 2669
2676 Result := 8; 2670 Result := 8;
2677 end; 2671 end;
@@ -2681,16 +2675,15 @@ var
2681 btemp: byte; 2675 btemp: byte;
2682 begin 2676 begin
2683 btemp := speekb(Addr); 2677 btemp := speekb(Addr);
2684 af.l := sll_f[btemp]; 2678 swap(btemp);
2685 spokeb(Addr, sll_a[btemp]); 2679 spokeb(Addr, btemp);
2686 2680
2687 Result := 16; 2681 Result := 16;
2688 end; 2682 end;
2689 2683
2690 function CBsll_a: byte; 2684 function CBsll_a: byte;
2691 begin 2685 begin
2692 af.l := sll_f[af.h]; 2686 swap(af.h);
2693 af.h := sll_a[af.h];
2694 2687
2695 Result := 8; 2688 Result := 8;
2696 end; 2689 end;