m68k: refactor some code to not fail when the tasmop set will be bigger than 256 elements

git-svn-id: trunk@42926 -
This commit is contained in:
Károly Balogh 2019-09-05 21:49:27 +00:00
parent de095c4631
commit 5eee29e5d1
3 changed files with 39 additions and 32 deletions

View File

@ -270,32 +270,28 @@ interface
op : tasmop; op : tasmop;
begin begin
op:=taicpu(hp).opcode; op:=taicpu(hp).opcode;
{ old versions of GAS don't like PEA.L and LEA.L } case op of
if (op in [
A_LEA,A_PEA,A_ABCD,A_BCHG,A_BCLR,A_BSET,A_BTST, A_LEA,A_PEA,A_ABCD,A_BCHG,A_BCLR,A_BSET,A_BTST,
A_EXG,A_NBCD,A_SBCD,A_SWAP,A_TAS,A_SCC,A_SCS, A_EXG,A_NBCD,A_SBCD,A_SWAP,A_TAS,A_SCC,A_SCS,
A_SEQ,A_SGE,A_SGT,A_SHI,A_SLE,A_SLS,A_SLT,A_SMI, A_SEQ,A_SGE,A_SGT,A_SHI,A_SLE,A_SLS,A_SLT,A_SMI,
A_SNE,A_SPL,A_ST,A_SVC,A_SVS,A_SF]) then A_SNE,A_SPL,A_ST,A_SVC,A_SVS,A_SF:
result:=gas_op2str[op] { old versions of GAS don't like PEA.L and LEA.L }
else result:=gas_op2str[op];
{ Scc/FScc is always BYTE, DBRA/DBcc is always WORD, doesn't need opsize (KB) } A_SXX, A_FSXX, A_DBXX, A_DBRA:
if op in [A_SXX, A_FSXX, A_DBXX, A_DBRA] then { Scc/FScc is always BYTE, DBRA/DBcc is always WORD, doesn't need opsize (KB) }
result:=gas_op2str[op]+cond2str[taicpu(hp).condition] result:=gas_op2str[op]+cond2str[taicpu(hp).condition];
else { fix me: a fugly hack to utilize GNU AS pseudo instructions for more optimal branching }
{ fix me: a fugly hack to utilize GNU AS pseudo instructions for more optimal branching } A_JSR:
if op in [A_JSR] then result:='jbsr';
result:='jbsr' A_JMP:
else result:='jra';
if op in [A_JMP] then A_BXX:
result:='jra' result:='j'+cond2str[taicpu(hp).condition]+gas_opsize2str[taicpu(hp).opsize];
else A_FBXX:
if op in [A_BXX] then result:='fj'+{gas_op2str[op]+}cond2str[taicpu(hp).condition]+gas_opsize2str[taicpu(hp).opsize];
result:='j'+cond2str[taicpu(hp).condition]+gas_opsize2str[taicpu(hp).opsize] else
else result:=gas_op2str[op]+gas_opsize2str[taicpu(hp).opsize];
if op in [A_FBXX] then end;
result:='fj'+{gas_op2str[op]+}cond2str[taicpu(hp).condition]+gas_opsize2str[taicpu(hp).opsize]
else
result:=gas_op2str[op]+gas_opsize2str[taicpu(hp).opsize];
end; end;

View File

@ -399,9 +399,16 @@ implementation
function is_calljmp(o:tasmop):boolean; function is_calljmp(o:tasmop):boolean;
begin begin
is_calljmp := case o of
o in [A_BXX,A_FBXX,A_DBXX,A_BCC..A_BVS,A_DBCC..A_DBVS,A_FBEQ..A_FSNGLE, A_BXX,A_FBXX,A_DBXX,
A_JSR,A_BSR,A_JMP]; A_BCC..A_BVS,
A_DBCC..A_DBVS,
A_FBEQ..A_FSNGLE,
A_JSR,A_BSR,A_JMP:
is_calljmp:=true;
else
is_calljmp:=false;
end;
end; end;

View File

@ -178,12 +178,16 @@ const
actopcode:=tasmop(PtrUInt(iasmops.Find(hs))); actopcode:=tasmop(PtrUInt(iasmops.Find(hs)));
{ Also filter the helper opcodes, they can't be valid { Also filter the helper opcodes, they can't be valid
while reading an assembly source } while reading an assembly source }
if not (actopcode in case actopcode of
[A_NONE, A_LABEL, A_DBXX, A_SXX, A_BXX, A_FBXX]) then A_NONE, A_LABEL, A_DBXX, A_SXX, A_BXX, A_FBXX:
begin begin
actasmtoken:=AS_OPCODE; end;
result:=TRUE; else
exit; begin
actasmtoken:=AS_OPCODE;
result:=TRUE;
exit;
end;
end; end;
end; end;