Beispiel #1
0
//----------------------------------------------------------------------
void out(void)
{
char buf[MAXSTR];

init_output_buffer(buf, sizeof(buf)); // setup the output pointer
OutMnem();                            // output instruction mnemonics

out_one_operand(0);                   // output the first operand

//Вывод операнда
if(cmd.Op2.type != o_void)
  {
  out_symbol(',');//вывод разделителя между операндами
  //если неуказан флаг UAS_NOSPA ставим пробел
  if(!(ash.uflag & UAS_NOSPA)) OutChar(' ');
  out_one_operand(1);
  }

if(cmd.Op3.type != o_void)
  {
  out_symbol(',');
  if(!(ash.uflag & UAS_NOSPA)) OutChar(' ');
  out_one_operand(2);
  }

if(isVoid(cmd.ea, uFlag, 0)) OutImmChar(cmd.Op1);
if(isVoid(cmd.ea, uFlag, 1)) OutImmChar(cmd.Op2);
if(isVoid(cmd.ea, uFlag, 2)) OutImmChar(cmd.Op3);

term_output_buffer();

gl_comm = 1;
MakeLine(buf);
}
Beispiel #2
0
void out( void )
{
    char buf[MAXSTR];

    init_output_buffer(buf, sizeof(buf));
    OutMnem();

    out_one_operand( 0 );

    if( cmd.Op2.type != o_void )
    {
        out_symbol( ',' );
        OutChar( ' ' );
        out_one_operand( 1 );
    }

    if( cmd.Op3.type != o_void )
    {
        out_symbol( ',' );
        OutChar( ' ' );
        out_one_operand( 2 );
    }

    if( isVoid( cmd.ea, uFlag, 0 ) )    OutImmChar( cmd.Op1 );
    if( isVoid( cmd.ea, uFlag, 1 ) )    OutImmChar( cmd.Op2 );
    if( isVoid( cmd.ea, uFlag, 2 ) )    OutImmChar( cmd.Op3 );

    term_output_buffer();
    gl_comm = 1;
    MakeLine( buf );
}
Beispiel #3
0
// outputs an instruction
void idaapi out(void) {
    char buf[MAXSTR];

    init_output_buffer(buf, sizeof(buf));

    OutMnem();
    out_one_operand(0);        // output the first operand

    if ( cmd.Op2.type != o_void ) {
        out_symbol(',');
        OutChar(' ');
        out_one_operand(1);
    }

    if ( cmd.Op3.type != o_void ) {
        out_symbol(',');
        OutChar(' ');
        out_one_operand(2);
    }

    // output a character representation of the immediate values
    // embedded in the instruction as comments
    if ( isVoid(cmd.ea,uFlag,0)) OutImmChar(cmd.Op1 );
    if ( isVoid(cmd.ea,uFlag,1)) OutImmChar(cmd.Op2 );
    if ( isVoid(cmd.ea,uFlag,2)) OutImmChar(cmd.Op3 );

    term_output_buffer();                   // terminate the output string
    gl_comm = 1;                            // ask to attach a possible user-
                                            // defined comment to it
    MakeLine(buf);                          // pass the generated line to the
                                            // kernel
}
Beispiel #4
0
//----------------------------------------------------------------------
void idaapi out(void)
{
  char buf[MAXSTR];
  init_output_buffer(buf, sizeof(buf));

  // output instruction mnemonics
  char postfix[4];
  postfix[0] = '\0';

  OutMnem(8, postfix);

  bool comma = out_one_operand(0);
  if ( cmd.Op2.type != o_void )
  {
    if ( comma ) out_symbol(',');
    out_one_operand(1);
  }
  if ( cmd.Op3.type != o_void )
  {
    out_symbol(',');
    out_one_operand(2);
  }


  if ( isVoid(cmd.ea, uFlag, 0) ) OutImmChar(cmd.Op1);
  if ( isVoid(cmd.ea, uFlag, 1) ) OutImmChar(cmd.Op2);
  if ( isVoid(cmd.ea, uFlag, 3) ) OutImmChar(cmd.Op3);

  term_output_buffer();

  gl_comm = 1;
  MakeLine(buf);
}
Beispiel #5
0
//----------------------------------------------------------------------
static void outmem(op_t &x, ea_t ea)
{
  char buf[MAXSTR];
  if ( get_name_expr(cmd.ea+x.offb, x.n, ea, BADADDR, buf, sizeof(buf)) <= 0 )
  {
    const ioport_t *p = find_sym(x.addr);
    if ( p == NULL )
    {
      out_tagon(COLOR_ERROR);
      OutLong(x.addr, 16);
      out_tagoff(COLOR_ERROR);
      QueueMark(Q_noName,cmd.ea);
    }
    else
    {
      out_line(p->name, COLOR_IMPNAME);
    }
  }
  else
  {
    bool complex = strchr(buf, '+') || strchr(buf, '-');
    if ( complex ) out_symbol(ash.lbrace);
    OutLine(buf);
    if ( complex ) out_symbol(ash.rbrace);
  }
}
Beispiel #6
0
// Output an instruction
void out(void) {

    //
    // print insn mnemonic
    //

    char buf[MAXSTR];
    init_output_buffer(buf, sizeof(buf));

    char postfix[5];
    postfix[0] = '\0';

    if ( is_jmp_cc(cmd.itype) )
        qstrncpy(postfix, ConditionCodes[cmd.auxpref], sizeof(postfix));

    OutMnem(8, postfix);

    //
    // print insn operands
    //

    out_one_operand(0);        // output the first operand

    if ( cmd.Op2.type != o_void ) {
        out_symbol(',');
        OutChar(' ');
        out_one_operand(1);
    }

    if ( cmd.Op3.type != o_void ) {
        out_symbol(',');
        OutChar(' ');
        out_one_operand(2);
    }

    // output a character representation of the immediate values
    // embedded in the instruction as comments
    if ( isVoid(cmd.ea,uFlag,0)) OutImmChar(cmd.Op1 );
    if ( isVoid(cmd.ea,uFlag,1)) OutImmChar(cmd.Op2 );
    if ( isVoid(cmd.ea,uFlag,2)) OutImmChar(cmd.Op3 );

    if ( gr_cmt != NULL ) {
        OutChar(' ');
        out_line(ash.cmnt, COLOR_AUTOCMT);
        OutChar(' ');
        out_line(gr_cmt, COLOR_AUTOCMT);
        if ( ash.cmnt2 != NULL ) {
            OutChar(' ');
            out_line(ash.cmnt2, COLOR_AUTOCMT);
        }
        gr_cmt = NULL;
    }

    term_output_buffer();                   // terminate the output string
    gl_comm = 1;                            // ask to attach a possible user-
                                            // defined comment to it
    MakeLine(buf);                          // pass the generated line to the
                                            // kernel
}
Beispiel #7
0
//----------------------------------------------------------------------
bool outop(op_t &op)
{
  switch ( op.type )
  {
    case o_void:
      return 0;

    case o_reg:
      out_operators_begin(op);
      out_reg(op);
      out_symbol_shift(op, false);
      out_operators_end(op);
      out_symbol_shift(op, true);
      break;

    case o_relop:
      out_relop(op);
      break;

    case o_shift:
      out_shift(op.value);
      break;

    case o_imm:
      if (op.tms_prefix == 0)
        out_symbol('#');
      else
        out_symbol(op.tms_prefix);
      if (op.tms_signed)
        OutValue(op, OOFS_IFSIGN|OOF_SIGNED|OOFW_IMM);
      else
        OutValue(op, OOFW_IMM);
      out_symbol_shift(op);
      break;

    case o_near:
      out_address(op);
      break;

    case o_mem:
    case o_io:
      out_operators_begin(op);
      out_address(op);
      out_symbol_shift(op, false);
      out_operators_end(op);
      out_symbol_shift(op, true);
      break;

    case o_cond:
      out_cond(op);
      break;

    default:
      error("interr: out");
      break;
  }
  return 1;
}
Beispiel #8
0
//----------------------------------------------------------------------
bool idaapi outop(op_t &x)
{
  ea_t ea;
  if ( x.type == o_imm )
    out_symbol('#');
  char buf[MAXSTR];

  switch ( x.type )
  {
    case o_void:
      return 0;

    case o_imm:
      OutValue(x, OOFS_IFSIGN|OOFW_IMM);
      break;

    case o_reg:
      outreg(x.reg);

      break;

    case o_mem:
      // no break;
    case o_near:
      {
        ea = calc_mem(x);
        if ( ea == cmd.ea+cmd.size )
          out_ip_rel(cmd.size);
        else if ( !out_name_expr(x, ea, x.addr) )
          out_bad_address(x.addr);
      }
      break;

    case o_phrase:
      {
       qsnprintf(buf, sizeof(buf), "%%%c%" FMT_EA "x", 'a' + x.reg, x.value);

       ea = calc_data_mem(x, as + x.reg);
       if ( ( ea != BADADDR ) && ( ( x.reg != SR3 ) || ( x.value < 6 ) ) )
       {
           out_line(buf, COLOR_AUTOCMT);
           out_symbol(' ');
           out_address(ea, x);
        }
       else
           out_line(buf, COLOR_REG);

      }
      break;

    default:
      interr("out");
      break;
  }
  return 1;
}
Beispiel #9
0
//----------------------------------------------------------------------
// generate a text representation of an instruction
// the information about the instruction is in the 'cmd' structure
void idaapi out(void) {
  char buf[MAXSTR];

  // setup the output pointer
  init_output_buffer(buf, sizeof(buf));

  // output instruction mnemonics
  OutMnem();

  // check for JP/JR instruction with condition code
  // add the condition on as a pseudo operand if present
  if ((cmd.itype == SAM8_JR) ||
      ((cmd.itype == SAM8_JP) && (cmd.c_condition != ccNone))) {
    // sanity check
    if (cmd.c_condition >= cc_last) {
      warning("%a (%s): Internal error: bad condition code %i",
              cmd.ea, cmd.get_canon_mnem(), cmd.c_condition);
      return;
    }

    // output the condition code normally
    out_keyword(ccNames[cmd.c_condition]);
    out_symbol(',');
    OutChar(' ');
  }

  // output the first operand
  if (cmd.Op1.type != o_void) {
    out_one_operand(0);
  }

  // output the second operand
  if (cmd.Op2.type != o_void) {
    out_symbol(',');
    OutChar(' ');
    out_one_operand(1);
  }

  // output the third operand
  if (cmd.Op3.type != o_void) {
    out_symbol(',');
    OutChar(' ');
    out_one_operand(2);
  }

  // terminate the output string
  term_output_buffer();

  // ask to attach a possible user-defined comment to it
  gl_comm = 1;

  // pass the generated line to the kernel
  MakeLine(buf);
}
Beispiel #10
0
// output an operand
bool idaapi outop(op_t &op) {
    switch ( op.type ) {
        // register
        case o_reg:
            outreg(op.reg);
            break;

        // immediate
        case o_imm:
            if ( (op.specflag1 & OP_IMM_BIT) == 0 )
              out_symbol('#');
            OutValue(op, OOFW_IMM);
            break;

        // data / code memory address
        case o_near:
        case o_mem:
            outaddr(op);
            break;

        // displ
        case o_displ:
            outdispl();
            break;

        // ignore void operands
        case o_void:
            break;

        default:
            INTERR(10024);
    }
    return 1;
}
Beispiel #11
0
static void out_reglist(op_t &op) {
    static const uint16 regs_ldm0[] = { rR7,  rR6,  rR5,  rR4,  rR3,  rR2,  rR1,  rR0  };
    static const uint16 regs_stm0[] = { rR0,  rR1,  rR2,  rR3,  rR4,  rR5,  rR6,  rR7  };
    static const uint16 regs_ldm1[] = { rR15, rR14, rR13, rR12, rR11, rR10, rR9,  rR8  };
    static const uint16 regs_stm1[] = { rR8,  rR9,  rR10, rR11, rR12, rR13, rR14, rR15 };
    const uint16 *regs;
    bool left;

    switch ( cmd.itype ) {
        case fr_ldm0:   regs = regs_ldm0; left = false; break;
        case fr_stm0:   regs = regs_stm0; left = true;  break;
        case fr_ldm1:   regs = regs_ldm1; left = false; break;
        case fr_stm1:   regs = regs_stm1; left = true;  break;
        default:
            INTERR(10018);
    }

    print_comma = false;

    out_symbol('(');
    if ( left ) {
        for (int i = 0, bit = 128; bit != 0; bit >>= 1, i++)
            out_reg_if_bit(regs[i], op.value, bit);
    }
    else {
        for (int i = 7, bit = 1; bit <= 128; bit <<= 1, i--)
Beispiel #12
0
	/* outputs an operand 'x' */
bool outop(op_t &x)
{
// const char *ptr;
  ea_t v;
	switch (x.type)
	{
	case o_reg:
		out_register(ph.regNames[x.reg]);
		break;
	case o_imm:
		OutValue(x, OOFS_IFSIGN | OOFW_IMM);
		break;
	case o_mem:
	case o_near:
		v=toEA(cmd.cs, x.addr);
		if ( !out_name_expr(x, v, x.addr) )
		{
			OutValue(x, OOF_ADDR | OOF_NUMBER | OOFS_NOSIGN | OOFW_32);
			QueueMark(Q_noName, cmd.ea);
			break;
		}
		break;
	default:
		out_symbol('?');
		break;
	}
	return 1;
}
Beispiel #13
0
//----------------------------------------------------------------------
void out(void)
{
  char buf[MAXSTR];
  // output .org for enties without any labels
  if ( !has_any_name(uFlag) && helper.altval(cmd.ea) )
  {
    btoa(buf, sizeof(buf), cmd.ip);
    printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.origin, buf);
  }

  init_output_buffer(buf, sizeof(buf));

  OutMnem();

  out_one_operand(0);
  if ( cmd.Op2.type != o_void )
  {
    out_symbol(',');
    OutChar(' ');
    out_one_operand(1);
  }

  if ( isVoid(cmd.ea, uFlag, 0) ) OutImmChar(cmd.Op1);
  if ( isVoid(cmd.ea, uFlag, 1) ) OutImmChar(cmd.Op2);

  term_output_buffer();

  gl_comm = 1;
  MakeLine(buf);
}
Beispiel #14
0
static void out_shift(int value)
{
  out_symbol('#');
  char buf[8];
  qsnprintf(buf, sizeof(buf), "%d", value);
  out_line(buf,COLOR_DNUM);
}
Beispiel #15
0
static void out_relop(op_t &op)
{
  out_register(ph.regNames[op.reg]);

  char *relop;
  switch(op.tms_relop)
  {
    case 0:
      relop = " == ";
      break;
    case 1:
      relop = " < ";
      break;
    case 2:
      relop = " >= ";
      break;
    case 3:
      relop = " != ";
      break;
    default:
      error("interr: out: o_relop");
  }
  out_line(relop, COLOR_SYMBOL);

  switch(op.tms_relop_type)
  {
    case TMS_RELOP_REG:
      out_register(ph.regNames[int(op.value)]);
      break;
    case TMS_RELOP_IMM:
      out_symbol('#');
      OutValue(op, OOFS_IFSIGN|OOF_SIGNED|OOF_NUMBER|OOFW_IMM);
      break;
  }
}
Beispiel #16
0
//----------------------------------------------------------------------
// основная выводилка команд
void N78K_out(void)
{
  char buf[MAXSTR];
#if IDP_INTERFACE_VERSION > 37
   init_output_buffer(buf, sizeof(buf)); // setup the output pointer
#else
  uFlag = getFlags(cmd.ea);
   u_line = buf;
#endif
   // выведем мнемонику
   OutMnem();

   // выведем первый операнд
   if(cmd.Op1.type!=o_void)out_one_operand(0);
   // выведем второй операнд
   if(cmd.Op2.type != o_void) {
     out_symbol(',');
     OutChar(' ');
     out_one_operand(1);
   }
   // выведем непосредственные данные, если они есть
   if(isVoid(cmd.ea, uFlag, 0)) OutImmChar(cmd.Op1);
   if(isVoid(cmd.ea, uFlag, 1)) OutImmChar(cmd.Op2);
#if IDP_INTERFACE_VERSION > 37
   term_output_buffer();
#else
  *u_line = '\0';
#endif
   gl_comm = 1;
   MakeLine(buf);
}
Beispiel #17
0
//----------------------------------------------------------------------
void out(void)
{
  char buf[MAXSTR];
  init_output_buffer(buf, sizeof(buf));

  const char *postfix = NULL;
       if ( cmd.auxpref & aux_byte ) postfix = ".b";
  else if ( cmd.auxpref & aux_word ) postfix = ".w";
  else if ( cmd.auxpref & aux_f    ) postfix = "/f";
  else if ( cmd.auxpref & aux_ne   ) postfix = "/ne";
  else if ( cmd.auxpref & aux_eq   ) postfix = "/eq";
  OutMnem(8, postfix);

  out_one_operand(0);
  if ( cmd.Op2.type != o_void )
  {
    out_symbol(',');
    OutChar(' ');
    out_one_operand(1);
  }

  if ( isVoid(cmd.ea, uFlag, 0) ) OutImmChar(cmd.Op1);
  if ( isVoid(cmd.ea, uFlag, 1) ) OutImmChar(cmd.Op2);

  term_output_buffer();
  gl_comm = 1;
  MakeLine(buf);
}
Beispiel #18
0
//----------------------------------------------------------------------
uchar chkOutSymbol(char c)
{
  if ( !checkLine(1)) return(1 );
  ++outcnt;
  out_symbol(c);
  return(0);
}
Beispiel #19
0
//----------------------------------------------------------------------
static void out_address(ea_t ea, op_t &x, bool mapping, bool at)
{
  regnum_t reg = get_mapped_register(ea);
  if ( mapping && reg != rnone) out_register(ph.regNames[reg] );
  else
  {
#ifndef TMS320C54_NO_NAME_NO_REF
    char buf[MAXSTR];
    // since tms320c54 uses memory mapping, we turn off verification
    // of name expression values (3d arg of get_name_expr is BADADDR)
    if ( get_name_expr(cmd.ea+x.offb, x.n, ea, BADADDR, buf, sizeof(buf)) > 0 )
    {
      if ( at)
        out_symbol('@' );
      OutLine(buf);
    }
    else
#endif
    {
      out_tagon(COLOR_ERROR);
      OutValue(x, OOFW_IMM|OOF_ADDR);
      out_tagoff(COLOR_ERROR);
      QueueMark(Q_noName, cmd.ea);
    }
  }
}
Beispiel #20
0
//----------------------------------------------------------------------
void out(void)
{
  char buf[MAXSTR];
  init_output_buffer(buf, sizeof(buf));

  int op;

  if (!(cmd.SpecialModes & TMS_MODE_USER_PARALLEL))
  {
    if ((cmd.SpecialModes & TMS_MODE_LR) || (cmd.SpecialModes & TMS_MODE_CR))
    {
      out_line(cmd.get_canon_mnem(), COLOR_INSN);
      out_line((cmd.SpecialModes & TMS_MODE_LR) ? ".lr ":".cr ", COLOR_INSN);
    }
    else
      OutMnem();
  }
  else
  { // user-defined parallelism
    out_line("|| ", COLOR_INSN);
    out_line(cmd.get_canon_mnem(), COLOR_INSN);
    out_line(" ", COLOR_INSN);
  }

  for (op = 0; op < UA_MAXOP; op++)
  {
    if (cmd.Operands[op].type == o_void) break;
    if (op != 0) // not the first operand
    {
      if (cmd.Parallel != TMS_PARALLEL_BIT && op == cmd.Parallel) // multi-line instruction
      {
        term_output_buffer();
        MakeLine(buf);
        // print the second instruction line
        init_output_buffer(buf, sizeof(buf));
        if (cmd.SpecialModes & TMS_MODE_SIMULATE_USER_PARALLEL)
          out_line("|| ", COLOR_INSN);
        else
          out_line(":: ", COLOR_INSN);
        const char *insn2 = cmd.get_canon_mnem();
        insn2 += strlen(insn2);
        insn2++;
        out_line(insn2, COLOR_INSN);
      }
      else
        out_symbol(',');
      OutChar(' ');
    }
    // print the operand
    out_one_operand(op);
  }

  // print immediate values
  for (op = 0; op < UA_MAXOP; op++)
    if ( isVoid(cmd.ea, uFlag, op) ) OutImmChar(cmd.Operands[op]);

  term_output_buffer();
  gl_comm = 1;
  MakeLine(buf);
}
//----------------------------------------------------------------------
bool chkOutSymbol(char c)
{
  if ( !checkLine(1) )
    return true;
  ++outcnt;
  out_symbol(c);
  return false;
}
Beispiel #22
0
//----------------------------------------------------------------------
uchar chkOutSymSpace(char c)
{
  if ( !checkLine(2)) return(1 );
  out_symbol(c);
  OutChar(' ');
  outcnt += 2;
  return(0);
}
Beispiel #23
0
// output a displacement
static void outdispl(void) {
    if ( is_displ_indx() ) {
        out_symbol('(');
        outaddr(cmd.Op1, false);
        out_symbol(',');
        if ( !(ash.uflag & UAS_INDX_NOSPACE)) OutChar(' ' );
        outreg(cmd.Op1.reg);
        out_symbol(')');
        return;
    }
    if ( is_displ_indy() ) {
        out_symbol('(');
        outaddr(cmd.Op1, false);
        out_symbol(')');
        out_symbol(',');
        OutChar(' ');
        outreg(cmd.Op1.reg);
        return;
    }
    if ( is_displ_zpx() || is_displ_zpy() || is_displ_absx() || is_displ_absy() ) {
        outaddr(cmd.Op1, false);
        out_symbol(',');
        OutChar(' ');
        outreg(cmd.Op1.reg);
        return;
    }
    INTERR(10023);
}
Beispiel #24
0
//----------------------------------------------------------------------
// вывод одного операнда
bool idaapi mn102_outop(op_t &x)
{
  switch ( x.type ){
  // ссылка на память с использованием регистра (регистров)
  // (disp,Ri)
  case o_displ: // открывающая скобка есть всегда
                // регистр пристуствует?
                out_symbol('(');
                                OutValue(x);
                out_symbol(',');
                out_register(ph.regNames[x.reg]);
                out_symbol(')');
                break;

  // регистр
  case o_reg:           if ( x.reg&0x80)out_symbol('(' );
                        if ( x.reg&0x10 ){
                                out_register(ph.regNames[((x.reg>>5)&3)+rD0]);
                                out_symbol(',');
                        }
                        out_register(ph.regNames[x.reg&0x0F]);
                        if ( x.reg&0x80)out_symbol(')' );
                        break;

  // непосредственные данные
  case o_imm:
#if IDP_INTERFACE_VERSION > 37
                                refinfo_t ri;
                                // micro bug-fix
                                if ( get_refinfo(cmd.ea, x.n, &ri) ){
                                        if ( ri.flags==REF_OFF16 )
                                                set_refinfo(cmd.ea, x.n,
                                                        REF_OFF32, ri.target, ri.base, ri.tdelta);
                                }
#endif
                        OutValue(x, /*OOFS_NOSIGN | */ OOF_SIGNED | OOFW_IMM);
                        break;

  // ссылка на программу
  case o_near:  OutVarName(x);
                break;

  // прямая ссылка на память
  case o_mem:   out_symbol('(');
                                OutVarName(x);
                out_symbol(')');
                break;

  // пустыка не выводится
  case o_void:  return 0;

  // неизвестный операнд
  default:      warning("out: %a: bad optype %d",cmd.ea,x.type);
                break;
  }
//----------------------------------------------------------------------
bool chkOutSymSpace(char c)
{
  if ( !checkLine(2) )
    return true;
  out_symbol(c);
  OutChar(' ');
  outcnt += 2;
  return false;
}
Beispiel #26
0
// output an address
static void outaddr(op_t &op, const bool replace_with_label = true) {
    bool ind = is_addr_ind(op);      // is operand indirect ?
    bool sp = is_addr_sp(op);        // is operand special page ?

    int size = 16;  // operand is 16 bits long

    if ( ind)    out_symbol('(' );
    if ( sp)     { out_symbol('\\' ); size = 8; /* just display the first 8 bits */ }

    if ( !out_name_expr(op, toEA(cmd.cs, op.addr), op.addr) || !replace_with_label)
    {
        if ( replace_with_label) out_tagon(COLOR_ERROR );
        OutValue(op, OOF_ADDR | OOFS_NOSIGN | (size < 16 ? OOFW_8 : OOFW_16) );
        if ( replace_with_label) out_tagoff(COLOR_ERROR );
    }

    if ( ind)    out_symbol(')' );
}
Beispiel #27
0
static void out_reg_if_bit(ushort reg, uval_t value, int bit) {
    if ( (value & bit) == bit ) {
        if ( print_comma ) {
            out_symbol(',');
            OutChar(' ');
        }
        out_reg(reg);
        print_comma = true;
    }
}
Beispiel #28
0
//----------------------------------------------------------------------
// вывод одного операнда
bool idaapi C39_outop(op_t &x)
{
  switch ( x.type ){
  // только регистр
  case o_reg:	out_register(ph.regNames[x.reg]);
				break;

  // непосредственные данные (8 бит)
  case o_imm:	out_symbol('#');
#if IDP_INTERFACE_VERSION > 37
				refinfo_t ri;
				// micro bug-fix
				if(get_refinfo(cmd.ea, x.n, &ri)){
					if(ri.flags==REF_OFF16)
						set_refinfo(cmd.ea, x.n,
							REF_OFF32, ri.target, ri.base, ri.tdelta);
					msg("Exec OFF16_Op Fix AT:%a Flags=%lx, Target=%lx, Base=%lx, Delta=%lx\n",
						cmd.ea,
						ri.flags,ri.target,ri.base,ri.tdelta);
				}
#endif
				OutValue(x, /*OOFS_NOSIGN | */ OOF_SIGNED | OOFW_IMM);
				break;

  // прямая ссылка на программу (реально - относительно PC)
  case o_near:	OutVarName(x);
                break;

  // обращение к ячейке памяти
  case o_mem:   if(x.specflag1&URR_IND) out_symbol('(');
                OutValue(x, OOFS_NOSIGN |  OOFW_IMM);
                if(x.specflag1&URR_IND) out_symbol(')');
                break;

  // пустыка не выводится
  case o_void:  return 0;

  // неизвестный операнд
  default:      warning("out: %lx: bad optype",cmd.ea,x.type);
                break;
  }
  return 1;
}
Beispiel #29
0
//----------------------------------------------------------------------
// вывести название регистра
static inline void OutReg(size_t rgnum, uchar size)
{
ushort reg_name=0;      // код основной фразы регистра
if ( size!=dt_dword ){
        // если 32 - без префиксов!
        if ( rgnum&2 ){ // префикс Q
                out_symbol('Q');
        }
        else{ //м.б. нужен R ?
                if ( rgnum<0xD0) out_symbol('R' );
        }
}
// выдадим само название регистра
switch ( size ){
case dt_byte:   if ( (rgnum&0xF0)!=0xF0 ){
                        // обычные регистры
                        reg_name=reg_byte[(1-rgnum&1)|((rgnum>>1)&6)];
                }
                else { // байтовый I*- регистры
Beispiel #30
0
//----------------------------------------------------------------------
bool outop( op_t &x )
{
    uval_t v, v1;
//  const char *ptr;

    switch( x.type )
    {
    case o_imm:
        out_symbol( '#' );
        OutValue( x, OOF_SIGNED | OOFW_IMM );
        break;

    case o_indexed:
        OutValue( x, OOF_ADDR|OOF_SIGNED|(is_ext_insn() ? OOFW_32 : OOFW_16) ); //.addr
        v = x.value;
        out_symbol( '[' );
        if ( v != 0 ) goto OUTPHRASE;
        out_symbol( ']' );
        break;

    case o_indirect:
    case o_indirect_inc:
        out_symbol( '[' );

    case o_mem:
    case o_near:
        v = x.addr;
OUTPHRASE:
        v1 = toEA( getSR(cmd.ea, (x.type == o_near) ? rVcs : rVds), v);
        if( !out_name_expr( x, v1, v ) )
        {
            OutValue( x, (x.type == o_indexed ? 0 : OOF_ADDR) | OOF_NUMBER|OOFS_NOSIGN|
                      ((x.type == o_near) ? (is_ext_insn() ? OOFW_32 : OOFW_16) : OOFW_8) );
            QueueMark( Q_noName, cmd.ea );
        }

        if( x.type == o_indirect || x.type == o_indirect_inc ||
                x.type == o_indexed )
        {
            out_symbol( ']' );
            if( x.type == o_indirect_inc )    out_symbol( '+' );
        }
        break;

    case o_void:
        return 0;

    case o_bit:
        out_symbol( char('0' + x.reg) );
        break;

    default:
        warning( "out: %a: bad optype %d", cmd.ea, x.type );
    }

    return 1;
}