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

442
idasdk76/module/c39/ana.cpp Normal file
View File

@@ -0,0 +1,442 @@
/*
* Rockwell C39 processor module for IDA.
* Copyright (c) 2000-2006 Konstantin Norvatoff, <konnor@bk.ru>
* Freeware.
*/
#include "c39.hpp"
/*
Operand types:
1) none
2) Register a, x, y
3) address $xx address may be 8 or 16 bits
4) indirect address ($xx) address of the cell with the target address
5) immediate #$xx constant
6) label Label target label of the jump
*/
//----------------------------------------------------------------------
// current byte(s) is immediate data, 1 byte
static void SetImmData(op_t &op, uchar code)
{
op.type = o_imm;
// always in the second byte
op.offb = 1;
// element size
op.dtype = dt_byte;
// value
op.addr = op.value = code;
// it can't be an offset!
op.flags |= OF_NUMBER; // only number
}
//----------------------------------------------------------------------
// registres are considered byte-sized
static void SetReg(op_t &op, uchar reg_n)
{
op.type = o_reg; // only register
op.reg = reg_n; // register number
op.dtype = dt_byte; // size is always 8 bits
}
//----------------------------------------------------------------------
// memory cell
static void SetMemVar(op_t &op, ushort addr)
{
op.type = o_mem;
op.addr = op.value = addr;
op.dtype = dt_word;
}
//----------------------------------------------------------------------
// memory cell with an address
static void SetMemVarI(op_t &op, ushort addr)
{
op.type = o_mem;
op.specflag1 |= URR_IND;
op.addr = op.value = addr;
op.dtype = dt_word;
}
//----------------------------------------------------------------------
// relative branch
static void SetRelative(const insn_t &insn, op_t &op, signed char disp)
{
op.type = o_near;
op.dtype = dt_word;
op.offb = 1; // in fact, not always...
// calculate indirect value
op.addr = op.value = insn.ip + insn.size + (int32)disp;
}
//----------------------------------------------------------------------
// absolute branch
static void SetAbs(op_t &op, unsigned short disp)
{
op.type = o_near;
op.dtype = dt_word;
op.offb = 1; // in fact, not always...
// calculate final value
op.addr = op.value = disp;
}
//----------------------------------------------------------------------
// analyzer
int idaapi C39_ana(insn_t *_insn)
{
static const uchar Dt[] =
{
C39_brk, C39_ora, C39_mpy, C39_tip, 0, C39_ora, C39_asl, C39_rmb, // 00
C39_php, C39_ora, C39_asl, C39_jsb, C39_jpi, C39_ora, C39_asl, C39_bbr, // 08
C39_bpl, C39_ora, C39_mpa, C39_lab, 0, C39_ora, C39_asl, C39_rmb, // 10
C39_clc, C39_ora, C39_neg, C39_jsb, 0, C39_ora, C39_asl, C39_bbr, // 18
C39_jsr, C39_and, C39_psh, C39_phw, C39_bit, C39_and, C39_rol, C39_rmb, // 20
C39_plp, C39_and, C39_rol, C39_jsb, C39_bit, C39_and, C39_rol, C39_bbr, // 28
C39_bmi, C39_and, C39_pul, C39_plw, 0, C39_and, C39_rol, C39_rmb, // 30
C39_sec, C39_and, C39_asr, C39_jsb, 0, C39_and, C39_rol, C39_bbr, // 38
C39_rti, C39_eor, C39_rnd, 0, 0, C39_eor, C39_lsr, C39_rmb, // 40
C39_pha, C39_eor, C39_lsr, C39_jsb, C39_jmp, C39_eor, C39_lsr, C39_bbr, // 48
C39_bvc, C39_eor, C39_clw, 0, 0, C39_eor, C39_lsr, C39_rmb, // 50
C39_cli, C39_eor, C39_phy, C39_jsb, 0, C39_eor, C39_lsr, C39_bbr, // 58
C39_rts, C39_adc, C39_taw, 0, C39_add, C39_adc, C39_ror, C39_rmb, // 60
C39_pla, C39_adc, C39_ror, C39_jsb, C39_jmp, C39_adc, C39_ror, C39_bbr, // 68
C39_bvs, C39_adc, C39_twa, 0, C39_add, C39_adc, C39_ror, C39_rmb, // 70
C39_sei, C39_adc, C39_ply, C39_jsb, C39_jmp, C39_adc, C39_ror, C39_bbr, // 78
C39_bra, C39_sta, 0, 0, C39_sty, C39_sta, C39_stx, C39_smb, // 80
C39_dey, C39_add, C39_txa, C39_nxt, C39_sty, C39_sta, C39_stx, C39_bbs, // 88
C39_bcc, C39_sta, 0, 0, C39_sty, C39_sta, C39_stx, C39_smb, // 90
C39_tya, C39_sta, C39_txs, C39_lii, 0, C39_sta, 0, C39_bbs, // 98
C39_ldy, C39_lda, C39_ldx, 0, C39_ldy, C39_lda, C39_ldx, C39_smb, // A0
C39_tay, C39_lda, C39_tax, C39_lan, C39_ldy, C39_lda, C39_ldx, C39_bbs, // A8
C39_bcs, C39_lda, C39_sti, 0, C39_ldy, C39_lda, C39_ldx, C39_smb, // B0
C39_clv, C39_lda, C39_tsx, C39_ini, C39_ldy, C39_lda, C39_ldx, C39_bbs, // B8
C39_cpy, C39_cmp, C39_rba, 0, C39_cpy, C39_cmp, C39_dec, C39_smb, // C0
C39_iny, C39_cmp, C39_dex, C39_phi, C39_cpy, C39_cmp, C39_dec, C39_bbs, // C8
C39_bne, C39_cmp, C39_sba, 0, C39_exc, C39_cmp, C39_dec, C39_smb, // D0
C39_cld, C39_cmp, C39_phx, C39_pli, 0, C39_cmp, C39_dec, C39_bbs, // D8
C39_cpx, C39_sbc, C39_bar, 0, C39_cpx, C39_sbc, C39_inc, C39_smb, // E0
C39_inx, C39_sbc, C39_nop, C39_lai, C39_cpx, C39_sbc, C39_inc, C39_bbs, // E8
C39_beq, C39_sbc, C39_bas, 0, 0, C39_sbc, C39_inc, C39_smb, // F0
C39_sed, C39_sbc, C39_plx, C39_pia, 0, C39_sbc, C39_inc, C39_bbs // F8
};
// get instruction byte
insn_t &insn = *_insn;
uchar code = insn.get_next_byte();
// get instruction code
insn.itype = Dt[code];
// analyze instruction type
switch ( insn.itype )
{
// unknown instruction
case 0:
return 0;
// smb/rmb
case C39_smb:
case C39_rmb:
SetImmData(insn.Op1, (code>>4) & 7);
SetMemVar(insn.Op2, insn.get_next_byte());
break;
// bbs/bbr
case C39_bbs:
case C39_bbr:
SetImmData(insn.Op1, (code>>4)&7);
SetMemVar(insn.Op2, insn.get_next_byte());
SetRelative(insn, insn.Op3, insn.get_next_byte());
break;
// bpl/bmi/bvc/bvs/bra/bcc/bcs/bne/beq
case C39_beq:
case C39_bne:
case C39_bcs:
case C39_bcc:
case C39_bra:
case C39_bvs:
case C39_bvc:
case C39_bmi:
case C39_bpl:
SetRelative(insn, insn.Op1, insn.get_next_byte());
break;
// jsb
case C39_jsb:
SetMemVar(insn.Op1,0xFFE0+((code>>4) & 7)*2);
break;
// ora, and, eor, adc, sta, lda, cmp, sbc
case C39_sbc:
case C39_cmp:
case C39_lda:
case C39_sta:
case C39_adc:
case C39_eor:
case C39_and:
case C39_ora:
switch ( code&0x1E )
{
// 01 - xxx ($b)
case 0x00:
SetMemVarI(insn.Op1, insn.get_next_byte());
break;
// 05 - xxx $b
case 0x04:
SetMemVar(insn.Op1, insn.get_next_byte());
break;
// 09 - xxx #$b
case 0x08:
SetImmData(insn.Op1, insn.get_next_byte());
break;
// 0D - xxx $w
case 0x0C:
SetMemVar(insn.Op1, insn.get_next_word());
break;
// 11 - xxx ($b), x
case 0x10:
SetMemVarI(insn.Op1, insn.get_next_byte());
SetReg(insn.Op2,rX);
break;
// 15 - xxx $b, x
case 0x14:
SetMemVar(insn.Op1, insn.get_next_byte());
SetReg(insn.Op2,rX);
break;
// 19 - xxx $w, y
case 0x18:
SetMemVar(insn.Op1, insn.get_next_word());
SetReg(insn.Op2,rY);
break;
// 1d - xxx $w, x
case 0x1C:
SetMemVar(insn.Op1, insn.get_next_word());
SetReg(insn.Op2,rX);
break;
}
break;
// asl, rol, lsr, ror, asr
case C39_asr: // this one has a single variant (asr a)
case C39_ror:
case C39_lsr:
case C39_rol:
case C39_asl:
switch ( code & 0x1C )
{
// 6 - xxx $b
case 0x04:
SetMemVar(insn.Op1, insn.get_next_byte());
break;
// A - xxx a
case 0x08:
SetReg(insn.Op1,rA);
break;
// E - xxx $w
case 0x0C:
SetMemVar(insn.Op1, insn.get_next_word());
break;
// 16 - xxx $b, x
case 0x14:
SetMemVar(insn.Op1, insn.get_next_byte());
SetReg(insn.Op2,rX);
break;
// 1E - xxx $w, x
case 0x1C:
SetMemVar(insn.Op1, insn.get_next_word());
SetReg(insn.Op2,rX);
break;
}
break;
// inc, dec
case C39_dec:
case C39_inc:
switch ( code&0x18 )
{
// e6 - xxx $b
case 0x00:
SetMemVar(insn.Op1, insn.get_next_byte());
break;
// ee - xxx $w
case 0x08:
SetMemVar(insn.Op1, insn.get_next_word());
break;
// f6 - xxx $b, x
case 0x10:
SetMemVar(insn.Op1, insn.get_next_byte());
SetReg(insn.Op2,rX);
break;
// fe - xxx $w, x
case 0x18:
SetMemVar(insn.Op1, insn.get_next_word());
SetReg(insn.Op2,rX);
break;
}
break;
// rba/sba $b, $w
case C39_rba:
case C39_sba:
SetImmData(insn.Op1, insn.get_next_byte());
SetMemVar(insn.Op2, insn.get_next_word());
break;
// cpy/cpx
case C39_cpx:
case C39_cpy:
switch ( code & 0x1C )
{
// a0 - xxx #$b
case 0x00:
SetImmData(insn.Op1, insn.get_next_byte());
break;
// a4 - xxx $b
case 0x04:
SetMemVar(insn.Op1, insn.get_next_byte());
break;
// ac - xxx $w
case 0x0C:
SetMemVar(insn.Op1, insn.get_next_word());
break;
// 14 - xxx $b, x
case 0x14:
SetMemVar(insn.Op1, insn.get_next_byte());
SetReg(insn.Op2,rX);
break;
// 1C - xxx $w, x
case 0x1C:
SetMemVar(insn.Op1, insn.get_next_word());
SetReg(insn.Op2,rX);
break;
}
break;
// lab/neg
case C39_neg:
case C39_lab:
SetReg(insn.Op1,rA);
break;
// jpi ($w)
case C39_jpi:
SetMemVarI(insn.Op1, insn.get_next_word());
break;
// jsr $w
case C39_jsr:
SetAbs(insn.Op1, insn.get_next_word());
break;
// bar/bas $w, $b ,$rel
case C39_bar:
case C39_bas:
SetMemVar(insn.Op1, insn.get_next_word());
SetImmData(insn.Op2, insn.get_next_byte());
SetRelative(insn, insn.Op3, insn.get_next_byte());
break;
// bit
case C39_bit:
if ( code & 8 )
SetMemVar(insn.Op1, insn.get_next_word()); // bit $w
else
SetMemVar(insn.Op1, insn.get_next_byte()); // bit $b
break;
// jmp
case C39_jmp:
switch ( code )
{
case 0x4C:
SetAbs(insn.Op1, insn.get_next_word());
break;
case 0x6C:
SetMemVarI(insn.Op1, insn.get_next_word());
break;
case 0x7C:
SetMemVarI(insn.Op1, insn.get_next_word());
SetReg(insn.Op2, rX);
break;
}
break;
// sti
case C39_sti:
SetImmData(insn.Op1,insn.get_next_byte());
SetMemVar(insn.Op2,insn.get_next_byte());
break;
// exc
case C39_exc:
SetMemVar(insn.Op1,insn.get_next_byte());
SetReg(insn.Op2,rX);
break;
// add
case C39_add:
switch ( code )
{
case 0x64:
SetMemVar(insn.Op1,insn.get_next_byte());
break;
case 0x74:
SetMemVar(insn.Op1,insn.get_next_byte());
SetReg(insn.Op2,rX);
break;
case 0x89:
SetImmData(insn.Op1,insn.get_next_byte());
break;
}
break;
// sty
case C39_stx:
case C39_ldx:
case C39_ldy:
case C39_sty:
switch ( code & 0x1C )
{
// A0 xxx #$b
case 0x00:
SetImmData(insn.Op1,insn.get_next_byte());
break;
// A4 xxx $b
case 0x04:
SetMemVar(insn.Op1,insn.get_next_byte());
break;
// AC xxx $w
case 0x0C:
SetMemVar(insn.Op1,insn.get_next_word());
break;
// B4 xxx $b, x
case 0x14:
SetMemVar(insn.Op1,insn.get_next_byte());
SetReg(insn.Op2,
insn.itype == C39_sty || insn.itype == C39_ldy ? rX : rY);
break;
// BC xxx $w, x
case 0x1C:
SetMemVar(insn.Op1,insn.get_next_word());
SetReg(insn.Op2,
insn.itype == C39_sty || insn.itype == C39_ldy ? rX : rY);
break;
}
break;
}
return insn.size;
}

277
idasdk76/module/c39/c39.cfg Normal file
View File

@@ -0,0 +1,277 @@
; The format of the input file:
; each device definition begins with a line like this:
;
; .devicename
;
; after it go the port definitions in this format:
;
; portname address
;
; the bit definitions (optional) are represented like this:
;
; portname.bitname bitnumber
;
; lines beginning with a space are ignored.
; comment lines should be started with ';' character.
;
; the default device is specified at the start of the file
;
; .default device_name
;
; all lines non conforming to the format are passed to the callback function
;
; Rockwell C39 SPECIFIC LINES
;------------------------
;
; the processor definition may include the memory configuration.
; the line format is:
; area CLASS AREA-NAME START:END
;
; where CLASS is anything, but please use one of CODE, DATA, BSS
; START and END are addresses, the end address is not included
; Interrupt vectors are declared in the following way:
; entry NAME ADDRESS COMMENT
.default C39
.C39
; MEMORY MAP
area DATA SFR 0x0000:0x0040 Special Function Register
area DATA IRAMS 0x0040:0x0080 Page 1 Segment Address
area DATA IRAM0 0x0080:0x0100 Page 0 Internal RAM
area DATA IRAM1 0x0100:0x0200 Page 1 Internal RAM
area DATA IRAM2 0x0200:0x0300 Page 2 Internal RAM
area DATA IRAM3 0x0300:0x0400 Page 3 Internal RAM
area DATA IRAM4 0x0400:0x0480 Page 4 Internal RAM
area DATA ICRC 0x0480:0x0500 CRC buffer Area
area DATA IRAM5 0x0500:0x0600 Page 5 Internal RAM (UNAVAIL)
area DATA IES4 0x0600:0x0800 Part of ES4 RAM
; Interrupt and reset vector assignments
interrupt JSB0_ 0xFFE0 JBS0 Vector
interrupt JSB1_ 0xFFE2 JBS1 Vector
interrupt JSB2_ 0xFFE4 JBS2 Vector
interrupt JSB3_ 0xFFE6 JBS3 Vector
interrupt JSB4_ 0xFFE8 JBS4 Vector
interrupt JSB5_ 0xFFEA JBS5 Vector
interrupt JSB6_ 0xFFEC JBS6 Vector
interrupt JSB7_ 0xFFEE JBS7 Vector
interrupt INT0_ 0xFFF0 INT0 Vector
interrupt TIMERA_ 0xFFF2 TIMER A Vector
interrupt INT2_ 0xFFF4 INT2 Vector
interrupt TIMERB_ 0xFFF6 TIMER B Vector
interrupt INT4_ 0xFFF8 INT4 Vector
interrupt NMI_ 0xFFFA NMI Vector
interrupt RESET_ 0xFFFC Reset Vector
interrupt PWR_INT 0xFFFE Start Vector
; INPUT/OUTPUT
P_A 0x00 Port A (bidir)
P_B 0x01 Port B (W)
P_C 0x02 Port C (Bidir)
P_AD 0x03 Port A Direction (R/O)
P_DD 0x04 Port D Direction Controll
P_BS 0x05 Port B Select (R/W)
P_CD 0x06 Port C Direction (W)
P_E 0x07 Port E (R/W)
P_ED 0x08 Port E Direction/Mask option
P_LPR 0x09 Low Power Register
P_EI 0x0A External Interrupt Register
P_CEI 0x0B Clear External Interrupt
P_PTGBMODE 0x0C PTG B Mode (R/W)
P_PBB 0x0D PBB (R/W)
P_PBUL 0x0E PBUL, PBB to PBLL
P_PBULC 0x0F PBUL PBB-PBLL Clear Download
P_TAMODE 0x10 Timer A Mode
P_TALC 0x11 Timer A LC, Timer A UC - Timer A S, Timer A LL
P_TAS 0x12 Timer A S (R), Timer A UL (W)
P_TASC 0x13 Timer A S, Timer A UL, Clear, Download
P_TBMODE 0x14 Timer B Mode
P_TBLC 0x15 Timer B LC, Timer B UC - Timer B S, Timer B LL
P_TBS 0x16 Timer B S (R), Timer B UL (W)
P_TBSC 0x17 Timer B S, Timer B UL, Clear, Download
P_BANK0000 0x18 Bank switch register 0000-1FFF (R/W)
P_BANK2000 0x19 Bank switch register 2000-3FFF (R/W)
P_BANK4000 0x1A Bank switch register 4000-5FFF (R/W)
P_BANK6000 0x1B Bank switch register 6000-7FFF (R/W)
P_BANK8000 0x1C Bank switch register 8000-9FFF (R/W)
P_BANKA000 0x1D Bank switch register A000-BFFF (R/W)
P_BANKC000 0x1E Bank switch register C000-DFFF (R/W)
P_BANKE000 0x1F Bank switch register E000-FFFF (R/W)
P_TXRX 0x20 Tx/Rx FIFO buf
P_LSR 0x21 LSR
P_MSR 0x22 MSR
P_LCR 0x23 line control register
P_MCR 0x24 modem control register
P_FIFOC 0x25 FIFO control
P_SPRAM6 0x26 SP RAM 6
P_SCRR 0x27 scratch reg
P_DLSB 0x28 divisor latch LSB
P_DMSB 0x29 divisor latch MSB
P_SPRAMA 0x2A SP RAM A
P_SPRAMB 0x2B SP RAM B
P_SPRAMC 0x2C SP RAM C
P_SPRAMD 0x2D SP RAM D
P_GPFE 0x2E GPFS
P_HHR 0x2F host handshake register
P_FSR 0x30 FSR
P_FIER 0x31 FIER
P_HCR 0x32 host control register
P_CSF 0x33 chip select fast/slow
P_PTGAMODE 0x34 PTG A mode
P_PAB 0x35 PAB
P_PAUL 0x36 PAUL, PAB-PALL
P_PAULC 0x37 PAUL PAB-PALL clear download
P_SIOBUF 0x38 serial I/O buffers
P_SIE 0x39 serial interrupt enable
P_SMR 0x3A serial mode register
P_SLCR 0x3B serial line control register
P_SSR 0x3C serial status register
P_SFR 0x3D serial form register
P_SOUTD 0x3E SOUT (RxD) divider latch (R)
P_SIND 0x3F SIN (TxD) divider latch (R)
.C29
; MEMORY MAP
area DATA SFR 0x0000:0x0040 Special Function Register
area DATA IRAMS 0x0040:0x0080 Page 1 Segment Address
area DATA IRAM0 0x0080:0x0100 Page 0 Internal RAM
area DATA IRAM1 0x0100:0x0200 Page 1 Internal RAM
area DATA IRAM2 0x0200:0x0300 Page 2 Internal RAM
area DATA IRAM3 0x0300:0x0400 Page 3 Internal RAM
area DATA IRAM4 0x0400:0x0480 Page 4 Internal RAM
area DATA ICRC 0x0480:0x0500 CRC buffer Area
area DATA IRAM5 0x0500:0x0600 Page 5 Internal RAM (UNAVAIL)
area DATA IES4 0x0600:0x0800 Part of ES4 RAM
; Interrupt and reset vector assignments
interrupt JSB0_ 0xFFE0 JBS0 Vector
interrupt JSB1_ 0xFFE2 JBS1 Vector
interrupt JSB2_ 0xFFE4 JBS2 Vector
interrupt JSB3_ 0xFFE6 JBS3 Vector
interrupt JSB4_ 0xFFE8 JBS4 Vector
interrupt JSB5_ 0xFFEA JBS5 Vector
interrupt JSB6_ 0xFFEC JBS6 Vector
interrupt JSB7_ 0xFFEE JBS7 Vector
interrupt INT0_ 0xFFF0 INT0 Vector
interrupt TIMERA_ 0xFFF2 TIMER A Vector
interrupt INT2_ 0xFFF4 INT2 Vector
interrupt TIMERB_ 0xFFF6 TIMER B Vector
interrupt INT4_ 0xFFF8 INT4 Vector
interrupt NMI_ 0xFFFA NMI Vector
interrupt RESET_ 0xFFFC Reset Vector
interrupt PWR_INT 0xFFFE Start Vector
; INPUT/OUTPUT
P_A 0x00 Port A (bidir)
P_B 0x01 Port B (W)
P_C 0x02 Port C (Bidir)
P_AD 0x03 Port A Direction (R/O)
P_DD 0x04 Port D Direction Controll
P_BS 0x05 Port B Select (R/W)
P_CD 0x06 Port C Direction (W)
P_E 0x07 Port E (R/W)
P_ED 0x08 Port E Direction/Mask option
P_LPR 0x09 Low Power Register
P_EI 0x0A External Interrupt Register
P_CEI 0x0B Clear External Interrupt
P_PTGBMODE 0x0C PTG B Mode (R/W)
P_PBB 0x0D PBB (R/W)
P_PBUL 0x0E PBUL, PBB to PBLL
P_PBULC 0x0F PBUL PBB-PBLL Clear Download
P_TAMODE 0x10 Timer A Mode
P_TALC 0x11 Timer A LC, Timer A UC - Timer A S, Timer A LL
P_TAS 0x12 Timer A S (R), Timer A UL (W)
P_TASC 0x13 Timer A S, Timer A UL, Clear, Download
P_TBMODE 0x14 Timer B Mode
P_TBLC 0x15 Timer B LC, Timer B UC - Timer B S, Timer B LL
P_TBS 0x16 Timer B S (R), Timer B UL (W)
P_TBSC 0x17 Timer B S, Timer B UL, Clear, Download
P_BANK0000 0x18 Bank switch register 0000-1FFF (R/W)
P_BANK2000 0x19 Bank switch register 2000-3FFF (R/W)
P_BANK4000 0x1A Bank switch register 4000-5FFF (R/W)
P_BANK6000 0x1B Bank switch register 6000-7FFF (R/W)
P_BANK8000 0x1C Bank switch register 8000-9FFF (R/W)
P_BANKA000 0x1D Bank switch register A000-BFFF (R/W)
P_BANKC000 0x1E Bank switch register C000-DFFF (R/W)
P_BANKE000 0x1F Bank switch register E000-FFFF (R/W)
P_TXRX 0x20 Tx/Rx
P_TXBUF 0x21 Tx buffer
P_SPRAM2 0x22 SP RAM 2
P_LCR 0x23 line control register
P_MCR 0x24 modem control register
P_SPRAM5 0x25 SP RAM 5
P_SPRAM6 0x26 SP RAM 6
P_SPRAM7 0x27 SP RAM 7
P_DLSB 0x28 divisor latch LSB
P_DMSB 0x29 divisor latch MSB
P_SPRAMA 0x2A SP RAM A
P_SPRAMB 0x2B SP RAM B
P_SPRAMC 0x2C SP RAM C
P_SPRAMD 0x2D SP RAM D
P_SPRAME 0x2E SP RAM E
P_HHR 0x2F host handshake register
P_LSR 0x30 LSR
P_MSR 0x31 MSR
P_HCR 0x32 host control register
P_CSF 0x33 chip select fast/slow
P_PTGAMODE 0x34 PTG A mode
P_PAB 0x35 PAB
P_PAUL 0x36 PAUL, PAB-PALL
P_PAULC 0x37 PAUL PAB-PALL clear download
P_SIOBUF 0x38 serial I/O buffers
P_SIE 0x39 serial interrupt enable
P_SMR 0x3A serial mode register
P_SLCR 0x3B serial line control register
P_SSR 0x3C serial status register
P_SFR 0x3D serial form register
P_SOUTD 0x3E SOUT (RxD) divider latch (R)
P_SIND 0x3F SIN (TxD) divider latch (R)
; Some Datapump register's - RC(V)288DPi
;DPi Rx/voice Rx buf (RBUFFER/VBUFR)
;DPi VOLUME/VPAUSE/CELULR/xXHF/RXP
;DPi TDE/SQDIS/V54/S511/DCD/CODBITS
;DPi EPT/SEPT/SRCEN/RLSDE/ARC/SDIS
;DPi RB/EQT2/V32BS/FIFOEN/EQFZ/NRZIEN
;DPi ECFZ/ECSQ/FECSQ/TXSQ/CEQ/TTDIS
;DPi RTDIS/EXOS/CF17/HDLC/PEN/STB
;DPi RDLE/RDL/L2ACT/DDIS/L3ACT/RA
;DPi ASYN/TPDM/V21S/V54T/V54A/V54P
;DPi NV25/CC/DTMF/ORG/LL/DATA/RRTSE
;DPi PNSUC/FLAGDT/PE/FE/OE/CRCS/VSYNC
;DPi TONEx/ATV25/ATBEL/DISDET/EQMAT
;DPi AADET/ACDET/CADET/CCDET/SDET
;DPi P2DET/PNDET/S1DET/SCR1/U1DET
;DPi RTDET/BRKD/RREDT/V32BDT/SPEED
;DPi RLSD/FED/CTS/DSR/RI/TM/RTSDT
;DPi Tx/voice Tx buf (TBUFFER/VBUFT)
;DPi BRKS/PARSL/TXV/RXV/V23HDX/TEOF
;DPi configuration (CONF)
;DPi TLVL/RTH/TXCLK
;DPi handshake abort code (ABCODE)
;DPi SLEEP/RDWK/HWRWK/AUTO/RREN/EXL3
;DPi sec Rx/V.34 Rx status (SECRXB)
;DPi sec Tx/V.34 Tx status (SECTXB)
;DPi memory access data LSB (MEDAL)
;DPi memory access data MSB (MEDAM)
;DPi SFRES/RIEN/RION/DMAE/SCOBF
;DPi EDET/DTDET/OTS/DTMFD/DTMF code
;DPi memory access addr LSB (MEADDL)
;DPi MEACC/MEMW/MEMCR/addr bits 8-11
;DPi TDBIA/RDBIA/TDBIE/TDBE/RDBIE
;DPi NSIA/NCIA/NSIE/NEWS/NCIE/NEWC
;

View File

@@ -0,0 +1,72 @@
/*
* Rockwell C39 processor module for IDA.
* Copyright (c) 2000-2006 Konstantin Norvatoff, <konnor@bk.ru>
* Freeware.
*/
#ifndef _C39_HPP
#define _C39_HPP
#include <ida.hpp>
#include <idp.hpp>
#include "../idaidp.hpp"
#define near
#define far
#include "ins.hpp"
#include "../iohandler.hpp"
// ============================================================
// aditional bits for specflags1 (specflag2 not used)
//-----------------------------------------------
// additional bits for memory access
#define URR_IND (0x01) // indirect via a register
//------------------------------------------------------------------------
// list of processor registers
#ifdef _MSC_VER
#define ENUM8BIT : uint8
#else
#define ENUM8BIT
#endif
enum C39_registers ENUM8BIT
{
rNULLReg,
rA,
rX, rY,
rVcs, rVds
};
//------------------------------------------------------------------------
int idaapi C39_ana(insn_t *insn);
int idaapi C39_emu(const insn_t &insn);
void idaapi C39_data(outctx_t &ctx, bool analyze_only);
//------------------------------------------------------------------------
struct c39_t : public procmod_t
{
netnode helper;
iohandler_t ioh = iohandler_t(helper);
bool flow = false; // stop flag
virtual ssize_t idaapi on_event(ssize_t msgid, va_list va) override;
void C39_header(outctx_t &ctx);
void handle_operand(
const insn_t &insn,
const op_t &x,
bool is_forced,
bool isload);
int C39_emu(const insn_t &insn);
void C39_segstart(outctx_t &ctx, segment_t *Sarea) const;
void C39_footer(outctx_t &ctx) const;
void load_from_idb();
};
extern int data_id;
#define PROCMOD_NODE_NAME "$ C39"
#define PROCMOD_NAME c39
#endif

View File

@@ -0,0 +1,98 @@
/*
* Rockwell C39 processor module for IDA.
* Copyright (c) 2000-2006 Konstantin Norvatoff, <konnor@bk.ru>
* Freeware.
*/
#include "c39.hpp"
//----------------------------------------------------------------------
// use/change of operands
void c39_t::handle_operand(
const insn_t &insn,
const op_t &x,
bool is_forced,
bool isload)
{
ea_t ea = map_code_ea(insn, x);
switch ( x.type )
{
case o_void:
break;
// nothing to do here
case o_reg:
break;
case o_imm:
if ( !isload )
goto badTouch;
set_immd(insn.ea);
if ( !is_forced && is_off(get_flags(insn.ea), x.n) )
insn.add_dref(ea, x.offb, dr_O); // offset!
break;
// jump or call
case o_near:
if ( has_insn_feature(insn.itype, CF_CALL) )
{
// add xref to code
insn.add_cref(ea, x.offb, fl_CN);
// is nonreturning function?
flow = func_does_return(ea);
}
else
{
insn.add_cref(ea, x.offb, fl_JN);
}
break;
// memory reference
case o_mem:
insn.create_op_data(ea, x);
insn.add_dref(ea, x.offb, isload ? dr_R : dr_W);
// add xref to the target address
if ( insn.itype == C39_jmp && x.dtype == dt_word && is_loaded(ea) )
{
ea_t callee = get_word(ea);
if ( callee > 32 && is_mapped(callee) ) // is good address?
{
add_cref(insn.ea, callee, fl_JN);
if ( !is_defarg0(get_flags(ea)) )
op_plain_offset(ea, 0, 0);
}
}
break;
default:
badTouch:
warning("%a %s,%d: bad optype %d",
insn.ea, insn.get_canon_mnem(ph),
x.n, x.type);
break;
}
}
//----------------------------------------------------------------------
int c39_t::C39_emu(const insn_t &insn)
{
uint32 Feature = insn.get_canon_feature(ph);
bool flag1 = is_forced_operand(insn.ea, 0);
bool flag2 = is_forced_operand(insn.ea, 1);
bool flag3 = is_forced_operand(insn.ea, 2);
flow = ((Feature & CF_STOP) == 0);
if ( Feature & CF_USE1) handle_operand(insn, insn.Op1, flag1, true);
if ( Feature & CF_USE2) handle_operand(insn, insn.Op2, flag2, true);
if ( Feature & CF_USE3) handle_operand(insn, insn.Op3, flag3, true);
if ( Feature & CF_JUMP )
remember_problem(PR_JUMP,insn.ea);
if ( Feature & CF_CHG1) handle_operand(insn, insn.Op1, flag1, false);
if ( Feature & CF_CHG2) handle_operand(insn, insn.Op2, flag2, false);
if ( Feature & CF_CHG3) handle_operand(insn, insn.Op3, flag3, false);
if ( flow )
add_cref(insn.ea, insn.ea+insn.size, fl_F);
return 1;
}

128
idasdk76/module/c39/ins.cpp Normal file
View File

@@ -0,0 +1,128 @@
/*
* Rockwell C39 processor module for IDA.
* Copyright (c) 2000-2006 Konstantin Norvatoff, <konnor@bk.ru>
* Freeware.
*/
#include "c39.hpp"
const instruc_t Instructions[] =
{
{ "", 0 },
{ "ADC", CF_USE1 },
{ "ADD", CF_USE1 },
{ "ANC", CF_USE1 },
{ "AND", CF_USE1 },
{ "ANE", CF_USE1 },
{ "ARR", CF_USE1 },
{ "ASL", 0 },
{ "ASR", CF_USE1 },
{ "BAR", CF_USE1|CF_USE2|CF_USE3 },
{ "BAS", CF_USE1|CF_USE2|CF_USE3 },
{ "BBR", CF_USE1|CF_USE2|CF_USE3|CF_JUMP },
{ "BBS", CF_USE1|CF_USE2|CF_USE3|CF_JUMP },
{ "BCC", CF_USE1|CF_JUMP },
{ "BCS", CF_USE1|CF_JUMP },
{ "BEQ", CF_USE1|CF_JUMP },
{ "BIT", CF_USE1 },
{ "BMI", CF_USE1|CF_JUMP },
{ "BNE", CF_USE1|CF_JUMP },
{ "BPL", CF_USE1|CF_JUMP },
{ "BRA", CF_USE1|CF_JUMP|CF_STOP },
{ "BRK", CF_STOP },
{ "BVC", CF_USE1|CF_JUMP },
{ "BVS", CF_USE1|CF_JUMP },
{ "CLC", 0 },
{ "CLD", 0 },
{ "CLI", 0 },
{ "CLV", 0 },
{ "CLW", 0 },
{ "CMP", CF_USE1 },
{ "CPX", CF_USE1 },
{ "CPY", CF_USE1 },
{ "DCP", CF_USE1|CF_CHG1 },
{ "DEC", CF_USE1|CF_CHG1 },
{ "DEX", 0 },
{ "DEY", 0 },
{ "EOR", CF_USE1 },
{ "EXC", CF_USE1 },
{ "INC", CF_USE1|CF_CHG1 },
{ "INI", 0 },
{ "INX", 0 },
{ "INY", 0 },
{ "ISB", CF_USE1|CF_CHG1 },
{ "JMP", CF_USE1|CF_STOP|CF_JUMP },
{ "JPI", CF_USE1|CF_STOP|CF_JUMP },
{ "JSB", CF_USE1|CF_CALL },
{ "JSR", CF_USE1|CF_CALL },
{ "LAB", CF_USE1 },
{ "LAE", CF_USE1 },
{ "LAI", 0 },
{ "LAN", 0 },
{ "LAX", CF_USE1 },
{ "LDA", CF_USE1 },
{ "LDX", CF_USE1 },
{ "LDY", CF_USE1 },
{ "LII", 0 },
{ "LSR", 0 },
{ "LXA", CF_USE1 },
{ "MPA", 0 },
{ "MPY", 0 },
{ "NEG", CF_USE1 },
{ "NOP", 0 },
{ "NXT", 0 },
{ "ORA", CF_USE1 },
{ "PHA", 0 },
{ "PHI", 0 },
{ "PHP", 0 },
{ "PHW", 0 },
{ "PHX", 0 },
{ "PHY", 0 },
{ "PIA", 0 },
{ "PLA", 0 },
{ "PLI", 0 },
{ "PLP", 0 },
{ "PLW", 0 },
{ "PLX", 0 },
{ "PLY", 0 },
{ "PSH", 0 },
{ "PUL", 0 },
{ "RBA", CF_USE1|CF_USE2 },
{ "RLA", CF_USE1|CF_CHG1 },
{ "RMB", CF_USE1|CF_USE2 },
{ "RND", 0 },
{ "ROL", 0 },
{ "ROR", 0 },
{ "RRA", CF_USE1|CF_CHG1 },
{ "RTI", CF_STOP },
{ "RTS", CF_STOP },
{ "SAX", CF_CHG1 },
{ "SBA", CF_USE1|CF_USE2 },
{ "SBC", CF_USE1 },
{ "SBX", CF_USE1 },
{ "SEC", 0 },
{ "SED", 0 },
{ "SEI", 0 },
{ "SHA", CF_CHG1 },
{ "SHS", CF_CHG1 },
{ "SHX", CF_CHG1 },
{ "SHY", CF_CHG1 },
{ "SLO", CF_USE1|CF_CHG1 },
{ "SMB", CF_USE1|CF_USE2|CF_CHG2 },
{ "SRE", CF_USE1|CF_CHG1 },
{ "STA", CF_CHG1 },
{ "STI", CF_USE1|CF_USE2 },
{ "STX", CF_CHG1 },
{ "STY", CF_CHG1 },
{ "TAX", 0 },
{ "TAY", 0 },
{ "TAW", 0 },
{ "TIP", 0 },
{ "TSX", 0 },
{ "TWA", 0 },
{ "TXA", 0 },
{ "TXS", 0 },
{ "TYA", 0 }
};
CASSERT(qnumber(Instructions) == C39_last);

134
idasdk76/module/c39/ins.hpp Normal file
View File

@@ -0,0 +1,134 @@
/*
* Rockwell C39 processor module for IDA.
* Copyright (c) 2000-2006 Konstantin Norvatoff, <konnor@bk.ru>
* Freeware.
*/
#ifndef __INSTRS_HPP
#define __INSTRS_HPP
// List of instructions
extern const instruc_t Instructions[];
//
enum nameNum ENUM_SIZE(uint16)
{
C39_null = 0, // Unknown Operation
C39_adc,
C39_add,
C39_anc,
C39_and,
C39_ane,
C39_arr,
C39_asl,
C39_asr,
C39_bar,
C39_bas,
C39_bbr,
C39_bbs,
C39_bcc,
C39_bcs,
C39_beq,
C39_bit,
C39_bmi,
C39_bne,
C39_bpl,
C39_bra,
C39_brk,
C39_bvc,
C39_bvs,
C39_clc,
C39_cld,
C39_cli,
C39_clv,
C39_clw,
C39_cmp,
C39_cpx,
C39_cpy,
C39_dcp,
C39_dec,
C39_dex,
C39_dey,
C39_eor,
C39_exc,
C39_inc,
C39_ini,
C39_inx,
C39_iny,
C39_isb,
C39_jmp,
C39_jpi,
C39_jsb,
C39_jsr,
C39_lab,
C39_lae,
C39_lai,
C39_lan,
C39_lax,
C39_lda,
C39_ldx,
C39_ldy,
C39_lii,
C39_lsr,
C39_lxa,
C39_mpa,
C39_mpy,
C39_neg,
C39_nop,
C39_nxt,
C39_ora,
C39_pha,
C39_phi,
C39_php,
C39_phw,
C39_phx,
C39_phy,
C39_pia,
C39_pla,
C39_pli,
C39_plp,
C39_plw,
C39_plx,
C39_ply,
C39_psh,
C39_pul,
C39_rba,
C39_rla,
C39_rmb,
C39_rnd,
C39_rol,
C39_ror,
C39_rra,
C39_rti,
C39_rts,
C39_sax,
C39_sba,
C39_sbc,
C39_sbx,
C39_sec,
C39_sed,
C39_sei,
C39_sha,
C39_shs,
C39_shx,
C39_shy,
C39_slo,
C39_smb,
C39_sre,
C39_sta,
C39_sti,
C39_stx,
C39_sty,
C39_tax,
C39_tay,
C39_taw,
C39_tip,
C39_tsx,
C39_twa,
C39_txa,
C39_txs,
C39_tya,
C39_last
};
#endif

View File

@@ -0,0 +1,57 @@
PROC=c39
CONFIGS=c39.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 c39.hpp ins.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 \
c39.hpp emu.cpp ins.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 \
c39.hpp ins.cpp ins.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 \
c39.hpp ins.hpp out.cpp
$(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)segregs.hpp $(I)ua.hpp $(I)xref.hpp ../idaidp.hpp \
../iohandler.hpp c39.hpp ins.hpp reg.cpp

171
idasdk76/module/c39/out.cpp Normal file
View File

@@ -0,0 +1,171 @@
/*
* Rockwell C39 processor module for IDA.
* Copyright (c) 2000-2006 Konstantin Norvatoff, <konnor@bk.ru>
* Freeware.
*/
#include "c39.hpp"
//----------------------------------------------------------------------
class out_C39_t : public outctx_t
{
out_C39_t(void) = delete; // not used
public:
void OutVarName(const op_t &x);
bool out_operand(const op_t &x);
void out_insn(void);
};
CASSERT(sizeof(out_C39_t) == sizeof(outctx_t));
DECLARE_OUT_FUNCS_WITHOUT_OUTMNEM(out_C39_t)
//----------------------------------------------------------------------
void out_C39_t::OutVarName(const op_t &x)
{
ea_t toea = map_code_ea(insn, x);
if ( !out_name_expr(x, toea, x.addr) )
{
out_value(x, OOF_ADDR | OOF_NUMBER | OOFS_NOSIGN | OOFW_32);
remember_problem(PR_NONAME, insn.ea);
}
}
//----------------------------------------------------------------------
bool out_C39_t::out_operand(const op_t &x)
{
switch ( x.type )
{
case o_reg:
out_register(ph.reg_names[x.reg]);
break;
case o_imm:
out_symbol('#');
refinfo_t ri;
// micro bug-fix
if ( get_refinfo(&ri, insn.ea, x.n) )
{
if ( ri.flags == REF_OFF16 )
{
set_refinfo(insn.ea, x.n,
REF_OFF32, ri.target, ri.base, ri.tdelta);
// msg("Exec OFF16_Op Fix AT:%a Flags=%x, Target=%a, Base=%a, Delta=%a\n",
// insn.ea,
// ri.flags,ri.target,ri.base,ri.tdelta);
}
}
out_value(x, /*OOFS_NOSIGN | */ OOF_SIGNED | OOFW_IMM);
break;
case o_near:
OutVarName(x);
break;
case o_mem:
if ( x.specflag1&URR_IND )
out_symbol('(');
out_value(x, OOFS_NOSIGN | OOFW_IMM);
if ( x.specflag1&URR_IND )
out_symbol(')');
break;
case o_void:
return 0;
default:
INTERR(10133);
}
return 1;
}
//----------------------------------------------------------------------
void out_C39_t::out_insn(void)
{
out_mnemonic();
if ( insn.Op1.type != o_void )
out_one_operand(0);
if ( insn.Op2.type != o_void )
{
out_symbol(',');
out_char(' ');
out_one_operand(1);
if ( insn.Op3.type != o_void )
{
out_symbol(',');
out_char(' ');
out_one_operand(2);
}
}
out_immchar_cmts();
flush_outbuf();
}
//--------------------------------------------------------------------------
void c39_t::C39_header(outctx_t &ctx)
{
ctx.gen_header(GH_PRINT_ALL_BUT_BYTESEX, ioh.device.c_str(), ioh.deviceparams.c_str());
}
//--------------------------------------------------------------------------
//lint -esym(1764, ctx) could be made const
//lint -esym(818, Sarea) could be made const
void c39_t::C39_segstart(outctx_t &ctx, segment_t *Sarea) const
{
const char *SegType = Sarea->type == SEG_CODE ? "CSEG"
: Sarea->type == SEG_DATA ? "DSEG"
: "RSEG";
// RSEG <NAME>
qstring sn;
get_visible_segm_name(&sn, Sarea);
ctx.gen_printf(-1,"%s %s ",SegType, sn.c_str());
// if non-zero offset (ORG XXXX)
if ( (inf_get_outflags() & OFLG_GEN_ORG) != 0 )
{
ea_t org = ctx.insn_ea - get_segm_base(Sarea);
if ( org != 0 )
{
char bufn[MAX_NUMBUF];
btoa(bufn, sizeof(bufn), org);
ctx.gen_printf(-1, "%s %s", ash.origin, bufn);
}
}
}
//--------------------------------------------------------------------------
void c39_t::C39_footer(outctx_t &ctx) const
{
if ( ash.end != NULL )
{
ctx.gen_empty_line();
ctx.out_line(ash.end, COLOR_ASMDIR);
qstring name;
if ( get_colored_name(&name, inf_get_start_ea()) > 0 )
{
size_t i = strlen(ash.end);
do
ctx.out_char(' ');
while ( ++i < 8 );
ctx.out_line(name.begin());
}
ctx.flush_outbuf(DEFAULT_INDENT);
}
else
{
ctx.gen_cmt_line("end of file");
}
}
//--------------------------------------------------------------------------
void idaapi C39_data(outctx_t &ctx, bool analyze_only)
{
ea_t ea = ctx.insn_ea;
// micro bug-fix
refinfo_t ri;
if ( get_refinfo(&ri, ea, 0) && ri.flags == REF_OFF16 )
set_refinfo(ea, 0, REF_OFF32, ri.target, ri.base, ri.tdelta);
ctx.out_data(analyze_only);
}

242
idasdk76/module/c39/reg.cpp Normal file
View File

@@ -0,0 +1,242 @@
/*
* Rockwell C39 processor module for IDA.
* Copyright (c) 2000-2006 Konstantin Norvatoff, <konnor@bk.ru>
* Freeware.
*/
#include "c39.hpp"
#include <diskio.hpp>
#include <segregs.hpp>
int data_id;
//--------------------------------------------------------------------------
static const char *const RegNames[] =
{
// empty place
"",
// general registers
"A","X","Y",
// pseudo-segment registers
"cs","ds"
};
//----------------------------------------------------------------------
void c39_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(c39_t));
return 0;
}
//----------------------------------------------------------------------
ssize_t idaapi c39_t::on_event(ssize_t msgid, va_list va)
{
switch ( msgid )
{
case processor_t::ev_init:
inf_set_gen_lzero(true);
helper.create(PROCMOD_NODE_NAME);
break;
case processor_t::ev_term:
ioh.ports.clear();
clr_module_data(data_id);
break;
case processor_t::ev_newfile:
{
char cfgfile[QMAXFILE];
ioh.get_cfg_filename(cfgfile, sizeof(cfgfile));
iohandler_t::parse_area_line0_t cb(ioh);
if ( choose_ioport_device2(&ioh.device, cfgfile, &cb) )
ioh.set_device_name(ioh.device.c_str(), IORESP_ALL);
}
break;
case processor_t::ev_ending_undo:
case processor_t::ev_oldfile:
load_from_idb();
break;
case processor_t::ev_creating_segm:
{
segment_t *s = va_arg(va, segment_t *);
// Set default value of DS register for all segments
set_default_dataseg(s->sel);
}
break;
case processor_t::ev_out_header:
{
outctx_t *ctx = va_arg(va, outctx_t *);
C39_header(*ctx);
return 1;
}
case processor_t::ev_out_footer:
{
outctx_t *ctx = va_arg(va, outctx_t *);
C39_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 *);
C39_segstart(*ctx, seg);
return 1;
}
case processor_t::ev_ana_insn:
{
insn_t *out = va_arg(va, insn_t *);
return C39_ana(out);
}
case processor_t::ev_emu_insn:
{
const insn_t *insn = va_arg(va, const insn_t *);
return C39_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_out_data:
{
outctx_t *ctx = va_arg(va, outctx_t *);
bool analyze_only = va_argi(va, bool);
C39_data(*ctx, analyze_only);
return 1;
}
default:
break;
}
return 0;
}
//-----------------------------------------------------------------------
// PseudoSam
//-----------------------------------------------------------------------
static const asm_t pseudosam =
{
AS_COLON | AS_UDATA | ASH_HEXF3 | ASD_DECF0,
0,
"Generic C39 assembler", // Assembler name
0, // Help screen number, 0 - no help
NULL, // array of automatically generated header lines
"org", // ORG
"end", // end
";", // comment
'"', // string literal delimiter
'\'', // char constant delimiter
"\\\"'", // special chars that cannot appear
"db", // ascii string directive
".DATA.B", // byte directive
".DATA.W", // word directive
".DATA.L", // dword (4 bytes)
NULL, // qword (8 bytes)
NULL, // oword (16 bytes)
NULL, // float (4 bytes)
NULL, // double (8 bytes)
NULL, // tbyte (10/12 bytes)
NULL, // packed decimal real
"#d dup(#v)", // arrays (#h,#d,#v,#s(...)
"db ?", // uninited arrays
".equ", // equ
NULL, // seg prefix
"$", // current IP
NULL, // Generate function header lines
NULL, // Generate function footer lines
NULL, // public
NULL, // weak
NULL, // extrn
NULL, // comm
NULL, // Get name of type of item at ea or id
".ALIGN", // align
'(', ')', // lbrace, rbrace
NULL, // mod
NULL, // and
NULL, // or
NULL, // xor
NULL, // not
NULL, // shl
NULL, // shr
NULL, // sizeof
};
static const asm_t *const asms[] = { &pseudosam, NULL };
//-----------------------------------------------------------------------
#define FAMILY "Rockwell C39:"
static const char *const shnames[] = { "C39", NULL };
static const char *const lnames[] = { FAMILY"Rockwell C39", NULL };
//--------------------------------------------------------------------------
static const uchar retcode_1[] = { 0x00, 0x0B }; // RTS
static const bytes_t retcodes[] =
{
{ sizeof(retcode_1), retcode_1 },
{ 0, NULL }
};
//-----------------------------------------------------------------------
// Processor Definition
//-----------------------------------------------------------------------
processor_t LPH =
{
IDP_INTERFACE_VERSION, // version
PLFM_C39, // processor's id
// flag
PR_USE32
| PR_BINMEM
| PR_SEGTRANS,
// flag2
0,
8, // 8 bits in a byte for code segments
8, // 8 bits in a byte
shnames, // short processor names
lnames, // long processor names
asms, // assembler definitions
notify, // Event notification handler
RegNames, // Regsiter names
qnumber(RegNames), // Number of registers
rVcs,rVds,
2, // size of a segment register
rVcs,rVds,
NULL, // typical code start sequences
retcodes, // 'return' instruction opcodes
0,C39_last, // icode of the first and the last instruction
Instructions, // instruc
3, // Size of long double (tbyte) - 24 bits
{0,0,0,0}, // Number of digits in floating numbers after the decimal point
0, // Icode of return instruction
NULL, // Reserved, currently equals to NULL
};