Selaa lähdekoodia

+ implemented OP_AND in tcgmos6502.a_op_const_reg_internal

Nikolay Nikolov 1 vuosi sitten
vanhempi
commit
b07d63852d
1 muutettua tiedostoa jossa 38 lisäystä ja 33 poistoa
  1. 38 33
      compiler/mos6502/cgcpu.pas

+ 38 - 33
compiler/mos6502/cgcpu.pas

@@ -994,9 +994,9 @@ unit cgcpu;
          end;
          end;
 
 
        var
        var
-       //  mask : qword;
-       //  shift : byte;
-       //  curvalue : byte;
+         mask : qword;
+         shift : byte;
+         curvalue : byte;
        //  tmpop: TAsmOp;
        //  tmpop: TAsmOp;
        //  l1: TAsmLabel;
        //  l1: TAsmLabel;
        //  instr: taicpu;
        //  instr: taicpu;
@@ -1005,8 +1005,8 @@ unit cgcpu;
 
 
        begin
        begin
          optimize_op_const(size,op,a);
          optimize_op_const(size,op,a);
-       //  mask:=$ff;
-       //  shift:=0;
+         mask:=$ff;
+         shift:=0;
        //  l1:=nil;
        //  l1:=nil;
          case op of
          case op of
            OP_NONE:
            OP_NONE:
@@ -1018,34 +1018,39 @@ unit cgcpu;
                { Optimized, replaced with a simple load }
                { Optimized, replaced with a simple load }
                a_load_const_reg(list,size,a,reg);
                a_load_const_reg(list,size,a,reg);
              end;
              end;
-       //    OP_AND:
-       //      begin
-       //        curvalue:=a and mask;
-       //        for i:=1 to tcgsize2size[size] do
-       //          begin
-       //            case curvalue of
-       //              0:
-       //                list.concat(taicpu.op_reg_const(A_LD,reg,0));
-       //              $ff:
-       //                {nothing};
-       //              else
-       //                begin
-       //                  getcpuregister(list,NR_A);
-       //                  emit_mov(list,NR_A,reg);
-       //                  list.concat(taicpu.op_reg_const(A_AND,NR_A,curvalue));
-       //                  emit_mov(list,reg,NR_A);
-       //                  ungetcpuregister(list,NR_A);
-       //                end;
-       //            end;
-       //            if i<>tcgsize2size[size] then
-       //              begin
-       //                NextReg;
-       //                mask:=mask shl 8;
-       //                inc(shift,8);
-       //                curvalue:=(qword(a) and mask) shr shift;
-       //              end;
-       //          end;
-       //      end;
+           OP_AND:
+             begin
+               curvalue:=a and mask;
+               for i:=1 to tcgsize2size[size] do
+                 begin
+                   case curvalue of
+                     0:
+                       begin
+                         getcpuregister(list,NR_A);
+                         list.concat(taicpu.op_const(A_LDA,0));
+                         a_load_reg_reg(list,OS_8,OS_8,NR_A,reg);
+                         ungetcpuregister(list,NR_A);
+                       end;
+                     $ff:
+                       {nothing};
+                     else
+                       begin
+                         getcpuregister(list,NR_A);
+                         a_load_reg_reg(list,OS_8,OS_8,reg,NR_A);
+                         list.concat(taicpu.op_const(A_AND,curvalue));
+                         a_load_reg_reg(list,OS_8,OS_8,NR_A,reg);
+                         ungetcpuregister(list,NR_A);
+                       end;
+                   end;
+                   if i<>tcgsize2size[size] then
+                     begin
+                       NextReg;
+                       mask:=mask shl 8;
+                       inc(shift,8);
+                       curvalue:=(qword(a) and mask) shr shift;
+                     end;
+                 end;
+             end;
        //    OP_OR:
        //    OP_OR:
        //      begin
        //      begin
        //        curvalue:=a and mask;
        //        curvalue:=a and mask;