Browse Source

+ support unsigned expansion in tcgz80.a_load_reg_ref

git-svn-id: branches/z80@44645 -
nickysn 5 years ago
parent
commit
7d9658e2ba
1 changed files with 22 additions and 10 deletions
  1. 22 10
      compiler/z80/cgcpu.pas

+ 22 - 10
compiler/z80/cgcpu.pas

@@ -1190,20 +1190,32 @@ unit cgcpu;
 
          if (tcgsize2size[fromsize]>32) or (tcgsize2size[tosize]>32) or (fromsize=OS_NO) or (tosize=OS_NO) then
            internalerror(2011021307);
+         if tcgsize2size[fromsize]>tcgsize2size[tosize] then
+           internalerror(2020040802);
 
-         if fromsize=tosize then
+         if (fromsize=tosize) or (fromsize in [OS_8,OS_16,OS_32]) then
            begin
              getcpuregister(list,NR_A);
-             for i:=tcgsize2size[fromsize] downto 1 do
-             begin
-               a_load_reg_reg(list,OS_8,OS_8,reg,NR_A);
-               list.concat(taicpu.op_ref_reg(A_LD,href,NR_A));
-               if i<>1 then
-                 begin
-                   inc(href.offset);
+             for i:=1 to tcgsize2size[fromsize] do
+               begin
+                 a_load_reg_reg(list,OS_8,OS_8,reg,NR_A);
+                 list.concat(taicpu.op_ref_reg(A_LD,href,NR_A));
+                 if i<>tcgsize2size[fromsize] then
                    reg:=GetNextReg(reg);
-                 end;
-             end;
+                 if i<>tcgsize2size[tosize] then
+                   inc(href.offset);
+               end;
+             for i:=tcgsize2size[fromsize]+1 to tcgsize2size[tosize] do
+               begin
+                 if i=(tcgsize2size[fromsize]+1) then
+                   list.concat(taicpu.op_reg_const(A_LD,NR_A,0));
+                 list.concat(taicpu.op_ref_reg(A_LD,href,NR_A));
+                 if i<>tcgsize2size[tosize] then
+                   begin
+                     inc(href.offset);
+                     reg:=GetNextReg(reg);
+                   end;
+               end;
              ungetcpuregister(list,NR_A);
            end
          else