Browse Source

+ added an output parameter to tcgz80.normalize_ref, that returns a list of the registers that were
actually used, so they can be freed after the reference is used.

git-svn-id: branches/z80@44892 -

nickysn 5 years ago
parent
commit
5c138c341f
1 changed files with 10 additions and 4 deletions
  1. 10 4
      compiler/z80/cgcpu.pas

+ 10 - 4
compiler/z80/cgcpu.pas

@@ -102,7 +102,7 @@ unit cgcpu;
 
 
         procedure a_jmp_cond(list : TAsmList;cond : TOpCmp;l: tasmlabel);
         procedure a_jmp_cond(list : TAsmList;cond : TOpCmp;l: tasmlabel);
         procedure fixref(list : TAsmList;var ref : treference);
         procedure fixref(list : TAsmList;var ref : treference);
-        function normalize_ref(list : TAsmList;ref : treference; const refopertypes:trefoperandtypes) : treference;
+        function normalize_ref(list : TAsmList;ref : treference; const refopertypes:trefoperandtypes; out allocatedregs:tregisterlist) : treference;
 
 
         procedure emit_mov(list: TAsmList;reg2: tregister; reg1: tregister);
         procedure emit_mov(list: TAsmList;reg2: tregister; reg1: tregister);
 
 
@@ -1209,11 +1209,15 @@ unit cgcpu;
       end;
       end;
 
 
 
 
-    function tcgz80.normalize_ref(list: TAsmList; ref: treference; const refopertypes: trefoperandtypes): treference;
+        function tcgz80.normalize_ref(list: TAsmList; ref: treference;
+      const refopertypes: trefoperandtypes; out allocatedregs: tregisterlist
+      ): treference;
       var
       var
         tmpref : treference;
         tmpref : treference;
         l : tasmlabel;
         l : tasmlabel;
       begin
       begin
+        SetLength(allocatedregs,0);
+
         if (ref.base=NR_NO) and (ref.index<>NR_NO) and (ref.scalefactor<=1) then
         if (ref.base=NR_NO) and (ref.index<>NR_NO) and (ref.scalefactor<=1) then
           begin
           begin
             ref.base:=ref.index;
             ref.base:=ref.index;
@@ -1229,8 +1233,10 @@ unit cgcpu;
         { can we use the HL register? }
         { can we use the HL register? }
         if OT_REF_HL in refopertypes then
         if OT_REF_HL in refopertypes then
           begin
           begin
-            getcpuregister(list,NR_H);
-            getcpuregister(list,NR_L);
+            SetLength(allocatedregs,2);
+            allocatedregs[0]:=NR_H;
+            allocatedregs[1]:=NR_L;
+            getcpuregisters(list,allocatedregs);
             if assigned(ref.symbol) then
             if assigned(ref.symbol) then
               begin
               begin
                 reference_reset(tmpref,0,[]);
                 reference_reset(tmpref,0,[]);