From 6bd0bef8c5fe2536ab868aa642fdafcc8ee4dc3c Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Mon, 21 Dec 2015 11:37:30 -0600 Subject: [PATCH] Fix bug causing wrong code generation for single-byte indirect local stores beyond the first 256 bytes of the stack frame. This fixes the compca19.c test case. --- Gen.pas | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Gen.pas b/Gen.pas index 31c1c6e..4578189 100644 --- a/Gen.pas +++ b/Gen.pas @@ -3409,10 +3409,9 @@ case optype of GenImplied(m_pha); end; {if} GetPointer(op^.left); - if short then - if simple then - GenNative(m_sep, immediate, 32, nil, 0); if gLong.where = inPointer then begin + if short and simple then + GenNative(m_sep, immediate, 32, nil, 0); if zero then GenNative(m_lda_imm, immediate, 0, nil, 0) else @@ -3423,7 +3422,9 @@ case optype of GenNative(m_sta_indlY, direct, gLong.disp, nil, 0); end {if} else if gLong.where = localAddress then begin - if gLong.fixedDisp then + if gLong.fixedDisp then begin + if short and simple then + GenNative(m_sep, immediate, 32, nil, 0); if (gLong.disp & $FF00) = 0 then if zero then GenNative(m_stz_dir, direct, gLong.disp, nil, 0) @@ -3442,6 +3443,7 @@ case optype of GenNative(m_sta_dirX, direct, 0, nil, 0); end; {else} end {else} + end {if} else begin if (gLong.disp & $FF00) <> 0 then begin GenImplied(m_txa); @@ -3450,6 +3452,8 @@ case optype of GenImplied(m_tax); gLong.disp := 0; end; {if} + if short and simple then + GenNative(m_sep, immediate, 32, nil, 0); if zero then GenNative(m_stz_dirX, direct, gLong.disp, nil, 0) else begin @@ -3459,6 +3463,8 @@ case optype of end; {else} end {else if} else {if gLong.where = globalLabel then} begin + if short and simple then + GenNative(m_sep, immediate, 32, nil, 0); if zero then begin if not smallMemoryModel then GenNative(m_lda_imm, immediate, 0, nil, 0);