소스 검색

+ implemented OP_NEG in tcgmos6502.a_op_reg_reg_internal

Nikolay Nikolov 1 년 전
부모
커밋
6bd5b3a69b
2개의 변경된 파일16개의 추가작업 그리고 53개의 파일을 삭제
  1. 13 53
      compiler/mos6502/cgcpu.pas
  2. 3 0
      rtl/mos6502/set.inc

+ 13 - 53
compiler/mos6502/cgcpu.pas

@@ -769,59 +769,19 @@ unit cgcpu;
                ungetcpuregister(list,NR_A);
              end;
 
-         //  OP_NEG:
-         //    begin
-         //      getcpuregister(list,NR_A);
-         //      if tcgsize2size[size]>=2 then
-         //        begin
-         //          tmpreg:=GetNextReg(src);
-         //          tmpreg2:=GetNextReg(dst);
-         //          for i:=2 to tcgsize2size[size] do
-         //            begin
-         //              a_load_reg_reg(list,OS_8,OS_8,tmpreg,NR_A);
-         //              list.concat(taicpu.op_none(A_CPL));
-         //              a_load_reg_reg(list,OS_8,OS_8,NR_A,tmpreg2);
-         //              if i<>tcgsize2size[size] then
-         //                begin
-         //                  if i=4 then
-         //                    begin
-         //                      tmpreg:=srchi;
-         //                      tmpreg2:=dsthi;
-         //                    end
-         //                  else
-         //                    begin
-         //                      tmpreg:=GetNextReg(tmpreg);
-         //                      tmpreg2:=GetNextReg(tmpreg2);
-         //                    end;
-         //                end;
-         //            end;
-         //        end;
-         //      a_load_reg_reg(list,OS_8,OS_8,src,NR_A);
-         //      list.concat(taicpu.op_none(A_NEG));
-         //      a_load_reg_reg(list,OS_8,OS_8,NR_A,dst);
-         //      if tcgsize2size[size]>=2 then
-         //        begin
-         //          tmpreg2:=GetNextReg(dst);
-         //          for i:=2 to tcgsize2size[size] do
-         //            begin
-         //              a_load_reg_reg(list,OS_8,OS_8,tmpreg2,NR_A);
-         //              list.concat(taicpu.op_reg_const(A_SBC,NR_A,-1));
-         //              a_load_reg_reg(list,OS_8,OS_8,NR_A,tmpreg2);
-         //              if i<>tcgsize2size[size] then
-         //                begin
-         //                  if i=4 then
-         //                    begin
-         //                      tmpreg2:=dsthi;
-         //                    end
-         //                  else
-         //                    begin
-         //                      tmpreg2:=GetNextReg(tmpreg2);
-         //                    end;
-         //                end;
-         //            end;
-         //        end;
-         //      ungetcpuregister(list,NR_A);
-         //    end;
+           OP_NEG:
+             begin
+               getcpuregister(list,NR_A);
+               list.concat(taicpu.op_none(A_SEC));
+               for i:=1 to tcgsize2size[size] do
+                 begin
+                   if i<>1 then
+                     NextSrcDst;
+                   a_load_const_reg(list,OS_8,0,NR_A);
+                   list.concat(taicpu.op_reg(A_SBC,src));
+                   a_load_reg_reg(list,OS_8,OS_8,NR_A,dst);
+                 end;
+             end;
 
            OP_NOT:
              begin

+ 3 - 0
rtl/mos6502/set.inc

@@ -19,6 +19,7 @@ var
   globaldw: longword;
   globalqw: qword;
   ga, gb, gc: byte;
+  gwa, gwb, gwc: word;
 
 procedure Test6502;
 begin
@@ -32,4 +33,6 @@ begin
   ga := gb or gc;
   ga := gb xor gc;
   ga := not gb;
+  ga := -gb;
+  gwa := -gwb;
 end;