Pārlūkot izejas kodu

+ implemented tcgmos6502.a_call_reg

Nikolay Nikolov 1 gadu atpakaļ
vecāks
revīzija
98a4343f73
1 mainītis faili ar 20 papildinājumiem un 26 dzēšanām
  1. 20 26
      compiler/mos6502/cgcpu.pas

+ 20 - 26
compiler/mos6502/cgcpu.pas

@@ -656,33 +656,27 @@ unit cgcpu;
 
 
 
 
     procedure tcgmos6502.a_call_reg(list : TAsmList;reg: tregister);
     procedure tcgmos6502.a_call_reg(list : TAsmList;reg: tregister);
-      //var
-      //  l : TAsmLabel;
-      //  ref : treference;
+      var
+        l : TAsmLabel;
+        ref : treference;
       begin
       begin
-        //{ HACK: at this point all registers are allocated, due to the way the
-        //  calling convention works, but we need to free some registers, in order
-        //  for the following code to work, so we do it here }
-        //dealloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
-        //
-        //getcpuregister(list,NR_L);
-        //a_load_reg_reg(list,OS_8,OS_8,reg,NR_L);
-        //getcpuregister(list,NR_H);
-        //a_load_reg_reg(list,OS_8,OS_8,GetNextReg(reg),NR_H);
-        //current_asmdata.getjumplabel(l);
-        //reference_reset(ref,0,[]);
-        //ref.symbol:=l;
-        //list.concat(taicpu.op_ref_reg(A_LD,ref,NR_HL));
-        //ungetcpuregister(list,NR_H);
-        //ungetcpuregister(list,NR_L);
-        //
-        //{ allocate them again, right before the actual call instruction }
-        //alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
-        //
-        //list.concat(tai_const.Create_8bit($CD));  { $CD is the opcode of the call instruction }
-        //list.concat(tai_label.Create(l));
-        //list.concat(tai_const.Create_16bit(0));
-        //include(current_procinfo.flags,pi_do_call);
+        { HACK: at this point all registers are allocated, due to the way the
+          calling convention works, but we need to free some registers, in order
+          for the following code to work, so we do it here }
+        dealloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
+
+        current_asmdata.getjumplabel(l);
+        reference_reset(ref,0,[]);
+        ref.symbol:=l;
+        a_load_reg_ref(list,OS_16,OS_16,reg,ref);
+
+        { allocate them again, right before the actual call instruction }
+        alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
+
+        list.concat(tai_const.Create_8bit($20));  { $20 is the opcode of the jsr instruction }
+        list.concat(tai_label.Create(l));
+        list.concat(tai_const.Create_16bit(0));
+        include(current_procinfo.flags,pi_do_call);
       end;
       end;