mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-16 20:32:57 +00:00
Generate better code for indexed jumps.
They now use a jmp (addr,X) instruction, rather than a more complicated code sequence using rts. This is an improvement that was suggested in an old Genie message from Todd Whitesel.
This commit is contained in:
parent
c36bf9bf0a
commit
60efb4d882
2
CGI.pas
2
CGI.pas
@ -45,6 +45,7 @@ const
|
||||
constantOpnd = 64; {the absolute operand is a constant}
|
||||
localLab = 128; {the operand is a local lab}
|
||||
forFlags = 256; {instruction used for effect on flags only}
|
||||
subtract1 = 512; {subtract 1 from address operand}
|
||||
|
||||
m_adc_abs = $6D; {op code #s for 65816 instructions}
|
||||
m_adc_dir = $65;
|
||||
@ -103,6 +104,7 @@ const
|
||||
m_inx = 232;
|
||||
m_iny = 200;
|
||||
m_jml = 92;
|
||||
m_jmp_indX = $7C;
|
||||
m_jsl = 34;
|
||||
m_lda_abs = 173;
|
||||
m_lda_absx = 189;
|
||||
|
6
Gen.pas
6
Gen.pas
@ -5535,7 +5535,7 @@ procedure GenTree {op: icptr};
|
||||
GenNative(m_lda_imm, genAddress, lab1, nil, shift16);
|
||||
GenNative(m_sta_s, direct, 6, nil, 0);
|
||||
GenNative(m_rep, immediate, 32, nil, 0);
|
||||
GenNative(m_lda_imm, genAddress, lab1, nil, 0);
|
||||
GenNative(m_lda_imm, genAddress, lab1, nil, subtract1);
|
||||
GenNative(m_sta_s, direct, 4, nil, 0);
|
||||
|
||||
{indirect call}
|
||||
@ -7316,9 +7316,7 @@ procedure GenTree {op: icptr};
|
||||
GenImplied(m_asl_a);
|
||||
GenImplied(m_tax);
|
||||
lab1 := GenLabel;
|
||||
GenNative(m_lda_longx, longAbs, lab1, nil, 0);
|
||||
GenImplied(m_pha);
|
||||
GenImplied(m_rts);
|
||||
GenNative(m_jmp_indX, absolute, lab1, nil, 0);
|
||||
GenLab(lab1);
|
||||
end; {GenXjp}
|
||||
|
||||
|
16
Native.pas
16
Native.pas
@ -731,8 +731,10 @@ case mode of
|
||||
LabelSearch(operand, 2, 16, 0)
|
||||
else
|
||||
LabelSearch(operand, 1, 16, 0)
|
||||
else if (flags & subtract1) <> 0 then
|
||||
LabelSearch(operand, 0, 0, 0)
|
||||
else
|
||||
LabelSearch(operand, 0, 0, 0);
|
||||
LabelSearch(operand, 2, 0, 0);
|
||||
end;
|
||||
|
||||
special:
|
||||
@ -819,7 +821,7 @@ case p_opcode of
|
||||
goto 3;
|
||||
|
||||
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_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_pea: begin
|
||||
@ -1523,11 +1525,11 @@ var
|
||||
for i := ns to nnextSpot-1 do begin
|
||||
opcode := npeep[i].opcode;
|
||||
if opcode in
|
||||
[m_bcc,m_bcs,m_beq,m_bmi,m_bne,m_bpl,m_bra,m_brl,m_bvs,m_jml,m_jsl,
|
||||
m_lda_abs,m_lda_absx,m_lda_dir,m_lda_dirx,m_lda_imm,m_lda_indl,
|
||||
m_lda_indly,m_lda_long,m_lda_longx,m_lda_s,m_mvn,m_pla,m_rtl,
|
||||
m_rts,m_tdc,m_txa,m_tya,m_tsc,d_end,d_bmov,d_add,d_pin,d_wrd,
|
||||
d_sym,d_cns] then begin
|
||||
[m_bcc,m_bcs,m_beq,m_bmi,m_bne,m_bpl,m_bra,m_brl,m_bvs,m_jml,
|
||||
m_jmp_indX,m_jsl,m_lda_abs,m_lda_absx,m_lda_dir,m_lda_dirx,
|
||||
m_lda_imm,m_lda_indl,m_lda_indly,m_lda_long,m_lda_longx,m_lda_s,
|
||||
m_mvn,m_pla,m_rtl,m_rts,m_tdc,m_txa,m_tya,m_tsc,d_end,d_bmov,
|
||||
d_add,d_pin,d_wrd,d_sym,d_cns] then begin
|
||||
ASafe := true;
|
||||
goto 1;
|
||||
end {if}
|
||||
|
Loading…
x
Reference in New Issue
Block a user