mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-06-25 16:29:56 +00:00
Generate better code for pc_ixa in large memory model.
This improves the code for certain array indexing operations.
This commit is contained in:
parent
2412ae0661
commit
7e860e60df
1
CGI.pas
1
CGI.pas
|
@ -86,6 +86,7 @@ const
|
||||||
m_cpx_abs = 236;
|
m_cpx_abs = 236;
|
||||||
m_cpx_dir = 228;
|
m_cpx_dir = 228;
|
||||||
m_cpx_imm = 224;
|
m_cpx_imm = 224;
|
||||||
|
m_cpy_imm = $C0;
|
||||||
m_dea = 58;
|
m_dea = 58;
|
||||||
m_dec_abs = 206;
|
m_dec_abs = 206;
|
||||||
m_dec_absX = $DE;
|
m_dec_absX = $DE;
|
||||||
|
|
69
Gen.pas
69
Gen.pas
|
@ -3340,8 +3340,9 @@ procedure GenIxa (op: icptr);
|
||||||
{ Generate code for a pc_ixa }
|
{ Generate code for a pc_ixa }
|
||||||
|
|
||||||
var
|
var
|
||||||
lab1: integer; {branch label}
|
lab1,lab2: integer; {branch labels}
|
||||||
lLong: longType; {type of address}
|
lLong: longType; {type of address}
|
||||||
|
signed: boolean; {doing signed addition?}
|
||||||
zero: boolean; {is the index 0?}
|
zero: boolean; {is the index 0?}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3394,8 +3395,8 @@ var
|
||||||
|
|
||||||
|
|
||||||
begin {GenIxa}
|
begin {GenIxa}
|
||||||
if smallMemoryModel or (op^.left^.opcode = pc_lda) then begin
|
|
||||||
lLong := gLong;
|
lLong := gLong;
|
||||||
|
if smallMemoryModel or (op^.left^.opcode = pc_lda) then begin
|
||||||
gLong.preference := inPointer+localAddress+globalLabel;
|
gLong.preference := inPointer+localAddress+globalLabel;
|
||||||
GenTree(op^.left);
|
GenTree(op^.left);
|
||||||
case gLong.where of
|
case gLong.where of
|
||||||
|
@ -3600,33 +3601,63 @@ if smallMemoryModel or (op^.left^.opcode = pc_lda) then begin
|
||||||
Error(cge1);
|
Error(cge1);
|
||||||
end; {case}
|
end; {case}
|
||||||
end {if smallMemoryModel or (op^.left^.opcode = pc_lda)}
|
end {if smallMemoryModel or (op^.left^.opcode = pc_lda)}
|
||||||
|
else begin
|
||||||
|
signed := IndexCanBeNegative;
|
||||||
|
if (not signed)
|
||||||
|
and ((globalLabel & lLong.preference) <> 0)
|
||||||
|
and (op^.left^.opcode = pc_lao)
|
||||||
|
then begin
|
||||||
|
if Complex(op^.right) then begin
|
||||||
|
GenTree(op^.right);
|
||||||
|
GenImplied(m_tax);
|
||||||
|
end {if}
|
||||||
|
else
|
||||||
|
LoadX(op^.right);
|
||||||
|
gLong.where := globalLabel;
|
||||||
|
gLong.fixedDisp := false;
|
||||||
|
gLong.disp := op^.left^.q;
|
||||||
|
gLong.lab := op^.left^.lab;
|
||||||
|
end {if}
|
||||||
|
else begin
|
||||||
|
if op^.left^.opcode = pc_lao then begin
|
||||||
|
GenTree(op^.right);
|
||||||
|
if signed then
|
||||||
|
GenImplied(m_tay);
|
||||||
|
GenImplied(m_clc);
|
||||||
|
GenNative(m_adc_imm, immediate, op^.left^.q, op^.left^.lab, 0);
|
||||||
|
GenNative(m_ldx_imm, immediate, op^.left^.q, op^.left^.lab, shift16);
|
||||||
|
end {if}
|
||||||
else begin
|
else begin
|
||||||
gLong.preference := onStack;
|
gLong.preference := onStack;
|
||||||
GenTree(op^.left);
|
GenTree(op^.left);
|
||||||
GenTree(op^.right);
|
GenTree(op^.right);
|
||||||
if IndexCanBeNegative then begin
|
if signed then
|
||||||
lab1 := GenLabel;
|
|
||||||
GenNative(m_ldx_imm, immediate, $0000, nil, 0);
|
|
||||||
GenImplied(m_tay);
|
GenImplied(m_tay);
|
||||||
GenNative(m_bpl, relative, lab1, nil, 0);
|
GenImplied(m_clc);
|
||||||
GenImplied(m_dex);
|
GenNative(m_adc_s, direct, 1, nil, 0);
|
||||||
|
GenImplied(m_plx);
|
||||||
|
GenImplied(m_plx);
|
||||||
|
end; {else}
|
||||||
|
lab1 := GenLabel;
|
||||||
|
GenNative(m_bcc, relative, lab1, nil, 0);
|
||||||
|
GenImplied(m_inx);
|
||||||
GenLab(lab1);
|
GenLab(lab1);
|
||||||
|
if signed then begin
|
||||||
|
GenNative(m_cpy_imm, immediate, $0000, nil, 0);
|
||||||
|
lab2 := GenLabel;
|
||||||
|
GenNative(m_bpl, relative, lab2, nil, 0);
|
||||||
|
GenImplied(m_dex);
|
||||||
|
GenLab(lab2);
|
||||||
|
end; {if}
|
||||||
|
if (A_X & lLong.preference) <> 0 then
|
||||||
|
gLong.where := A_X
|
||||||
|
else begin
|
||||||
GenImplied(m_phx);
|
GenImplied(m_phx);
|
||||||
GenImplied(m_pha);
|
GenImplied(m_pha);
|
||||||
end {else if}
|
|
||||||
else begin
|
|
||||||
GenNative(m_pea, immediate, 0, nil, 0);
|
|
||||||
GenImplied(m_pha);
|
|
||||||
end; {else}
|
|
||||||
GenImplied(m_clc);
|
|
||||||
GenImplied(m_pla);
|
|
||||||
GenNative(m_adc_s, direct, 3, nil, 0);
|
|
||||||
GenNative(m_sta_s, direct, 3, nil, 0);
|
|
||||||
GenImplied(m_pla);
|
|
||||||
GenNative(m_adc_s, direct, 3, nil, 0);
|
|
||||||
GenNative(m_sta_s, direct, 3, nil, 0);
|
|
||||||
gLong.where := onStack;
|
gLong.where := onStack;
|
||||||
end; {else}
|
end; {else}
|
||||||
|
end; {else}
|
||||||
|
end; {else}
|
||||||
end; {GenIxa}
|
end; {GenIxa}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -854,7 +854,7 @@ case p_opcode of
|
||||||
|
|
||||||
m_bra,m_brl,m_clc,m_cmp_abs,m_cmp_dir,m_cmp_imm,m_cmp_s,m_cmp_indl,
|
m_bra,m_brl,m_clc,m_cmp_abs,m_cmp_dir,m_cmp_imm,m_cmp_s,m_cmp_indl,
|
||||||
m_cmp_indly,m_cpx_imm,m_jml,m_jmp_indX,m_plb,m_rtl,m_rts,m_sec,d_add,d_pin,
|
m_cmp_indly,m_cpx_imm,m_jml,m_jmp_indX,m_plb,m_rtl,m_rts,m_sec,d_add,d_pin,
|
||||||
m_cpx_abs,m_cpx_dir,m_cmp_dirx,m_plp,m_cop,d_wrd: ;
|
m_cpx_abs,m_cpx_dir,m_cpy_imm,m_cmp_dirx,m_plp,m_cop,d_wrd: ;
|
||||||
|
|
||||||
m_pea: begin
|
m_pea: begin
|
||||||
if aRegister.condition = regImmediate then
|
if aRegister.condition = regImmediate then
|
||||||
|
|
Loading…
Reference in New Issue
Block a user