From 039979fdcc4e7beab2bee0606f8de2344a1e4180 Mon Sep 17 00:00:00 2001 From: nickysn Date: Sat, 9 Nov 2013 21:57:29 +0000 Subject: [PATCH] * handle 4-byte records in registers as well in location_force_mem on i8086 git-svn-id: trunk@26002 - --- compiler/i8086/hlcgcpu.pas | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/compiler/i8086/hlcgcpu.pas b/compiler/i8086/hlcgcpu.pas index ee2606adc2..70bbc0f64b 100644 --- a/compiler/i8086/hlcgcpu.pas +++ b/compiler/i8086/hlcgcpu.pas @@ -201,10 +201,12 @@ implementation var r,tmpref: treference; is_sixbyterecord: Boolean; + is_fourbyterecord: Boolean; is_methodptr: Boolean; is_nestedprocptr: Boolean; begin is_sixbyterecord:=(size.typ=recorddef) and (size.size=6); + is_fourbyterecord:=(size.typ=recorddef) and (size.size=4); is_methodptr:=(size.typ=procvardef) and (po_methodpointer in tprocvardef(size).procoptions) and not(po_addressonly in tprocvardef(size).procoptions); @@ -234,6 +236,25 @@ implementation else cg.a_load_reg_ref(list,OS_16,OS_16,l.registerhi,tmpref); + location_reset_ref(l,LOC_REFERENCE,l.size,0); + l.reference:=r; + end + { 4-byte records in registers need special handling as well. A record may + be located in registerhi:register if it was converted from a procvar or + in GetNextReg(register):register if it was converted from a longint. + We can tell between the two by checking whether registerhi has been set. } + else if is_fourbyterecord and (l.loc in [LOC_REGISTER,LOC_CREGISTER]) then + begin + tg.gethltemp(list,size,size.size,tt_normal,r); + tmpref:=r; + + cg.a_load_reg_ref(list,OS_16,OS_16,l.register,tmpref); + inc(tmpref.offset,2); + if l.registerhi<>tregister(0) then + cg.a_load_reg_ref(list,OS_16,OS_16,l.registerhi,tmpref) + else + cg.a_load_reg_ref(list,OS_16,OS_16,GetNextReg(l.register),tmpref); + location_reset_ref(l,LOC_REFERENCE,l.size,0); l.reference:=r; end