update to ida 7.6, add builds

This commit is contained in:
2021-10-31 21:20:46 +02:00
parent e0e0f2be99
commit b1809fe2d9
1408 changed files with 279193 additions and 302468 deletions

View File

@@ -0,0 +1,624 @@
/*
* Interactive disassembler (IDA).
* Copyright (c) 1990-2000 by Ilfak Guilfanov.
* ALL RIGHTS RESERVED.
* E-mail: ig@datarescue.com
*
*/
#include "st20.hpp"
//--------------------------------------------------------------------------
// ST20/C2-C4
static const ushort primary4[] =
{
/* 00 */ ST20_j,
/* 01 */ ST20_ldlp,
/* 02 */ ST20_pfix,
/* 03 */ ST20_ldnl,
/* 04 */ ST20_ldc,
/* 05 */ ST20_ldnlp,
/* 06 */ ST20_nfix,
/* 07 */ ST20_ldl,
/* 08 */ ST20_adc,
/* 09 */ ST20_call,
/* 0A */ ST20_cj,
/* 0B */ ST20_ajw,
/* 0C */ ST20_eqc,
/* 0D */ ST20_stl,
/* 0E */ ST20_stnl,
/* 0F */ ST20_opr,
};
static const ushort secondary4_negative[] =
{
/*~00 */ ST20_swapqueue, // swap scheduler queue
/*~01 */ ST20_swaptimer, // swap timer queue
/*~02 */ ST20_insertqueue, // insert at front of scheduler queue
/*~03 */ ST20_timeslice, // timeslice
/*~04 */ ST20_signal, // signal
/*~05 */ ST20_wait, // wait
/*~06 */ ST20_trapdis, // trap disable
/*~07 */ ST20_trapenb, // trap enable
/*~08 */ ST20_null,
/*~09 */ ST20_null,
/*~0A */ ST20_null,
/*~0B */ ST20_tret, // trap return
/*~0C */ ST20_ldshadow, // load shadow registers
/*~0D */ ST20_stshadow, // store shadow registers
/*~0E */ ST20_null,
/*~0F */ ST20_null,
/*~10 */ ST20_null,
/*~11 */ ST20_null,
/*~12 */ ST20_null,
/*~13 */ ST20_null,
/*~14 */ ST20_null,
/*~15 */ ST20_null,
/*~16 */ ST20_null,
/*~17 */ ST20_null,
/*~18 */ ST20_null,
/*~19 */ ST20_null,
/*~1A */ ST20_null,
/*~1B */ ST20_null,
/*~1C */ ST20_null,
/*~1D */ ST20_null,
/*~1E */ ST20_null,
/*~1F */ ST20_iret, // interrupt return
/*~20 */ ST20_null,
/*~21 */ ST20_null,
/*~22 */ ST20_null,
/*~23 */ ST20_null,
/*~24 */ ST20_devmove, // device move
/*~25 */ ST20_null,
/*~26 */ ST20_null,
/*~27 */ ST20_null,
/*~28 */ ST20_null,
/*~29 */ ST20_null,
/*~2A */ ST20_null,
/*~2B */ ST20_null,
/*~2C */ ST20_null,
/*~2D */ ST20_null,
/*~2E */ ST20_restart, // restart
/*~2F */ ST20_causeerror, // cause error
/*~30 */ ST20_nop, // no operation
/*~31 */ ST20_null,
/*~32 */ ST20_null,
/*~33 */ ST20_null,
/*~34 */ ST20_null,
/*~35 */ ST20_null,
/*~36 */ ST20_null,
/*~37 */ ST20_null,
/*~38 */ ST20_null,
/*~39 */ ST20_null,
/*~3A */ ST20_null,
/*~3B */ ST20_null,
/*~3C */ ST20_null,
/*~3D */ ST20_null,
/*~3E */ ST20_null,
/*~3F */ ST20_null,
/*~40 */ ST20_null,
/*~41 */ ST20_null,
/*~42 */ ST20_null,
/*~43 */ ST20_null,
/*~44 */ ST20_null,
/*~45 */ ST20_null,
/*~46 */ ST20_null,
/*~47 */ ST20_null,
/*~48 */ ST20_null,
/*~49 */ ST20_null,
/*~4A */ ST20_null,
/*~4B */ ST20_null,
/*~4C */ ST20_stclock, // store clock register
/*~4D */ ST20_ldclock, // load clock
/*~4E */ ST20_clockdis, // clock disable
/*~4F */ ST20_clockenb, // clock enable
/*~50 */ ST20_null,
/*~51 */ ST20_null,
/*~52 */ ST20_null,
/*~53 */ ST20_null,
/*~54 */ ST20_null,
/*~55 */ ST20_null,
/*~56 */ ST20_null,
/*~57 */ ST20_null,
/*~58 */ ST20_null,
/*~59 */ ST20_null,
/*~5A */ ST20_null,
/*~5B */ ST20_null,
/*~5C */ ST20_null,
/*~5D */ ST20_null,
/*~5E */ ST20_null,
/*~5F */ ST20_null,
/*~60 */ ST20_null,
/*~61 */ ST20_null,
/*~62 */ ST20_null,
/*~63 */ ST20_null,
/*~64 */ ST20_null,
/*~65 */ ST20_null,
/*~66 */ ST20_null,
/*~67 */ ST20_null,
/*~68 */ ST20_null,
/*~69 */ ST20_null,
/*~6A */ ST20_null,
/*~6B */ ST20_null,
/*~6C */ ST20_null,
/*~6D */ ST20_null,
/*~6E */ ST20_null,
/*~6F */ ST20_null,
/*~70 */ ST20_null,
/*~71 */ ST20_null,
/*~72 */ ST20_null,
/*~73 */ ST20_null,
/*~74 */ ST20_null,
/*~75 */ ST20_null,
/*~76 */ ST20_null,
/*~77 */ ST20_null,
/*~78 */ ST20_null,
/*~79 */ ST20_null,
/*~7A */ ST20_null,
/*~7B */ ST20_null,
/*~7C */ ST20_null,
/*~7D */ ST20_null,
/*~7E */ ST20_null,
/*~7F */ ST20_null,
/*~80 */ ST20_null,
/*~81 */ ST20_null,
/*~82 */ ST20_null,
/*~83 */ ST20_null,
/*~84 */ ST20_null,
/*~85 */ ST20_null,
/*~86 */ ST20_null,
/*~87 */ ST20_null,
/*~88 */ ST20_null,
/*~89 */ ST20_null,
/*~8A */ ST20_null,
/*~8B */ ST20_null,
/*~8C */ ST20_ldprodid, // load product identity
/*~8D */ ST20_reboot, // reboot
/*~8E */ ST20_null,
/*~8F */ ST20_null,
};
static const ushort secondary4[] =
{
/* 00 */ ST20_rev, // ---------------------------------------------
/* 01 */ ST20_lb, // load byte
/* 02 */ ST20_bsub, // byte subscript
/* 03 */ ST20_endp, // end process
/* 04 */ ST20_diff, // difference
/* 05 */ ST20_add,
/* 06 */ ST20_gcall, // general call
/* 07 */ ST20_in, // input message
/* 08 */ ST20_prod, // product
/* 09 */ ST20_gt, // greater than
/* 0A */ ST20_wsub, // word subscript
/* 0B */ ST20_out, // output message
/* 0C */ ST20_sub, // subtract
/* 0D */ ST20_startp, // start process
/* 0E */ ST20_outbyte, // output byte
/* 0F */ ST20_outword, // output word
/* 10 */ ST20_seterr, // set error flags
/* 11 */ ST20_null,
/* 12 */ ST20_resetch, // reset channel
/* 13 */ ST20_csub0, // check subscript from 0
/* 14 */ ST20_null,
/* 15 */ ST20_stopp, // stop process
/* 16 */ ST20_ladd, // long add
/* 17 */ ST20_stlb, // store low priority back pointer
/* 18 */ ST20_sthf, // store high priority front pointer
/* 19 */ ST20_norm, // normalize
/* 1A */ ST20_ldiv, // long divide
/* 1B */ ST20_ldpi, // load pointer to instruction
/* 1C */ ST20_stlf, // store low priority front pointer
/* 1D */ ST20_xdble, // extend to double
/* 1E */ ST20_ldpri, // load current priority
/* 1F */ ST20_rem, // remainder
/* 20 */ ST20_ret, // return
/* 21 */ ST20_lend, // loop end
/* 22 */ ST20_ldtimer, // load timer
/* 23 */ ST20_null,
/* 24 */ ST20_null,
/* 25 */ ST20_null,
/* 26 */ ST20_null,
/* 27 */ ST20_null,
/* 28 */ ST20_null,
/* 29 */ ST20_testerr, // test error flag
/* 2A */ ST20_testpranal, // test processor analysing
/* 2B */ ST20_tin, // timer input
/* 2C */ ST20_div, // divide
/* 2D */ ST20_null,
/* 2E */ ST20_dist, // disable timer
/* 2F */ ST20_disc, // disable channel
/* 30 */ ST20_diss, // disable skip
/* 31 */ ST20_lmul, // long multiply
/* 32 */ ST20_not, // not
/* 33 */ ST20_xor, // exclusize or
/* 34 */ ST20_bcnt, // byte count
/* 35 */ ST20_lshr, // long shift right
/* 36 */ ST20_lshl, // long shift left
/* 37 */ ST20_lsum, // long sum
/* 38 */ ST20_lsub, // long subtract
/* 39 */ ST20_runp, // run process
/* 3A */ ST20_xword, // extend word
/* 3B */ ST20_sb, // store byte
/* 3C */ ST20_gajw, // general adjust workspace
/* 3D */ ST20_savel, // save low priority queue registers
/* 3E */ ST20_saveh, // save high priority queue registers
/* 3F */ ST20_wcnt, // word count
/* 40 */ ST20_shr, // shift right
/* 41 */ ST20_shl, // shift left
/* 42 */ ST20_mint, // minimum integer
/* 43 */ ST20_alt, // alt start
/* 44 */ ST20_altwt, // alt wait
/* 45 */ ST20_altend, // alt end
/* 46 */ ST20_and,
/* 47 */ ST20_enbt, // enable timer
/* 48 */ ST20_enbc, // enable channel
/* 49 */ ST20_enbs, // enable skip
/* 4A */ ST20_move, // move message
/* 4B */ ST20_or, // or
/* 4C */ ST20_csngl, // check single
/* 4D */ ST20_ccnt1, // check count from 1
/* 4E */ ST20_talt, // timer alt start
/* 4F */ ST20_ldiff, // long diff
/* 50 */ ST20_sthb, // store high priority back pointer
/* 51 */ ST20_taltwt, // timer alt wait
/* 52 */ ST20_sum, // sum
/* 53 */ ST20_mul, // multiply
/* 54 */ ST20_sttimer, // store timer
/* 55 */ ST20_stoperr, // stop on error
/* 56 */ ST20_cword, // check word
/* 57 */ ST20_clrhalterr, // clear halt-on error flag
/* 58 */ ST20_sethalterr, // set halt-on error flag
/* 59 */ ST20_testhalterr, // test halt-on error flag
/* 5A */ ST20_dup, // duplicate top of stack
/* 5B */ ST20_move2dinit, // initialize data for 2D block move
/* 5C */ ST20_move2dall, // 2D block copy
/* 5D */ ST20_move2dnonzero, // 2D block copy non-zero bytes
/* 5E */ ST20_move2dzero, // 2D block copy zero bytes
/* 5F */ ST20_gtu, // greater than unsigned
/* 60 */ ST20_null,
/* 61 */ ST20_null,
/* 62 */ ST20_null,
/* 63 */ ST20_unpacksn, // unpack single length fp number
/* 64 */ ST20_slmul, // signed long multiply
/* 65 */ ST20_sulmul, // signed timer unsigned long multiply
/* 66 */ ST20_null,
/* 67 */ ST20_null,
/* 68 */ ST20_satadd, // saturating add
/* 69 */ ST20_satsub, // saturating subtract
/* 6A */ ST20_satmul, // saturating multiply
/* 6B */ ST20_null,
/* 6C */ ST20_postnormsn, // post-normalize correction of single length fp number
/* 6D */ ST20_roundsn, // round single length floating point number
/* 6E */ ST20_ldtraph, // load trap handler
/* 6F */ ST20_sttraph, // store trap handler
/* 70 */ ST20_null,
/* 71 */ ST20_ldinf, // load infinity
/* 72 */ ST20_fmul, // fractional multiply
/* 73 */ ST20_cflerr, // check floating point error
/* 74 */ ST20_crcword, // calculate CRC on word
/* 75 */ ST20_crcbyte, // calculate CRC on byte
/* 76 */ ST20_bitcnt, // count bits set in word
/* 77 */ ST20_bitrevword, // reverse bits in word
/* 78 */ ST20_bitrevnbits, // reverse bottom n bits in word
/* 79 */ ST20_pop, // pop processor stack
/* 7A */ ST20_null,
/* 7B */ ST20_null,
/* 7C */ ST20_null,
/* 7D */ ST20_null,
/* 7E */ ST20_ldmemstartval, // load value of MemStart address
/* 7F */ ST20_null,
/* 80 */ ST20_null,
/* 81 */ ST20_wsubdb, // form double word subscript
/* 82 */ ST20_null,
/* 83 */ ST20_null,
/* 84 */ ST20_null,
/* 85 */ ST20_null,
/* 86 */ ST20_null,
/* 87 */ ST20_null,
/* 88 */ ST20_null,
/* 89 */ ST20_null,
/* 8A */ ST20_null,
/* 8B */ ST20_null,
/* 8C */ ST20_null,
/* 8D */ ST20_null,
/* 8E */ ST20_null,
/* 8F */ ST20_null,
/* 90 */ ST20_null,
/* 91 */ ST20_null,
/* 92 */ ST20_null,
/* 93 */ ST20_null,
/* 94 */ ST20_null,
/* 95 */ ST20_null,
/* 96 */ ST20_null,
/* 97 */ ST20_null,
/* 98 */ ST20_null,
/* 99 */ ST20_null,
/* 9A */ ST20_null,
/* 9B */ ST20_null,
/* 9C */ ST20_fptesterr, // test for FPU error
/* 9D */ ST20_null,
/* 9E */ ST20_null,
/* 9F */ ST20_null,
/* A0 */ ST20_null,
/* A1 */ ST20_null,
/* A2 */ ST20_null,
/* A3 */ ST20_null,
/* A4 */ ST20_null,
/* A5 */ ST20_null,
/* A6 */ ST20_null,
/* A7 */ ST20_null,
/* A8 */ ST20_null,
/* A9 */ ST20_null,
/* AA */ ST20_null,
/* AB */ ST20_null,
/* AC */ ST20_null,
/* AD */ ST20_null,
/* AE */ ST20_null,
/* AF */ ST20_null,
/* B0 */ ST20_settimeslice, // set timeslicing status
/* B1 */ ST20_null,
/* B2 */ ST20_null,
/* B3 */ ST20_null,
/* B4 */ ST20_null,
/* B5 */ ST20_null,
/* B6 */ ST20_null,
/* B7 */ ST20_null,
/* B8 */ ST20_xbword, // sign extend byte to word
/* B9 */ ST20_lbx, // load byte and sign extend
/* BA */ ST20_cb, // check byte
/* BB */ ST20_cbu, // check byte unsigned
/* BC */ ST20_null,
/* BD */ ST20_null,
/* BE */ ST20_null,
/* BF */ ST20_null,
/* C0 */ ST20_null,
/* C1 */ ST20_ssub, // sixteen subscript
/* C2 */ ST20_null,
/* C3 */ ST20_null,
/* C4 */ ST20_intdis, // (localised) interrupt disable
/* C5 */ ST20_intenb, // (localised) interrupt enable
/* C6 */ ST20_ldtrapped, // load trapped process status
/* C7 */ ST20_cir, // check in range
/* C8 */ ST20_ss, // store sixteen
/* C9 */ ST20_null,
/* CA */ ST20_ls, // load sixteen
/* CB */ ST20_sttrapped, // store trapped process
/* CC */ ST20_ciru, // check in range unsigned
/* CD */ ST20_gintdis, // general interrupt disable
/* CE */ ST20_gintenb, // general interrupt enable
/* CF */ ST20_null,
/* D0 */ ST20_null,
/* D1 */ ST20_null,
/* D2 */ ST20_null,
/* D3 */ ST20_null,
/* D4 */ ST20_null,
/* D5 */ ST20_null,
/* D6 */ ST20_null,
/* D7 */ ST20_null,
/* D8 */ ST20_null,
/* D9 */ ST20_null,
/* DA */ ST20_null,
/* DB */ ST20_null,
/* DC */ ST20_null,
/* DD */ ST20_null,
/* DE */ ST20_null,
/* DF */ ST20_null,
/* E0 */ ST20_null,
/* E1 */ ST20_null,
/* E2 */ ST20_null,
/* E3 */ ST20_null,
/* E4 */ ST20_null,
/* E5 */ ST20_null,
/* E6 */ ST20_null,
/* E7 */ ST20_null,
/* E8 */ ST20_null,
/* E9 */ ST20_null,
/* EA */ ST20_null,
/* EB */ ST20_null,
/* EC */ ST20_null,
/* ED */ ST20_null,
/* EE */ ST20_null,
/* EF */ ST20_null,
/* F0 */ ST20_devlb, // device load byte
/* F1 */ ST20_devsb, // device store byte
/* F2 */ ST20_devls, // device load sixteen
/* F3 */ ST20_devss, // device store sixteen
/* F4 */ ST20_devlw, // device load word
/* F5 */ ST20_devsw, // device store word
/* F6 */ ST20_null,
/* F7 */ ST20_null,
/* F8 */ ST20_xsword, // sign extend sixteen to word
/* F9 */ ST20_lsx, // load sixteen and sign extend
/* FA */ ST20_cs, // check sixteen
/* FB */ ST20_csu, // check sixteen unsigned
/* FC */ ST20_null,
/* FD */ ST20_null,
/* FE */ ST20_null,
/* FF */ ST20_null,
};
//--------------------------------------------------------------------------
// ST20/C1
static const ushort primary1[] =
{
/* 00 */ ST20_j,
/* 01 */ ST20_ldlp,
/* 02 */ ST20_pfix,
/* 03 */ ST20_ldnl,
/* 04 */ ST20_ldc,
/* 05 */ ST20_ldnlp,
/* 06 */ ST20_nfix,
/* 07 */ ST20_ldl,
/* 08 */ ST20_adc,
/* 09 */ ST20_fcall,
/* 0A */ ST20_cj,
/* 0B */ ST20_ajw,
/* 0C */ ST20_eqc,
/* 0D */ ST20_stl,
/* 0E */ ST20_stnl,
/* 0F */ ST20_opr,
};
static const ushort secondary1[] =
{
/* 00 */ ST20_rev,
/* 01 */ ST20_dup,
/* 02 */ ST20_rot,
/* 03 */ ST20_arot,
/* 04 */ ST20_add,
/* 05 */ ST20_sub,
/* 06 */ ST20_mul,
/* 07 */ ST20_wsub,
/* 08 */ ST20_not,
/* 09 */ ST20_and,
/* 0A */ ST20_or,
/* 0B */ ST20_shl,
/* 0C */ ST20_shr,
/* 0D */ ST20_jab,
/* 0E */ ST20_timeslice,
/* 0F */ ST20_breakpoint,
/* 10 */ ST20_addc,
/* 11 */ ST20_subc,
/* 12 */ ST20_mac,
/* 13 */ ST20_umac,
/* 14 */ ST20_smul,
/* 15 */ ST20_smacinit,
/* 16 */ ST20_smacloop,
/* 17 */ ST20_biquad,
/* 18 */ ST20_divstep,
/* 19 */ ST20_unsign,
/* 1A */ ST20_saturate,
/* 1B */ ST20_gt,
/* 1C */ ST20_gtu,
/* 1D */ ST20_order,
/* 1E */ ST20_orderu,
/* 1F */ ST20_ashr,
/* 20 */ ST20_xor,
/* 21 */ ST20_xbword,
/* 22 */ ST20_xsword,
/* 23 */ ST20_bitld,
/* 24 */ ST20_bitst,
/* 25 */ ST20_bitmask,
/* 26 */ ST20_statusset,
/* 27 */ ST20_statusclr,
/* 28 */ ST20_statustst,
/* 29 */ ST20_rmw,
/* 2A */ ST20_lbinc,
/* 2B */ ST20_sbinc,
/* 2C */ ST20_lsinc,
/* 2D */ ST20_lsxinc,
/* 2E */ ST20_ssinc,
/* 2F */ ST20_lwinc,
/* 30 */ ST20_swinc,
/* 31 */ ST20_ecall,
/* 32 */ ST20_eret,
/* 33 */ ST20_run,
/* 34 */ ST20_stop,
/* 35 */ ST20_signal,
/* 36 */ ST20_wait,
/* 37 */ ST20_enqueue,
/* 38 */ ST20_dequeue,
/* 39 */ ST20_ldtdesc,
/* 3A */ ST20_ldpi,
/* 3B */ ST20_gajw,
/* 3C */ ST20_ldprodid,
/* 3D */ ST20_io,
/* 3E */ ST20_swap32,
/* 3F */ ST20_nop,
};
struct ana_info_t
{
const ushort *primary;
const ushort *secondary;
size_t sqty;
const ushort *secondary_negative;
size_t nsqty;
};
static const ana_info_t c1 =
{
primary1,
secondary1,
qnumber(secondary1),
NULL,
0
};
static const ana_info_t c4 =
{
primary4,
secondary4,
qnumber(secondary4),
secondary4_negative,
qnumber(secondary4_negative),
};
//--------------------------------------------------------------------------
int st20_t::st20_ana(insn_t *_insn)
{
insn_t &insn = *_insn;
const ana_info_t &a = isc4() ? c4 : c1;
int value = 0;
while ( 1 )
{
int code = insn.get_next_byte();
value |= (code & 15);
insn.itype = a.primary[code>>4];
switch ( insn.itype )
{
case ST20_j:
case ST20_cj:
case ST20_fcall:
case ST20_call:
insn.Op1.type = o_near;
insn.Op1.dtype = dt_code;
insn.Op1.addr = uint32(insn.ip + insn.size + value);
break;
case ST20_ldlp:
case ST20_ldnl:
case ST20_ldc:
case ST20_ldnlp:
case ST20_ldl:
case ST20_adc:
case ST20_ajw:
case ST20_eqc:
case ST20_stl:
case ST20_stnl:
insn.Op1.type = o_imm;
insn.Op1.dtype = dt_dword;
insn.Op1.value = value;
break;
case ST20_nfix:
value = ~value;
// fallthrough
case ST20_pfix:
value <<= 4;
continue;
case ST20_opr:
if ( isc4() && value == 0x17C )
{
insn.itype = ST20_lddevid;
break;
}
if ( value < 0 )
{
value = (~value & ~15) | (value & 15);
if ( value >= a.nsqty )
return 0;
insn.itype = a.secondary_negative[value];
}
else
{
if ( value >= a.sqty )
return 0;
insn.itype = a.secondary[value];
}
break;
}
break;
}
return insn.size;
}

View File

@@ -0,0 +1,126 @@
/*
* Interactive disassembler (IDA).
* Copyright (c) 1990-99 by Ilfak Guilfanov.
* ALL RIGHTS RESERVED.
* E-mail: ig@datarescue.com
*
*
*/
#include "st20.hpp"
//------------------------------------------------------------------------
static void process_immediate_number(const insn_t &insn, int n)
{
set_immd(insn.ea);
if ( is_defarg(get_flags(insn.ea),n) )
return;
switch ( insn.itype )
{
case ST20_ajw:
op_num(insn.ea, n);
break;
}
}
//----------------------------------------------------------------------
ea_t calc_mem(const insn_t &insn, ea_t ea)
{
return to_ea(insn.cs, ea);
}
//----------------------------------------------------------------------
void st20_t::handle_operand(const insn_t &insn, const op_t &x, bool isload)
{
ea_t ea;
switch ( x.type )
{
case o_imm:
QASSERT(10110, isload);
process_immediate_number(insn, x.n);
if ( op_adds_xrefs(get_flags(insn.ea), x.n) )
insn.add_off_drefs(x, dr_O, 0);
break;
case o_near:
{
cref_t ftype = fl_JN;
ea = calc_mem(insn, x.addr);
if ( has_insn_feature(insn.itype, CF_CALL) )
{
if ( !func_does_return(ea) )
flow = false;
ftype = fl_CN;
}
insn.add_cref(ea, x.offb, ftype);
}
break;
default:
INTERR(10376);
}
}
//----------------------------------------------------------------------
int st20_t::st20_emu(const insn_t &insn)
{
uint32 Feature = insn.get_canon_feature(ph);
flow = ((Feature & CF_STOP) == 0);
if ( Feature & CF_USE1 ) handle_operand(insn, insn.Op1, true);
if ( Feature & CF_CHG1 ) handle_operand(insn, insn.Op1, false);
//
// Determine if the next instruction should be executed
//
if ( segtype(insn.ea) == SEG_XTRN )
flow = false;
if ( flow )
add_cref(insn.ea,insn.ea+insn.size,fl_F);
return 1;
}
//----------------------------------------------------------------------
int is_jump_func(const func_t * /*pfn*/, ea_t *jump_target)
{
*jump_target = BADADDR;
return 0; // means "don't know"
}
//----------------------------------------------------------------------
int may_be_func(const insn_t &)
{
// if ( insn.itype == H8_push && isbp(insn.Op1.reg) ) return 100; // push.l er6
return 0;
}
//----------------------------------------------------------------------
int is_sane_insn(const insn_t &insn, int /*nocrefs*/)
{
if ( insn.itype == ST20_nop )
{
for ( int i=0; i < 8; i++ )
if ( get_word(insn.ea-i*2) != 0 )
return 1;
return 0; // too many nops in a row
}
return 1;
}
//----------------------------------------------------------------------
int idaapi is_align_insn(ea_t ea)
{
insn_t insn;
if ( decode_insn(&insn, ea) < 1 )
return 0;
switch ( insn.itype )
{
case ST20_nop:
break;
default:
return 0;
}
return insn.size;
}

View File

@@ -0,0 +1,238 @@
/*
* Interactive disassembler (IDA).
* Copyright (c) 1990-2000 by Ilfak Guilfanov.
* ALL RIGHTS RESERVED.
* E-mail: ig@datarescue.com
*
*
*/
#include "st20.hpp"
const instruc_t Instructions[] =
{
{ "", 0 }, // Unknown Operation
{ "adc", CF_USE1 }, // add constant
{ "add", 0 }, // add
{ "addc", 0 }, // add with carry
{ "ajw", CF_USE1 }, // adjust work space
{ "and", 0 }, // and
{ "arot", 0 }, // anti-rotate stack
{ "ashr", 0 }, // arithmetic shift right
{ "biquad", 0 }, // biquad IIR filter step
{ "bitld", 0 }, // load bit
{ "bitmask", 0 }, // create bit mask
{ "bitst", 0 }, // store bit
{ "breakpoint", 0 }, // breakpoint
{ "cj", CF_USE1 }, // conditional jump
{ "dequeue", 0 }, // dequeue a process
{ "divstep", 0 }, // divide step
{ "dup", 0 }, // duplicate
{ "ecall", 0 }, // exception call
{ "enqueue", 0 }, // enqueue a process
{ "eqc", CF_USE1 }, // equals constant
{ "eret", CF_STOP }, // exception return
{ "fcall", CF_USE1|CF_CALL }, // function call
{ "gajw", 0 }, // general adjust workspace
{ "gt", 0 }, // greater than
{ "gtu", 0 }, // greater than unsigned
{ "io", 0 }, // input/output
{ "j", CF_USE1|CF_STOP }, // jump
{ "jab", 0 }, // jump absolute
{ "lbinc", 0 }, // load byte and increment
{ "ldc", CF_USE1 }, // load constant
{ "ldl", CF_USE1 }, // load local
{ "ldlp", CF_USE1 }, // load local pointer
{ "ldnl", CF_USE1 }, // load non-local
{ "ldnlp", CF_USE1 }, // load non-local pointer
{ "ldpi", 0 }, // load pointer to instruction
{ "ldprodid", 0 }, // load product identity
{ "ldtdesc", 0 }, // load task descriptor
{ "lsinc", 0 }, // load sixteen and increment
{ "lsxinc", 0 }, // load sixteen sign extended and increment
{ "lwinc", 0 }, // load word and increment
{ "mac", 0 }, // multiply accumulate
{ "mul", 0 }, // multiply
{ "nfix", CF_USE1 }, // negative prefix
{ "nop", 0 }, // no operation
{ "not", 0 }, // bitwise not
{ "opr", CF_USE1 }, // operate
{ "or", 0 }, // or
{ "order", 0 }, // order
{ "orderu", 0 }, // unsigned order
{ "pfix", CF_USE1 }, // prefix
{ "rev", 0 }, // reverse
{ "rmw", 0 }, // read modify write
{ "rot", 0 }, // rotate stack
{ "run", 0 }, // run process
{ "saturate", 0 }, // saturate
{ "sbinc", 0 }, // store byte and increment
{ "shl", 0 }, // shift left
{ "shr", 0 }, // shift right
{ "signal", 0 }, // signal
{ "smacinit", 0 }, // initialize short multiply accumulate loop
{ "smacloop", 0 }, // short multiply accumulate loop
{ "smul", 0 }, // short multiply
{ "ssinc", 0 }, // store sixteen and increment
{ "statusclr", 0 }, // clear bits in status register
{ "statusset", 0 }, // set bits in status register
{ "statustst", 0 }, // test status register
{ "stl", CF_USE1 }, // store local
{ "stnl", CF_USE1 }, // store non-local
{ "stop", 0 }, // stop process
{ "sub", 0 }, // subtract
{ "subc", 0 }, // subtract with carry
{ "swap32", 0 }, // byte swap 32
{ "swinc", 0 }, // store word and increment
{ "timeslice", 0 }, // timeslice
{ "umac", 0 }, // unsigned multiply accumulate
{ "unsign", 0 }, // unsign argument
{ "wait", 0 }, // wait
{ "wsub", 0 }, // word subscript
{ "xbword", 0 }, // sign extend byte to word
{ "xor", 0 }, // exclusive or
{ "xsword", 0 }, // sign extend sixteen to word
// C2-C4 instructions
{ "alt", 0 }, // alt start
{ "altend", CF_STOP }, // alt end
{ "altwt", 0 }, // alt wait
{ "bcnt", 0 }, // byte count
{ "bitcnt", 0 }, // count bits set in word
{ "bitrevnbits", 0 }, // reverse bottom n bits in word
{ "bitrevword", 0 }, // reverse bits in word
{ "bsub", 0 }, // byte subscript
{ "call", CF_USE1|CF_CALL }, // call
{ "causeerror", 0 }, // cause error
{ "cb", 0 }, // check byte
{ "cbu", 0 }, // check byte unsigned
{ "ccnt1", 0 }, // check count from 1
{ "cflerr", 0 }, // check floating point error
{ "cir", 0 }, // check in range
{ "ciru", 0 }, // check in range unsigned
{ "clockdis", 0 }, // clock disable
{ "clockenb", 0 }, // clock enable
{ "clrhalterr", 0 }, // clear halt-on error flag
{ "crcbyte", 0 }, // calculate CRC on byte
{ "crcword", 0 }, // calculate CRC on word
{ "cs", 0 }, // check sixteen
{ "csngl", 0 }, // check single
{ "csu", 0 }, // check sixteen unsigned
{ "csub0", 0 }, // check subscript from 0
{ "cword", 0 }, // check word
{ "devlb", 0 }, // device load byte
{ "devls", 0 }, // device load sixteen
{ "devlw", 0 }, // device load word
{ "devmove", 0 }, // device move
{ "devsb", 0 }, // device store byte
{ "devss", 0 }, // device store sixteen
{ "devsw", 0 }, // device store word
{ "diff", 0 }, // difference
{ "disc", 0 }, // disable channel
{ "diss", 0 }, // disable skip
{ "dist", 0 }, // disable timer
{ "div", 0 }, // divide
{ "enbc", 0 }, // enable channel
{ "enbs", 0 }, // enable skip
{ "enbt", 0 }, // enable timer
{ "endp", CF_STOP }, // end process
{ "fmul", 0 }, // fractional multiply
{ "fptesterr", 0 }, // test for FPU error
{ "gcall", CF_CALL|CF_JUMP }, // general call
{ "gintdis", 0 }, // general interrupt disable
{ "gintenb", 0 }, // general interrupt enable
{ "in", 0 }, // input message
{ "insertqueue", 0 }, // insert at front of scheduler queue
{ "intdis", 0 }, // (localised) interrupt disable
{ "intenb", 0 }, // (localised) interrupt enable
{ "iret", CF_STOP }, // interrupt return
{ "ladd", 0 }, // long add
{ "lb", 0 }, // load byte
{ "lbx", 0 }, // load byte and sign extend
{ "ldclock", 0 }, // load clock
{ "lddevid", 0 }, // load device identity
{ "ldiff", 0 }, // long diff
{ "ldinf", 0 }, // load infinity
{ "ldiv", 0 }, // long divide
{ "ldmemstartval", 0 }, // load value of MemStart address
{ "ldpri", 0 }, // load current priority
{ "ldshadow", 0 }, // load shadow registers
{ "ldtimer", 0 }, // load timer
{ "ldtraph", 0 }, // load trap handler
{ "ldtrapped", 0 }, // load trapped process status
{ "lend", 0 }, // loop end
{ "lmul", 0 }, // long multiply
{ "ls", 0 }, // load sixteen
{ "lshl", 0 }, // long shift left
{ "lshr", 0 }, // long shift right
{ "lsub", 0 }, // long subtract
{ "lsum", 0 }, // long sum
{ "lsx", 0 }, // load sixteen and sign extend
{ "mint", 0 }, // minimum integer
{ "move", 0 }, // move message
{ "move2dall", 0 }, // 2D block copy
{ "move2dinit", 0 }, // initialize data for 2D block move
{ "move2dnonzero", 0 }, // 2D block copy non-zero bytes
{ "move2dzero", 0 }, // 2D block copy zero bytes
{ "norm", 0 }, // normalize
{ "out", 0 }, // output message
{ "outbyte", 0 }, // output byte
{ "outword", 0 }, // output word
{ "pop", 0 }, // pop processor stack
{ "postnormsn", 0 }, // post-normalize correction of single length fp number
{ "prod", 0 }, // product
{ "reboot", CF_STOP }, // reboot
{ "rem", 0 }, // remainder
{ "resetch", 0 }, // reset channel
{ "restart", CF_STOP }, // restart
{ "ret", CF_STOP }, // return
{ "roundsn", 0 }, // round single length floating point number
{ "runp", 0 }, // run process
{ "satadd", 0 }, // saturating add
{ "satmul", 0 }, // saturating multiply
{ "satsub", 0 }, // saturating subtract
{ "saveh", 0 }, // save high priority queue registers
{ "savel", 0 }, // save low priority queue registers
{ "sb", 0 }, // store byte
{ "seterr", 0 }, // set error flags
{ "sethalterr", 0 }, // set halt-on error flag
{ "settimeslice", 0 }, // set timeslicing status
{ "slmul", 0 }, // signed long multiply
{ "ss", 0 }, // store sixteen
{ "ssub", 0 }, // sixteen subscript
{ "startp", 0 }, // start process
{ "stclock", 0 }, // store clock register
{ "sthb", 0 }, // store high priority back pointer
{ "sthf", 0 }, // store high priority front pointer
{ "stlb", 0 }, // store low priority back pointer
{ "stlf", 0 }, // store low priority front pointer
{ "stoperr", 0 }, // stop on error
{ "stopp", 0 }, // stop process
{ "stshadow", 0 }, // store shadow registers
{ "sttimer", 0 }, // store timer
{ "sttraph", 0 }, // store trap handler
{ "sttrapped", 0 }, // store trapped process
{ "sulmul", 0 }, // signed timer unsigned long multiply
{ "sum", 0 }, // sum
{ "swapqueue", 0 }, // swap scheduler queue
{ "swaptimer", 0 }, // swap timer queue
{ "talt", 0 }, // timer alt start
{ "taltwt", 0 }, // timer alt wait
{ "testerr", 0 }, // test error flag
{ "testhalterr", 0 }, // test halt-on error flag
{ "testpranal", 0 }, // test processor analysing
{ "tin", 0 }, // timer input
{ "trapdis", 0 }, // trap disable
{ "trapenb", 0 }, // trap enable
{ "tret", CF_STOP }, // trap return
{ "unpacksn", 0 }, // unpack single length fp number
{ "wcnt", 0 }, // word count
{ "wsubdb", 0 }, // form double word subscript
{ "xdble", 0 }, // extend to double
{ "xword", 0 }, // extend word
};
CASSERT(qnumber(Instructions) == ST20_last);

View File

@@ -0,0 +1,243 @@
/*
* Interactive disassembler (IDA).
* Copyright (c) 1990-2021 Hex-Rays
* ALL RIGHTS RESERVED.
*
*/
#ifndef __INSTRS_HPP
#define __INSTRS_HPP
extern const instruc_t Instructions[];
enum nameNum
{
ST20_null = 0, // Unknown Operation
// C1 instructions
ST20_adc, // add constant
ST20_add, // add
ST20_addc, // add with carry
ST20_ajw, // adjust work space
ST20_and, // and
ST20_arot, // anti-rotate stack
ST20_ashr, // arithmetic shift right
ST20_biquad, // biquad IIR filter step
ST20_bitld, // load bit
ST20_bitmask, // create bit mask
ST20_bitst, // store bit
ST20_breakpoint, // breakpoint
ST20_cj, // conditional jump
ST20_dequeue, // dequeue a process
ST20_divstep, // divide step
ST20_dup, // duplicate
ST20_ecall, // exception call
ST20_enqueue, // enqueue a process
ST20_eqc, // equals constant
ST20_eret, // exception return
ST20_fcall, // function call
ST20_gajw, // general adjust workspace
ST20_gt, // greater than
ST20_gtu, // greater than unsigned
ST20_io, // input/output
ST20_j, // jump
ST20_jab, // jump absolute
ST20_lbinc, // load byte and increment
ST20_ldc, // load constant
ST20_ldl, // load local
ST20_ldlp, // load local pointer
ST20_ldnl, // load non-local
ST20_ldnlp, // load non-local pointer
ST20_ldpi, // load pointer to instruction
ST20_ldprodid, // load product identity
ST20_ldtdesc, // load task descriptor
ST20_lsinc, // load sixteen and increment
ST20_lsxinc, // load sixteen sign extended and increment
ST20_lwinc, // load word and increment
ST20_mac, // multiply accumulate
ST20_mul, // multiply
ST20_nfix, // negative prefix
ST20_nop, // no operation
ST20_not, // bitwise not
ST20_opr, // operate
ST20_or, // or
ST20_order, // order
ST20_orderu, // unsigned order
ST20_pfix, // prefix
ST20_rev, // reverse
ST20_rmw, // read modify write
ST20_rot, // rotate stack
ST20_run, // run process
ST20_saturate, // saturate
ST20_sbinc, // store byte and increment
ST20_shl, // shift left
ST20_shr, // shift right
ST20_signal, // signal
ST20_smacinit, // initialize short multiply accumulate loop
ST20_smacloop, // short multiply accumulate loop
ST20_smul, // short multiply
ST20_ssinc, // store sixteen and increment
ST20_statusclr, // clear bits in status register
ST20_statusset, // set bits in status register
ST20_statustst, // test status register
ST20_stl, // store local
ST20_stnl, // store non-local
ST20_stop, // stop process
ST20_sub, // subtract
ST20_subc, // subtract with carry
ST20_swap32, // byte swap 32
ST20_swinc, // store word and increment
ST20_timeslice, // timeslice
ST20_umac, // unsigned multiply accumulate
ST20_unsign, // unsign argument
ST20_wait, // wait
ST20_wsub, // word subscript
ST20_xbword, // sign extend byte to word
ST20_xor, // exclusive or
ST20_xsword, // sign extend sixteen to word
// C2-C4 instructions
ST20_alt, // alt start
ST20_altend, // alt end
ST20_altwt, // alt wait
ST20_bcnt, // byte count
ST20_bitcnt, // count bits set in word
ST20_bitrevnbits, // reverse bottom n bits in word
ST20_bitrevword, // reverse bits in word
ST20_bsub, // byte subscript
ST20_call, // call
ST20_causeerror, // cause error
ST20_cb, // check byte
ST20_cbu, // check byte unsigned
ST20_ccnt1, // check count from 1
ST20_cflerr, // check floating point error
ST20_cir, // check in range
ST20_ciru, // check in range unsigned
ST20_clockdis, // clock disable
ST20_clockenb, // clock enable
ST20_clrhalterr, // clear halt-on error flag
ST20_crcbyte, // calculate CRC on byte
ST20_crcword, // calculate CRC on word
ST20_cs, // check sixteen
ST20_csngl, // check single
ST20_csu, // check sixteen unsigned
ST20_csub0, // check subscript from 0
ST20_cword, // check word
ST20_devlb, // device load byte
ST20_devls, // device load sixteen
ST20_devlw, // device load word
ST20_devmove, // device move
ST20_devsb, // device store byte
ST20_devss, // device store sixteen
ST20_devsw, // device store word
ST20_diff, // difference
ST20_disc, // disable channel
ST20_diss, // disable skip
ST20_dist, // disable timer
ST20_div, // divide
ST20_enbc, // enable channel
ST20_enbs, // enable skip
ST20_enbt, // enable timer
ST20_endp, // end process
ST20_fmul, // fractional multiply
ST20_fptesterr, // test for FPU error
ST20_gcall, // general call
ST20_gintdis, // general interrupt disable
ST20_gintenb, // general interrupt enable
ST20_in, // input message
ST20_insertqueue, // insert at front of scheduler queue
ST20_intdis, // (localised) interrupt disable
ST20_intenb, // (localised) interrupt enable
ST20_iret, // interrupt return
ST20_ladd, // long add
ST20_lb, // load byte
ST20_lbx, // load byte and sign extend
ST20_ldclock, // load clock
ST20_lddevid, // load device identity
ST20_ldiff, // long diff
ST20_ldinf, // load infinity
ST20_ldiv, // long divide
ST20_ldmemstartval, // load value of MemStart address
ST20_ldpri, // load current priority
ST20_ldshadow, // load shadow registers
ST20_ldtimer, // load timer
ST20_ldtraph, // load trap handler
ST20_ldtrapped, // load trapped process status
ST20_lend, // loop end
ST20_lmul, // long multiply
ST20_ls, // load sixteen
ST20_lshl, // long shift left
ST20_lshr, // long shift right
ST20_lsub, // long subtract
ST20_lsum, // long sum
ST20_lsx, // load sixteen and sign extend
ST20_mint, // minimum integer
ST20_move, // move message
ST20_move2dall, // 2D block copy
ST20_move2dinit, // initialize data for 2D block move
ST20_move2dnonzero, // 2D block copy non-zero bytes
ST20_move2dzero, // 2D block copy zero bytes
ST20_norm, // normalize
ST20_out, // output message
ST20_outbyte, // output byte
ST20_outword, // output word
ST20_pop, // pop processor stack
ST20_postnormsn, // post-normalize correction of single length fp number
ST20_prod, // product
ST20_reboot, // reboot
ST20_rem, // remainder
ST20_resetch, // reset channel
ST20_restart, // restart
ST20_ret, // return
ST20_roundsn, // round single length floating point number
ST20_runp, // run process
ST20_satadd, // saturating add
ST20_satmul, // saturating multiply
ST20_satsub, // saturating subtract
ST20_saveh, // save high priority queue registers
ST20_savel, // save low priority queue registers
ST20_sb, // store byte
ST20_seterr, // set error flags
ST20_sethalterr, // set halt-on error flag
ST20_settimeslice, // set timeslicing status
ST20_slmul, // signed long multiply
ST20_ss, // store sixteen
ST20_ssub, // sixteen subscript
ST20_startp, // start process
ST20_stclock, // store clock register
ST20_sthb, // store high priority back pointer
ST20_sthf, // store high priority front pointer
ST20_stlb, // store low priority back pointer
ST20_stlf, // store low priority front pointer
ST20_stoperr, // stop on error
ST20_stopp, // stop process
ST20_stshadow, // store shadow registers
ST20_sttimer, // store timer
ST20_sttraph, // store trap handler
ST20_sttrapped, // store trapped process
ST20_sulmul, // signed timer unsigned long multiply
ST20_sum, // sum
ST20_swapqueue, // swap scheduler queue
ST20_swaptimer, // swap timer queue
ST20_talt, // timer alt start
ST20_taltwt, // timer alt wait
ST20_testerr, // test error flag
ST20_testhalterr, // test halt-on error flag
ST20_testpranal, // test processor analysing
ST20_tin, // timer input
ST20_trapdis, // trap disable
ST20_trapenb, // trap enable
ST20_tret, // trap return
ST20_unpacksn, // unpack single length fp number
ST20_wcnt, // word count
ST20_wsubdb, // form double word subscript
ST20_xdble, // extend to double
ST20_xword, // extend word
ST20_last,
};
#endif

View File

@@ -0,0 +1,57 @@
PROC=st20
CONFIGS=st20.cfg
include ../module.mak
# MAKEDEP dependency list ------------------
$(F)ana$(O) : $(I)auto.hpp $(I)bitrange.hpp $(I)bytes.hpp \
$(I)config.hpp $(I)diskio.hpp \
$(I)entry.hpp $(I)fpro.h $(I)funcs.hpp $(I)ida.hpp \
$(I)idp.hpp $(I)ieee.h $(I)kernwin.hpp $(I)lines.hpp \
$(I)llong.hpp $(I)loader.hpp \
$(I)nalt.hpp $(I)name.hpp \
$(I)netnode.hpp $(I)offset.hpp $(I)pro.h \
$(I)problems.hpp $(I)range.hpp $(I)segment.hpp \
$(I)ua.hpp $(I)xref.hpp ../idaidp.hpp ../iohandler.hpp \
ana.cpp ins.hpp st20.hpp
$(F)emu$(O) : $(I)auto.hpp $(I)bitrange.hpp $(I)bytes.hpp \
$(I)config.hpp $(I)diskio.hpp \
$(I)entry.hpp $(I)fpro.h $(I)funcs.hpp $(I)ida.hpp \
$(I)idp.hpp $(I)ieee.h $(I)kernwin.hpp $(I)lines.hpp \
$(I)llong.hpp $(I)loader.hpp \
$(I)nalt.hpp $(I)name.hpp \
$(I)netnode.hpp $(I)offset.hpp $(I)pro.h \
$(I)problems.hpp $(I)range.hpp $(I)segment.hpp \
$(I)ua.hpp $(I)xref.hpp ../idaidp.hpp ../iohandler.hpp \
emu.cpp ins.hpp st20.hpp
$(F)ins$(O) : $(I)auto.hpp $(I)bitrange.hpp $(I)bytes.hpp \
$(I)config.hpp $(I)diskio.hpp \
$(I)entry.hpp $(I)fpro.h $(I)funcs.hpp $(I)ida.hpp \
$(I)idp.hpp $(I)ieee.h $(I)kernwin.hpp $(I)lines.hpp \
$(I)llong.hpp $(I)loader.hpp \
$(I)nalt.hpp $(I)name.hpp \
$(I)netnode.hpp $(I)offset.hpp $(I)pro.h \
$(I)problems.hpp $(I)range.hpp $(I)segment.hpp \
$(I)ua.hpp $(I)xref.hpp ../idaidp.hpp ../iohandler.hpp \
ins.cpp ins.hpp st20.hpp
$(F)out$(O) : $(I)auto.hpp $(I)bitrange.hpp $(I)bytes.hpp \
$(I)config.hpp $(I)diskio.hpp \
$(I)entry.hpp $(I)fpro.h $(I)funcs.hpp $(I)ida.hpp \
$(I)idp.hpp $(I)ieee.h $(I)kernwin.hpp $(I)lines.hpp \
$(I)llong.hpp $(I)loader.hpp \
$(I)nalt.hpp $(I)name.hpp \
$(I)netnode.hpp $(I)offset.hpp $(I)pro.h \
$(I)problems.hpp $(I)range.hpp $(I)segment.hpp \
$(I)ua.hpp $(I)xref.hpp ../idaidp.hpp ../iohandler.hpp \
ins.hpp out.cpp st20.hpp
$(F)reg$(O) : $(I)auto.hpp $(I)bitrange.hpp $(I)bytes.hpp \
$(I)config.hpp $(I)diskio.hpp \
$(I)entry.hpp $(I)fpro.h $(I)funcs.hpp $(I)ida.hpp \
$(I)idp.hpp $(I)ieee.h $(I)kernwin.hpp $(I)lines.hpp \
$(I)llong.hpp $(I)loader.hpp \
$(I)nalt.hpp $(I)name.hpp \
$(I)netnode.hpp $(I)offset.hpp $(I)pro.h \
$(I)problems.hpp $(I)range.hpp $(I)segment.hpp \
$(I)ua.hpp $(I)xref.hpp ../idaidp.hpp ../iohandler.hpp \
ins.hpp reg.cpp st20.hpp

View File

@@ -0,0 +1,108 @@
/*
* Interactive disassembler (IDA).
* Copyright (c) 1990-99 by Ilfak Guilfanov.
* ALL RIGHTS RESERVED.
* E-mail: ig@datarescue.com
*
*
*/
#include "st20.hpp"
//----------------------------------------------------------------------
class out_st20_t : public outctx_t
{
out_st20_t(void) = delete; // not used
public:
void outmem(const op_t &x, ea_t ea);
bool out_operand(const op_t &x);
void out_insn(void);
};
CASSERT(sizeof(out_st20_t) == sizeof(outctx_t));
DECLARE_OUT_FUNCS_WITHOUT_OUTMNEM(out_st20_t)
//----------------------------------------------------------------------
void out_st20_t::outmem(const op_t &x, ea_t ea)
{
if ( !out_name_expr(x, ea, BADADDR) )
{
out_tagon(COLOR_ERROR);
out_btoa(x.addr, 16);
out_tagoff(COLOR_ERROR);
remember_problem(PR_NONAME,insn.ea);
}
}
//----------------------------------------------------------------------
bool out_st20_t::out_operand(const op_t &x)
{
switch ( x.type )
{
case o_void:
return 0;
case o_imm:
out_value(x, OOFS_IFSIGN|OOFW_IMM);
break;
case o_near:
outmem(x, calc_mem(insn, x.addr));
break;
default:
INTERR(10377);
}
return 1;
}
//----------------------------------------------------------------------
void out_st20_t::out_insn(void)
{
out_mnemonic();
out_one_operand(0);
out_immchar_cmts();
flush_outbuf();
}
//--------------------------------------------------------------------------
//lint -esym(1764, ctx) could be made const
//lint -esym(818, Sarea) could be made const
void idaapi st20_segstart(outctx_t &ctx, segment_t *Sarea)
{
if ( is_spec_segm(Sarea->type) )
return;
qstring sname;
get_visible_segm_name(&sname, Sarea);
ctx.gen_cmt_line("section %s", sname.c_str());
}
//--------------------------------------------------------------------------
void idaapi st20_segend(outctx_t &, segment_t *)
{
}
//--------------------------------------------------------------------------
void idaapi st20_header(outctx_t &ctx)
{
ctx.gen_header(GH_PRINT_PROC);
ctx.gen_empty_line();
}
//--------------------------------------------------------------------------
void st20_t::st20_footer(outctx_t &ctx) const
{
qstring nbuf = get_colored_name(inf_get_start_ea());
const char *name = nbuf.c_str();
const char *end = ash.end;
if ( end == NULL )
ctx.gen_printf(DEFAULT_INDENT,COLSTR("%s end %s",SCOLOR_AUTOCMT), ash.cmnt, name);
else
ctx.gen_printf(DEFAULT_INDENT,
COLSTR("%s",SCOLOR_ASMDIR) " " COLSTR("%s %s",SCOLOR_AUTOCMT),
ash.end, ash.cmnt, name);
}

View File

@@ -0,0 +1,338 @@
/*
* Interactive disassembler (IDA).
* Copyright (c) 1990-2000 by Ilfak Guilfanov.
* ALL RIGHTS RESERVED.
* E-mail: ig@datarescue.com
*
*
*/
#include "st20.hpp"
#include <diskio.hpp>
int data_id;
//--------------------------------------------------------------------------
static const char *const register_names[] =
{
"Areg", // Evaluation stack register A
"Breg", // Evaluation stack register B
"Creg", // Evaluation stack register C
"Iptr", // Instruction pointer register, pointing to the next instruction to be executed
"Status", // Status register
"Wptr", // Work space pointer, pointing to the stack of the currently executing process
"Tdesc", // Task descriptor
"IOreg", // Input and output register
"cs", "ds",
};
//--------------------------------------------------------------------------
static const uchar ret0[] = { 0x23, 0x22 }; // eret
static const uchar ret1[] = { 0x24, 0xF5 }; // altend
static const uchar ret2[] = { 0x20, 0xF3 }; // endp
static const uchar ret3[] = { 0x61, 0xFF }; // iret
static const uchar ret4[] = { 0x68, 0xFD }; // reboot
static const uchar ret5[] = { 0x62, 0xFE }; // restart
static const uchar ret6[] = { 0x22, 0xF0 }; // ret
static const uchar ret7[] = { 0x60, 0xFB }; // tret
static const bytes_t retcodes1[] =
{
{ qnumber(ret0), ret0, },
{ 0, NULL }
};
static const bytes_t retcodes4[] =
{
{ qnumber(ret1), ret1, },
{ qnumber(ret2), ret2, },
{ qnumber(ret3), ret3, },
{ qnumber(ret4), ret4, },
{ qnumber(ret5), ret5, },
{ qnumber(ret6), ret6, },
{ qnumber(ret7), ret7, },
{ 0, NULL }
};
//-----------------------------------------------------------------------
// Hypthetical assembler
//-----------------------------------------------------------------------
static const asm_t hypasm =
{
ASH_HEXF0 // 1234h
|ASD_DECF0 // 1234
|ASB_BINF0 // 1010b
|ASO_OCTF0 // 1234o
|AS_COLON // create colons after data names
|AS_ONEDUP, // one array definition per line
0,
"Hypthetical assembler",
0,
NULL, // header lines
"org", // org
"end", // end
";", // comment string
'\"', // string delimiter
'\'', // char delimiter
"'\"", // special symbols in char and string constants
"db", // ascii string directive
"db", // byte directive
"dw", // word directive
"dd", // double words
"dq", // qwords
NULL, // oword (16 bytes)
NULL, // float (4 bytes)
NULL, // double (8 bytes)
NULL, // tbyte (10/12 bytes)
NULL, // packed decimal real
NULL, // arrays (#h,#d,#v,#s(...)
"ds %s", // uninited arrays
"equ", // equ
NULL, // 'seg' prefix (example: push seg seg001)
"$", // current IP (instruction pointer)
NULL, // func_header
NULL, // func_footer
"public", // "public" name keyword
NULL, // "weak" name keyword
"extrn", // "extrn" name keyword
// .extern directive requires an explicit object size
NULL, // "comm" (communal variable)
NULL, // get_type_name
NULL, // "align" keyword
'(', ')', // lbrace, rbrace
"mod", // mod
"&", // and
"|", // or
"^", // xor
"not", // not
"<<", // shl
">>", // shr
NULL, // sizeof
};
static const asm_t *const asms[] = { &hypasm, NULL };
//--------------------------------------------------------------------------
static const char cfgname[] = "st20.cfg";
//--------------------------------------------------------------------------
const char *st20_t::set_idp_options(
const char *keyword,
int /*value_type*/,
const void * /*value*/,
bool /*idb_loaded*/)
{
if ( keyword != NULL )
return IDPOPT_BADKEY;
if ( choose_ioport_device(&ioh.device, cfgname) )
ioh.set_device_name(ioh.device.c_str(), IORESP_ALL);
return IDPOPT_OK;
}
//----------------------------------------------------------------------
void st20_t::load_from_idb()
{
ioh.restore_device();
}
//----------------------------------------------------------------------
// This old-style callback only returns the processor module object.
static ssize_t idaapi notify(void *, int msgid, va_list)
{
if ( msgid == processor_t::ev_get_procmod )
return size_t(SET_MODULE_DATA(st20_t));
return 0;
}
//--------------------------------------------------------------------------
ssize_t idaapi st20_t::on_event(ssize_t msgid, va_list va)
{
int code = 0;
switch ( msgid )
{
case processor_t::ev_init:
helper.create(PROCMOD_NODE_NAME);
break;
case processor_t::ev_term:
clr_module_data(data_id);
break;
case processor_t::ev_ending_undo:
procnum = ph.get_proc_index();
if ( isc4() )
ph.retcodes = retcodes4;
//fall through
case processor_t::ev_oldfile:
if ( msgid == processor_t::ev_oldfile )
ioh.upgrade_device_index(); // upgrade device index from 0 to -1
load_from_idb();
break;
case processor_t::ev_newprc: // new processor type
procnum = va_arg(va, int);
// bool keep_cfg = va_argi(va, bool);
if ( isc4() )
ph.retcodes = retcodes4;
break;
case processor_t::ev_is_jump_func:
{
const func_t *pfn = va_arg(va, const func_t *);
ea_t *jump_target = va_arg(va, ea_t *);
return is_jump_func(pfn, jump_target);
}
case processor_t::ev_is_sane_insn:
{
const insn_t *insn = va_arg(va, insn_t *);
int no_crefs = va_arg(va, int);
return is_sane_insn(*insn, no_crefs) == 1 ? 1 : -1;
}
case processor_t::ev_may_be_func:
{
const insn_t *insn = va_arg(va, insn_t *);
return may_be_func(*insn);
}
case processor_t::ev_out_header:
{
outctx_t *ctx = va_arg(va, outctx_t *);
st20_header(*ctx);
return 1;
}
case processor_t::ev_out_footer:
{
outctx_t *ctx = va_arg(va, outctx_t *);
st20_footer(*ctx);
return 1;
}
case processor_t::ev_out_segstart:
{
outctx_t *ctx = va_arg(va, outctx_t *);
segment_t *seg = va_arg(va, segment_t *);
st20_segstart(*ctx, seg);
return 1;
}
case processor_t::ev_out_segend:
{
outctx_t *ctx = va_arg(va, outctx_t *);
segment_t *seg = va_arg(va, segment_t *);
st20_segend(*ctx, seg);
return 1;
}
case processor_t::ev_ana_insn:
{
insn_t *out = va_arg(va, insn_t *);
return st20_ana(out);
}
case processor_t::ev_emu_insn:
{
const insn_t *insn = va_arg(va, const insn_t *);
return st20_emu(*insn) ? 1 : -1;
}
case processor_t::ev_out_insn:
{
outctx_t *ctx = va_arg(va, outctx_t *);
out_insn(*ctx);
return 1;
}
case processor_t::ev_out_operand:
{
outctx_t *ctx = va_arg(va, outctx_t *);
const op_t *op = va_arg(va, const op_t *);
return out_opnd(*ctx, *op) ? 1 : -1;
}
case processor_t::ev_set_idp_options:
{
const char *keyword = va_arg(va, const char *);
int value_type = va_arg(va, int);
const char *value = va_arg(va, const char *);
const char **errmsg = va_arg(va, const char **);
bool idb_loaded = va_argi(va, bool);
const char *ret = set_idp_options(keyword, value_type, value, idb_loaded);
if ( ret == IDPOPT_OK )
return 1;
if ( errmsg != NULL )
*errmsg = ret;
return -1;
}
case processor_t::ev_is_align_insn:
{
ea_t ea = va_arg(va, ea_t);
return is_align_insn(ea);
}
default:
break;
}
return code;
}
//-----------------------------------------------------------------------
#define FAMILY "SGS-Thomson ST20:"
static const char *const shnames[] = { "st20", "st20c4", NULL };
static const char *const lnames[] =
{
FAMILY"SGS-Thomson ST20/C1",
"SGS-Thomson ST20/C2-C4",
NULL
};
//-----------------------------------------------------------------------
// Processor Definition
//-----------------------------------------------------------------------
processor_t LPH =
{
IDP_INTERFACE_VERSION, // version
PLFM_ST20, // id
// flag
PRN_HEX
| PR_RNAMESOK,
// flag2
PR2_IDP_OPTS, // the module has processor-specific configuration options
8, // 8 bits in a byte for code segments
8, // 8 bits in a byte for other segments
shnames,
lnames,
asms,
notify,
register_names, // Register names
qnumber(register_names), // Number of registers
cs, // first
ds, // last
2, // size of a segment register
cs, ds,
NULL, // No known code start sequences
retcodes1,
ST20_null,
ST20_last,
Instructions, // instruc
0, // int tbyte_size; -- doesn't exist
{ 0, 7, 15, 0 }, // char real_width[4];
// number of symbols after decimal point
// 2byte float (0-does not exist)
// normal float
// normal double
// long double
ST20_eret, // Icode of return instruction. It is ok to give any of possible return instructions
};

View File

@@ -0,0 +1,9 @@
; This file describes standard names for SGS-Thomson ST20
; They are not used yet.
TEST 0

View File

@@ -0,0 +1,90 @@
/*
* Interactive disassembler (IDA).
* Copyright (c) 1990-2000 by Ilfak Guilfanov.
* ALL RIGHTS RESERVED.
* E-mail: ig@datarescue.com
*
*
*/
#ifndef _ST20_HPP
#define _ST20_HPP
#include "../idaidp.hpp"
#include <diskio.hpp>
#include "ins.hpp"
#include "../iohandler.hpp"
#define PROCMOD_NAME st20
#define PROCMOD_NODE_NAME "$ st20"
//------------------------------------------------------------------
enum regnum_t
{
Areg, // Evaluation stack register A
Breg, // Evaluation stack register B
Creg, // Evaluation stack register C
Iptr, // Instruction pointer register, pointing to the next instruction to be executed
Status, // Status register
Wptr, // Work space pointer, pointing to the stack of the currently executing process
Tdesc, // Task descriptor
IOreg, // Input and output register
cs,
ds,
};
//------------------------------------------------------------------
#define PROC_C1 0
#define PROC_C4 1
//------------------------------------------------------------------
struct st20_iohandler_t : public iohandler_t
{
st20_iohandler_t(netnode &nn) : iohandler_t(nn) {}
};
struct st20_t : public procmod_t
{
netnode helper;
st20_iohandler_t ioh = st20_iohandler_t(helper);
int procnum;
bool flow;
virtual ssize_t idaapi on_event(ssize_t msgid, va_list va) override;
const char *idaapi set_idp_options(
const char *keyword,
int /*value_type*/,
const void * /*value*/,
bool /*idb_loaded*/);
int st20_ana(insn_t *insn);
int st20_emu(const insn_t &insn);
void handle_operand(const insn_t &insn, const op_t &x, bool isload);
bool isc4(void) { return procnum == PROC_C4; }
void st20_footer(outctx_t &ctx) const;
void load_from_idb();
};
extern int data_id;
ea_t calc_mem(const insn_t &insn, ea_t ea); // map virtual to physical ea
//------------------------------------------------------------------
void idaapi st20_header(outctx_t &ctx);
void idaapi st20_segstart(outctx_t &ctx, segment_t *seg);
void idaapi st20_segend(outctx_t &ctx, segment_t *seg);
void idaapi st20_assumes(outctx_t &ctx); // function to produce assume directives
int idaapi is_align_insn(ea_t ea);
int is_jump_func(const func_t *pfn, ea_t *jump_target);
int is_sane_insn(const insn_t &insn, int nocrefs);
int may_be_func(const insn_t &insn); // can a function start here?
#endif // _ST20_HPP