mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-02 19:29:21 +00:00
Do quad add/subtract without loading operands on stack.
As with the previous support for bitwise ops, this applies if the operands are simple quad loads.
This commit is contained in:
parent
043124db93
commit
0b56689626
125
Gen.pas
125
Gen.pas
@ -47,6 +47,7 @@ const
|
|||||||
globalLabel = 16;
|
globalLabel = 16;
|
||||||
constant = 32;
|
constant = 32;
|
||||||
nowhere = 64;
|
nowhere = 64;
|
||||||
|
inStackLoc = 128;
|
||||||
|
|
||||||
{stack frame locations}
|
{stack frame locations}
|
||||||
{---------------------}
|
{---------------------}
|
||||||
@ -403,6 +404,9 @@ case gQuad.preference of
|
|||||||
end; {else}
|
end; {else}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
inStackLoc:
|
||||||
|
GenNative(m_sta_s, direct, gQuad.disp+offset, nil, 0);
|
||||||
|
|
||||||
onStack:
|
onStack:
|
||||||
GenImplied(m_pha);
|
GenImplied(m_pha);
|
||||||
|
|
||||||
@ -876,41 +880,98 @@ procedure GenAdqSbq (op: icptr);
|
|||||||
{ op - pc_adq or pc_sbq operation }
|
{ op - pc_adq or pc_sbq operation }
|
||||||
|
|
||||||
begin {GenAdqSbq}
|
begin {GenAdqSbq}
|
||||||
gQuad.preference := onStack;
|
|
||||||
GenTree(op^.right);
|
|
||||||
gQuad.preference := onStack;
|
|
||||||
GenTree(op^.left);
|
|
||||||
if op^.opcode = pc_adq then begin
|
if op^.opcode = pc_adq then begin
|
||||||
GenImplied(m_clc);
|
if SimpleQuadLoad(op^.left) and SimpleQuadLoad(op^.right) then begin
|
||||||
GenImplied(m_pla);
|
gQuad.where := gQuad.preference;
|
||||||
GenNative(m_adc_s, direct, 7, nil, 0);
|
if gQuad.preference = onStack then begin
|
||||||
GenNative(m_sta_s, direct, 7, nil, 0);
|
GenImplied(m_tsc);
|
||||||
GenImplied(m_pla);
|
GenImplied(m_sec);
|
||||||
GenNative(m_adc_s, direct, 7, nil, 0);
|
GenNative(m_sbc_imm, immediate, 8, nil, 0);
|
||||||
GenNative(m_sta_s, direct, 7, nil, 0);
|
GenImplied(m_tcs);
|
||||||
GenImplied(m_pla);
|
gQuad.preference := inStackLoc;
|
||||||
GenNative(m_adc_s, direct, 7, nil, 0);
|
gQuad.disp := 1;
|
||||||
GenNative(m_sta_s, direct, 7, nil, 0);
|
end; {if}
|
||||||
GenImplied(m_pla);
|
GenImplied(m_clc);
|
||||||
GenNative(m_adc_s, direct, 7, nil, 0);
|
OpOnWordOfQuad(m_lda_imm, op^.left, 0);
|
||||||
GenNative(m_sta_s, direct, 7, nil, 0);
|
OpOnWordOfQuad(m_adc_imm, op^.right, 0);
|
||||||
end {else}
|
StoreWordOfQuad(0);
|
||||||
|
OpOnWordOfQuad(m_lda_imm, op^.left, 2);
|
||||||
|
OpOnWordOfQuad(m_adc_imm, op^.right, 2);
|
||||||
|
StoreWordOfQuad(2);
|
||||||
|
OpOnWordOfQuad(m_lda_imm, op^.left, 4);
|
||||||
|
OpOnWordOfQuad(m_adc_imm, op^.right, 4);
|
||||||
|
StoreWordOfQuad(4);
|
||||||
|
OpOnWordOfQuad(m_lda_imm, op^.left, 6);
|
||||||
|
OpOnWordOfQuad(m_adc_imm, op^.right, 6);
|
||||||
|
StoreWordOfQuad(6);
|
||||||
|
end {if}
|
||||||
|
else begin
|
||||||
|
gQuad.preference := onStack;
|
||||||
|
GenTree(op^.right);
|
||||||
|
gQuad.preference := onStack;
|
||||||
|
GenTree(op^.left);
|
||||||
|
GenImplied(m_clc);
|
||||||
|
GenImplied(m_pla);
|
||||||
|
GenNative(m_adc_s, direct, 7, nil, 0);
|
||||||
|
GenNative(m_sta_s, direct, 7, nil, 0);
|
||||||
|
GenImplied(m_pla);
|
||||||
|
GenNative(m_adc_s, direct, 7, nil, 0);
|
||||||
|
GenNative(m_sta_s, direct, 7, nil, 0);
|
||||||
|
GenImplied(m_pla);
|
||||||
|
GenNative(m_adc_s, direct, 7, nil, 0);
|
||||||
|
GenNative(m_sta_s, direct, 7, nil, 0);
|
||||||
|
GenImplied(m_pla);
|
||||||
|
GenNative(m_adc_s, direct, 7, nil, 0);
|
||||||
|
GenNative(m_sta_s, direct, 7, nil, 0);
|
||||||
|
gQuad.where := onStack;
|
||||||
|
end; {else}
|
||||||
|
end {if}
|
||||||
else {if op^.opcode = pc_sbq then} begin
|
else {if op^.opcode = pc_sbq then} begin
|
||||||
GenImplied(m_sec);
|
if SimpleQuadLoad(op^.left) and SimpleQuadLoad(op^.right) then begin
|
||||||
GenImplied(m_pla);
|
gQuad.where := gQuad.preference;
|
||||||
GenNative(m_sbc_s, direct, 7, nil, 0);
|
if gQuad.preference = onStack then begin
|
||||||
GenNative(m_sta_s, direct, 7, nil, 0);
|
GenImplied(m_tsc);
|
||||||
GenImplied(m_pla);
|
GenImplied(m_sec);
|
||||||
GenNative(m_sbc_s, direct, 7, nil, 0);
|
GenNative(m_sbc_imm, immediate, 8, nil, 0);
|
||||||
GenNative(m_sta_s, direct, 7, nil, 0);
|
GenImplied(m_tcs);
|
||||||
GenImplied(m_pla);
|
gQuad.preference := inStackLoc;
|
||||||
GenNative(m_sbc_s, direct, 7, nil, 0);
|
gQuad.disp := 1;
|
||||||
GenNative(m_sta_s, direct, 7, nil, 0);
|
end; {if}
|
||||||
GenImplied(m_pla);
|
GenImplied(m_sec);
|
||||||
GenNative(m_sbc_s, direct, 7, nil, 0);
|
OpOnWordOfQuad(m_lda_imm, op^.left, 0);
|
||||||
GenNative(m_sta_s, direct, 7, nil, 0);
|
OpOnWordOfQuad(m_sbc_imm, op^.right, 0);
|
||||||
|
StoreWordOfQuad(0);
|
||||||
|
OpOnWordOfQuad(m_lda_imm, op^.left, 2);
|
||||||
|
OpOnWordOfQuad(m_sbc_imm, op^.right, 2);
|
||||||
|
StoreWordOfQuad(2);
|
||||||
|
OpOnWordOfQuad(m_lda_imm, op^.left, 4);
|
||||||
|
OpOnWordOfQuad(m_sbc_imm, op^.right, 4);
|
||||||
|
StoreWordOfQuad(4);
|
||||||
|
OpOnWordOfQuad(m_lda_imm, op^.left, 6);
|
||||||
|
OpOnWordOfQuad(m_sbc_imm, op^.right, 6);
|
||||||
|
StoreWordOfQuad(6);
|
||||||
|
end {if}
|
||||||
|
else begin
|
||||||
|
gQuad.preference := onStack;
|
||||||
|
GenTree(op^.right);
|
||||||
|
gQuad.preference := onStack;
|
||||||
|
GenTree(op^.left);
|
||||||
|
GenImplied(m_sec);
|
||||||
|
GenImplied(m_pla);
|
||||||
|
GenNative(m_sbc_s, direct, 7, nil, 0);
|
||||||
|
GenNative(m_sta_s, direct, 7, nil, 0);
|
||||||
|
GenImplied(m_pla);
|
||||||
|
GenNative(m_sbc_s, direct, 7, nil, 0);
|
||||||
|
GenNative(m_sta_s, direct, 7, nil, 0);
|
||||||
|
GenImplied(m_pla);
|
||||||
|
GenNative(m_sbc_s, direct, 7, nil, 0);
|
||||||
|
GenNative(m_sta_s, direct, 7, nil, 0);
|
||||||
|
GenImplied(m_pla);
|
||||||
|
GenNative(m_sbc_s, direct, 7, nil, 0);
|
||||||
|
GenNative(m_sta_s, direct, 7, nil, 0);
|
||||||
|
gQuad.where := onStack;
|
||||||
|
end; {else}
|
||||||
end; {else}
|
end; {else}
|
||||||
gQuad.where := onStack;
|
|
||||||
end; {GenAdqSbq}
|
end; {GenAdqSbq}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user