* fixed tcgz80.a_call_reg

git-svn-id: branches/z80@45062 -
This commit is contained in:
nickysn 2020-04-25 11:06:58 +00:00
parent 4b88e8f48e
commit b15c66b396

View File

@ -673,12 +673,28 @@ unit cgcpu;
l : TAsmLabel;
ref : treference;
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,reg));
list.concat(tai_const.Create_8bit($CD));
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);
end;