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; } }
//---------------------------------------------------------------------- // вывод одного операнда 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; }
/* 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; }
//---------------------------------------------------------------------- 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); } } }
// output shift symbol (if out = true, output outside of brackets) static void out_symbol_shift(op_t &op, bool out = false) { if (op.tms_shift != TMS_OP_SHIFT_NULL) { if (((op.tms_shift & TMS_OP_SHIFT_OUT)!=0) == out) // check if the shift must be print inside or outside the brackets { switch(op.tms_shift & TMS_OP_SHIFT_TYPE) { case TMS_OP_SHIFTL_IMM: out_line(" << ",COLOR_SYMBOL); out_shift(op.tms_shift_value); break; case TMS_OP_SHIFTL_REG: out_line(" << ",COLOR_SYMBOL); out_register(ph.regNames[op.tms_shift_value]); break; case TMS_OP_SHIFTR_IMM: out_line(" >> ",COLOR_SYMBOL); out_shift(op.tms_shift_value); break; case TMS_OP_EQ: out_line(" == ",COLOR_SYMBOL); out_shift(op.tms_shift_value); break; case TMS_OP_NEQ: out_line(" != ",COLOR_SYMBOL); out_shift(op.tms_shift_value); break; default: error("interr: out: out_symbol_shift"); } } } }
// Output a register static void out_reg(ushort reg) { out_register(ph.regNames[reg]); const char *cmt = get_general_register_description(reg); if ( cmt != NULL && !has_cmt(uFlag) ) { gr_cmt = cmt; } }
static void out_operators_end(op_t &op) { int i; short operators = (op.tms_operator2 << 8) | (op.tms_operator1 &0xFF); int brackets = 0; for (i = 0; i < TMS_OPERATORS_SIZE; i++) if (operators & (1<<i)) brackets++; if (operators & TMS_OPERATOR_T3) brackets--; if (operators & TMS_OPERATOR_NOT) brackets--; for (i = 0; i < brackets; i++) out_register(")"); }
//---------------------------------------------------------------------- static void out_phrase(int phn) { switch ( phn ) { case PH_XPLUS: // X+ out_register("X"); out_symbol('+'); break; case PH_MINUSX: // -X out_symbol('-'); case PH_X: // X out_register("X"); break; case PH_YPLUS: // Y+ out_register("Y"); out_symbol('+'); break; case PH_MINUSY: // -Y out_symbol('-'); case PH_Y: // Y out_register("Y"); break; case PH_ZPLUS: // Z+ out_register("Z"); out_symbol('+'); break; case PH_MINUSZ: // -Z out_symbol('-'); case PH_Z: // Z out_register("Z"); break; default: error("%a: bad phrase number", cmd.ea); } }
//---------------------------------------------------------------------- // вывод одного операнда 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; }
//---------------------------------------------------------------------- void OutRegString(bool isWorkingReg, bool isPair, int regNum, int regBit = -1) { char buf[256]; // if it is a working register, output it with an R in front if (isWorkingReg) { if (!isPair) { qsnprintf(buf, sizeof(buf), "R%u", regNum); } else { qsnprintf(buf, sizeof(buf), "RR%u", regNum); } } else { // output either working or non-working reg if (!isPair) { // N.B. working registers start at 0xC0 if (regNum >= 0xC0) { qsnprintf(buf, sizeof(buf), "R%u", regNum - 0xC0); } else { qsnprintf(buf, sizeof(buf), "0%XH", regNum); } } else { // N.B. working registers start at 0xC0 if (regNum >= 0xC0) { qsnprintf(buf, sizeof(buf), "RR%u", regNum - 0xC0); } else { qsnprintf(buf, sizeof(buf), "0%XH", regNum); } } } out_register(buf); // output regBit if requested if (regBit != -1) { qsnprintf(buf, sizeof(buf), ".%i", regBit); out_line(buf, COLOR_DEFAULT); } }
//---------------------------------------------------------------------- void idaapi 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.IsParallel ) { // new line for Parallel instructions term_output_buffer(); MakeLine(buf); init_output_buffer(buf, sizeof(buf)); out_line("|| ", COLOR_INSN); const char *insn2 = NULL; switch ( cmd.itype ) { case TMS320C54_ld_mac: insn2 = "mac "; break; case TMS320C54_ld_macr: insn2 = "macr "; break; case TMS320C54_ld_mas: insn2 = "mas "; break; case TMS320C54_ld_masr: insn2 = "masr "; break; case TMS320C54_st_add: insn2 = "add "; break; case TMS320C54_st_sub: insn2 = "sub "; break; case TMS320C54_st_ld: insn2 = "ld "; break; case TMS320C54_st_mpy: insn2 = "mpy "; break; case TMS320C54_st_mac: insn2 = "mac "; break; case TMS320C54_st_macr: insn2 = "macr "; break; case TMS320C54_st_mas: insn2 = "mas "; break; case TMS320C54_st_masr: insn2 = "masr "; break; default: warning("interr: out parallel instruction"); } out_line(insn2, COLOR_INSN); } if ( cmd.Op3.type != o_void ) { if ( !cmd.IsParallel ) { out_symbol(','); OutChar(' '); } out_one_operand(2); if ( cmd.Op4_type != 0 ) { out_symbol(','); OutChar(' '); switch ( cmd.Op4_type ) { case o_reg: out_register(ph.regNames[cmd.Op4_value]); break; case o_cond8: out_cond8(cmd.Op4_value); break; default: break; } } } } 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); }
bool idaapi cr16c_outop(op_t& x) { switch(x.type) { case o_reg: out_register(ph.regNames[x.reg]); break; case o_displ: OutValue(x,OOF_SIGNED|OOFW_32); break; case o_phrase: out_symbol('('); switch(x.specflag1) { default: case PAR_ind_reg: out_register(ph.regNames[x.reg]); break; case PAR_ind_rp: out_register(ph.regNames[x.reg+16]); break; /* case PAR_ind_prp: out_register(ph.regNames[x.reg+16]); break;*/ case PAR_ind_rrp: out_register(ph.regNames[x.reg+32]); break; } out_symbol(')'); break; case o_mem: OutValue(x,OOF_SIGNED|OOFW_32); break; case o_imm: out_symbol('$'); OutValue(x,OOF_SIGNED|OOFW_32); break; case o_idpspec0: out_symbol('['); if(x.specval&0x4) OutChar('d'); if((x.specval&0x4)&&((x.specval&0x2)||(x.specval&0x1))) out_symbol(','); if(x.specval&0x2) OutChar('i'); if((x.specval&0x2)&&(x.specval&0x1)) out_symbol(','); if(x.specval&0x1) OutChar('u'); out_symbol(']'); break; default:; } //out_name_expr(x, x.addr, x.addr); /* if (cmd.itype == COMPARE_OP) { //For comparisons, the argument indicates the type of comparison to be //performed. Print a symbolic representation of the comparison rather //than a number. if (x.value < qnumber(compare_ops)) { OutLine(compare_ops[x.value]); } else { OutLine("BAD OPERAND"); } } else if (cmd.auxpref & HAS_JREL) { //we don't test for x.type == o_near here because we need to distinguish //between relative jumps and absolute jumps. In our case, HAS_JREL //implies o_near out_name_expr(x, x.addr, x.addr); } else { //otherwise just print the operand value OutValue(x); }*/ return true; }
//---------------------------------------------------------------------- bool outop(op_t &x) { switch ( x.type ) { case o_void: return 0; case o_reg: if ( ram != BADADDR ) { char buf[MAXSTR]; const char *name = get_name(cmd.ea, ram+x.reg, buf, sizeof(buf)); if ( name != NULL ) { out_register(name); break; } } out_register(ph.regNames[x.reg]); break; case o_imm: if ( cmd.itype == AVR_cbi || cmd.itype == AVR_sbic || cmd.itype == AVR_sbi || cmd.itype == AVR_sbis ) { const char *bit = find_bit(cmd.Op1.addr, (size_t)x.value); if ( bit != NULL ) { out_line(bit, COLOR_REG); break; } } if ( x.specflag1 && isOff1(uFlag) && !is_invsign(cmd.ea, uFlag, 1) ) { out_symbol('-'); } OutValue(x, OOFS_IFSIGN|OOF_SIGNED|OOFW_8); break; case o_near: { ea_t ea = toEA(cmd.cs, x.addr); if ( !out_name_expr(x, ea, x.addr) ) out_bad_address(x.addr); } break; case o_mem: { ea_t ea = toEA(dataSeg(), x.addr); if ( !out_name_expr(x, ea, x.addr) ) out_bad_address(x.addr); } break; case o_phrase: out_phrase(x.phrase); break; case o_displ: out_phrase(x.phrase); OutValue(x,OOF_ADDR|OOFS_NEEDSIGN|OOFW_IMM); break; case o_port: { const char *pname = find_port(x.addr); if ( pname == NULL ) out_bad_address(x.addr); else out_register(pname); } break; default: warning("out: %a: bad optype %d", cmd.ea, x.type); break; } return 1; }
// Output a register static void out_reg(ushort reg) { out_register(ph.regNames[reg]); }
void out_print_tpreg(op_t &/*x*/, ea_t /*pc*/) { out_register("$tp"); }
//---------------------------------------------------------------------- inline void outreg(int r) { out_register(ph.regNames[r]); }
//---------------------------------------------------------------------- bool idaapi outop(op_t &x) { ea_t ea; switch ( x.type ) { case o_void: return 0; case o_reg: out_register(ph.regNames[x.reg]); break; case o_near: case o_far: out_address(calc_code_mem(x.addr, x.type == o_near), x, false, false); break; case o_imm: { const char *name = NULL; if ( idpflags & TMS320C54_IO && x.IOimm ) name = find_sym(x.value); if ( !x.NoCardinal ) out_symbol('#'); if ( name != NULL ) { out_line(name, COLOR_IMPNAME); } else { if ( !x.Signed ) OutValue(x, OOFW_IMM); else OutValue(x, OOFS_IFSIGN|OOF_SIGNED|OOF_NUMBER|OOFW_IMM); } break; } case o_local: OutValue(x, OOFW_IMM|OOF_ADDR); break; case o_mmr: case o_mem: case o_farmem: if ( x.IndirectAddressingMOD == ABSOLUTE_INDIRECT_ADRESSING ) { out_symbol('*'); out_symbol('('); } ea = calc_data_mem(x.addr, x.type == o_mem); if ( ea != BADADDR ) out_address(ea, x, true, x.IndirectAddressingMOD != ABSOLUTE_INDIRECT_ADRESSING); // no '@' if absolute "indirect" adressing else OutValue(x, OOFW_IMM|OOF_ADDR); if ( x.IndirectAddressingMOD == ABSOLUTE_INDIRECT_ADRESSING ) out_symbol(')'); break; case o_displ: // Indirect addressing mode { const char *reg = ph.regNames[x.reg]; char buf[8]; switch ( x.IndirectAddressingMOD ) { case 0: qsnprintf(buf, sizeof(buf), "*%s",reg); out_register(buf); break; case 1: qsnprintf(buf, sizeof(buf), "*%s-",reg); out_register(buf); break; case 2: qsnprintf(buf, sizeof(buf), "*%s+",reg); out_register(buf); break; case 3: qsnprintf(buf, sizeof(buf), "*+%s",reg); out_register(buf); break; case 4: qsnprintf(buf, sizeof(buf), "*%s-0B",reg); out_register(buf); break; case 5: qsnprintf(buf, sizeof(buf), "*%s-0",reg); out_register(buf); break; case 6: qsnprintf(buf, sizeof(buf), "*%s+0",reg); out_register(buf); break; case 7: qsnprintf(buf, sizeof(buf), "*%s+0B",reg); out_register(buf); break; case 8: qsnprintf(buf, sizeof(buf), "*%s-%%",reg); out_register(buf); break; case 9: qsnprintf(buf, sizeof(buf), "*%s-0%%",reg); out_register(buf); break; case 0xA: qsnprintf(buf, sizeof(buf), "*%s+%%",reg); out_register(buf); break; case 0xB: qsnprintf(buf, sizeof(buf), "*%s+0%%",reg); out_register(buf); break; case 0xC: qsnprintf(buf, sizeof(buf), "*%s(",reg); out_register(buf); OutValue(x, OOF_ADDR|OOF_SIGNED|OOFW_16); out_symbol(')'); break; case 0xD: qsnprintf(buf, sizeof(buf), "*+%s(",reg); out_register(buf); OutValue(x, OOF_ADDR|OOF_SIGNED|OOFW_16); out_symbol(')'); break; case 0xE: qsnprintf(buf, sizeof(buf), "*+%s(",reg); out_register(buf); OutValue(x, OOF_ADDR|OOF_SIGNED|OOFW_16); out_symbol(')'); out_symbol('%'); break; // this special adressing mode is now defined as o_farmem ! // case ABSOLUTE_INDIRECT_ADRESSING: // out_symbol('*'); // out_symbol('('); // OutValue(x, OOF_ADDR|OOF_SIGNED|OOFW_16); // out_symbol(')'); // break; default: error("interr: out: o_displ"); } break; } case o_bit: { if ( !x.NoCardinal ) out_symbol('#'); char buf[20]; qsnprintf(buf, sizeof(buf), "%d", int(x.value)); out_line(buf,COLOR_REG); break; } case o_cond8: out_cond8((uchar)x.value); break; case o_cond2: { const char *cond = ""; switch ( x.value ) { case 0: cond = "eq"; break; case 1: cond = "lt"; break; case 2: cond = "gt"; break; case 3: cond = "neq"; break; default: warning("interr: out 2-bit condition"); } out_line(cond, COLOR_REG); break; } default: error("interr: out"); break; } return 1; }
// output register name inline static void outreg(const int n) { out_register(ph.regNames[n]); }
//---------------------------------------------------------------------- inline void OutReg(int rgnum) { out_register(ph.regNames[rgnum]); }
static void out_reg(op_t &op) { char *reg = ph.regNames[op.reg]; switch(op.tms_modifier) { case TMS_MODIFIER_NULL: out_register(reg); break; case TMS_MODIFIER_REG: out_symbol('*'); out_register(reg); break; case TMS_MODIFIER_REG_P: out_symbol('*'); out_register(reg); out_symbol('+'); break; case TMS_MODIFIER_REG_M: out_symbol('*'); out_register(reg); out_symbol('-'); break; case TMS_MODIFIER_REG_P_T0: out_line("*(", COLOR_SYMBOL); out_register(reg); out_symbol('+'); out_register(ph.regNames[T0]); out_symbol(')'); break; case TMS_MODIFIER_REG_P_T1: out_line("*(", COLOR_SYMBOL); out_register(reg); out_symbol('+'); out_register(ph.regNames[T1]); out_symbol(')'); break; case TMS_MODIFIER_REG_M_T0: out_line("*(", COLOR_SYMBOL); out_register(reg); out_symbol('-'); out_register(ph.regNames[T0]); out_symbol(')'); break; case TMS_MODIFIER_REG_M_T1: out_line("*(", COLOR_SYMBOL); out_register(reg); out_symbol('-'); out_register(ph.regNames[T1]); out_symbol(')'); break; case TMS_MODIFIER_REG_T0: out_symbol('*'); out_register(reg); out_symbol('('); out_register(ph.regNames[T0]); out_symbol(')'); break; case TMS_MODIFIER_REG_OFFSET: case TMS_MODIFIER_P_REG_OFFSET: out_symbol('*'); if (op.tms_modifier == TMS_MODIFIER_P_REG_OFFSET) out_symbol('+'); out_register(reg); out_line("(#", COLOR_SYMBOL); OutValue(op, OOFS_IFSIGN|OOF_SIGNED|OOF_NUMBER|OOFW_IMM); out_symbol(')'); break; case TMS_MODIFIER_REG_SHORT_OFFSET: out_symbol('*'); out_register(reg); out_line("(short(#", COLOR_SYMBOL); OutValue(op, OOFS_IFSIGN|OOF_SIGNED|OOF_NUMBER|OOFW_IMM); out_line("))", COLOR_SYMBOL); break; case TMS_MODIFIER_REG_T1: out_symbol('*'); out_register(reg); out_symbol('('); out_register(ph.regNames[T1]); out_symbol(')'); break; case TMS_MODIFIER_P_REG: out_symbol('+'); out_register(reg); break; case TMS_MODIFIER_M_REG: out_symbol('-'); out_register(reg); break; case TMS_MODIFIER_REG_P_T0B: out_line("*(", COLOR_SYMBOL); out_register(reg); out_symbol('+'); out_register("T0B"); out_symbol(')'); break; case TMS_MODIFIER_REG_M_T0B: out_line("*(", COLOR_SYMBOL); out_register(reg); out_symbol('-'); out_register("T0B"); out_symbol(')'); break; default: error("interr: out: o_reg: modifier"); } }
bool __stdcall outop( op_t &x ) { char buf[MAXSTR]; switch( x.type ) { case o_imm: { switch(cmd.insnpref) { case SWFACTION_GETURL2: { switch(x.specflag1) { case 'M': if (x.value == 2) out_keyword("method:POST"); else x.value?out_keyword("method:GET"):out_keyword("method:none"); break; case 'T': x.value?out_keyword("target:sprite"):out_keyword("target:browser"); break; case 'V': x.value?out_keyword("vars:load"):out_keyword("vars:no"); } } break; case SWFACTION_CONSTANTPOOL: OutValue( x, OOFW_IMM ); break; case SWFACTION_GOTOFRAME2: if (x.n == 0) { x.value?out_keyword("play:yes"):out_keyword("play:no"); } else { OutValue( x, OOFW_IMM ); } break; case SWFACTION_DEFINEFUNCTION2: if (x.n == 5) { //output the parameters first uint16 p = cmd.auxpref, i = 0; uint16 param_length = get_word(cmd.ea + 1) - p -2; out_char('{', COLOR_SYMBOL); while (i < param_length) { uint8 reg = get_byte(cmd.ea + 3 + p + i); char* reg_name = buf; *reg_name = 0; while ((i++ < param_length) && ((*(reg_name++) = get_byte(cmd.ea + 3 + p + i))!= 0)) {;} i++; if (reg_name > buf && *(--reg_name) == 0) { char r[6]; out_char('{', COLOR_SYMBOL); if (reg) { qsnprintf(r, 5, "r%u", reg); out_register( r ); } else { out_char('0', COLOR_NUMBER); } out_line(",\"", COLOR_SYMBOL); out_line(buf, COLOR_CHAR); out_line("\"}, ", COLOR_SYMBOL); }//if }//while out_line("}, ", COLOR_SYMBOL); } OutValue( x, OOFW_IMM ); break; default: OutValue( x, OOFW_IMM ); } } break; case o_reg: qsnprintf(buf, MAXSTR, "r%u", x.reg); out_register( buf ); break; case o_near: if( !out_name_expr(x, x.addr, x.addr) ) { // if we could not create and output a name expression from the address OutValue(x, OOF_ADDR | OOF_NUMBER | OOFW_32); // instead output a raw value QueueMark(Q_noName, cmd.ea); //and mark this as a problem } break; case o_null: out_keyword("null"); break; case o_undefined: out_keyword("undefined"); break; case o_bool: x.value?out_keyword("true"):out_keyword("false"); break; case o_const: out_keyword("constant:"); OutValue( x, OOFW_IMM ); break; case o_string: { uint16 p = 0; char c; out_char('"', COLOR_SYMBOL); while ((c = get_byte(x.addr+p)) != 0) { if (is_printable(c)) { out_char(c, COLOR_CHAR); } else { qsnprintf(buf, MAXSTR, "\\x%02X", c); out_line(buf, COLOR_STRING); } p++; } out_char('"', COLOR_SYMBOL); } break; case o_void: return 0; default: warning( "out: %lx: bad optype %d", cmd.ea, x.type ); } return 1; }
//---------------------------------------------------------------------- static void out_address(op_t &op) { ea_t ea; if (op.type == o_near) ea = calc_code_mem(op.addr); else if (op.type == o_mem) ea = calc_data_mem(op); else if (op.type == o_io) ea = calc_io_mem(op); int reg = -1; if (op.type == o_mem) reg = get_mapped_register(ea); // print begin of the modifier switch(op.tms_modifier) { case TMS_MODIFIER_NULL: break; case TMS_MODIFIER_DMA: if ((int)reg == -1) out_symbol('@'); break; case TMS_MODIFIER_ABS16: case TMS_MODIFIER_PTR: out_symbol('*'); if (op.tms_modifier == TMS_MODIFIER_ABS16) out_line("abs16", COLOR_SYMBOL); out_line("(#", COLOR_SYMBOL); break; case TMS_MODIFIER_MMAP: out_line("mmap(@", COLOR_SYMBOL); break; case TMS_MODIFIER_PORT: out_line("port(#", COLOR_SYMBOL); break; case TMS_MODIFIER_PORT_AT: out_line("port(@", COLOR_SYMBOL); break; default: error("interr: out: o_address: modifier_begin"); } if (op.type != o_io) { if (int(reg) != -1) // memory mapped register out_register(ph.regNames[reg]); else { #ifndef TMS320C55_NO_NAME_NO_REF if ( !out_name_expr(op, ea, ea) ) #endif { out_tagon(COLOR_ERROR); if (op.type != o_mem) OutLong(op.addr, 16); else OutLong(op.addr, 16); out_tagoff(COLOR_ERROR); QueueMark(Q_noName, cmd.ea); } } } else // IO address { if (ea != BADADDR) { const char *name = NULL; if (idpflags & TMS320C55_IO) name = find_sym(ea); if (name) out_line(name, COLOR_IMPNAME); else OutLong(ea, 16); } else { out_tagon(COLOR_ERROR); OutLong(op.addr, 16); out_tagoff(COLOR_ERROR); } } // print end of the modifier switch(op.tms_modifier) { case TMS_MODIFIER_NULL: case TMS_MODIFIER_DMA: break; case TMS_MODIFIER_ABS16: case TMS_MODIFIER_PTR: case TMS_MODIFIER_MMAP: case TMS_MODIFIER_PORT: case TMS_MODIFIER_PORT_AT: out_symbol(')'); break; default: error("interr: out: o_address: modifier_begin"); } }
static void out_cond(op_t &x) { char *reg = ph.regNames[x.reg]; switch(x.value) { case 0x00: out_register(reg); out_line(" == #", COLOR_SYMBOL); out_long(0, 10); break; case 0x10: out_register(reg); out_line(" != #", COLOR_SYMBOL); out_long(0, 10); break; case 0x20: out_register(reg); out_line(" < #", COLOR_SYMBOL); out_long(0, 10); break; case 0x30: out_register(reg); out_line(" <= #", COLOR_SYMBOL); out_long(0, 10); break; case 0x40: out_register(reg); out_line(" > #", COLOR_SYMBOL); out_long(0, 10); break; case 0x50: out_register(reg); out_line(" >= #", COLOR_SYMBOL); out_long(0, 10); break; case 0x60: out_line("overflow(", COLOR_SYMBOL); out_register(reg); out_symbol(')'); break; case 0x64: out_register(ph.regNames[TC1]); break; case 0x65: out_register(ph.regNames[TC2]); break; case 0x66: out_register(ph.regNames[CARRY]); break; case 0x68: out_register(ph.regNames[TC1]); out_line(" & ", COLOR_SYMBOL); out_register(ph.regNames[TC2]); break; case 0x69: out_register(ph.regNames[TC1]); out_line(" & !", COLOR_SYMBOL); out_register(ph.regNames[TC2]); break; case 0x6A: out_symbol('!'); out_register(ph.regNames[TC1]); out_line(" & ", COLOR_SYMBOL); out_register(ph.regNames[TC2]); break; case 0x6B: out_symbol('!'); out_register(ph.regNames[TC1]); out_line(" & !", COLOR_SYMBOL); out_register(ph.regNames[TC2]); break; case 0x70: out_line("!overflow(", COLOR_SYMBOL); out_register(reg); out_symbol(')'); break; case 0x74: out_symbol('!'); out_register(ph.regNames[TC1]); break; case 0x75: out_symbol('!'); out_register(ph.regNames[TC2]); break; case 0x76: out_symbol('!'); out_register(ph.regNames[CARRY]); break; case 0x78: out_register(ph.regNames[TC1]); out_line(" | ", COLOR_SYMBOL); out_register(ph.regNames[TC2]); break; case 0x79: out_register(ph.regNames[TC1]); out_line(" | !", COLOR_SYMBOL); out_register(ph.regNames[TC2]); break; case 0x7A: out_symbol('!'); out_register(ph.regNames[TC1]); out_line(" | ", COLOR_SYMBOL); out_register(ph.regNames[TC2]); break; case 0x7B: out_symbol('!'); out_register(ph.regNames[TC1]); out_line(" | !", COLOR_SYMBOL); out_register(ph.regNames[TC2]); break; case 0x7C: out_register(ph.regNames[TC1]); out_line(" ^ ", COLOR_SYMBOL); out_register(ph.regNames[TC2]); break; case 0x7D: out_register(ph.regNames[TC1]); out_line(" ^ !", COLOR_SYMBOL); out_register(ph.regNames[TC2]); break; case 0x7E: out_symbol('!'); out_register(ph.regNames[TC1]); out_line(" ^ ", COLOR_SYMBOL); out_register(ph.regNames[TC2]); break; case 0x7F: out_symbol('!'); out_register(ph.regNames[TC1]); out_line(" ^ !", COLOR_SYMBOL); out_register(ph.regNames[TC2]); break; default: error("interr: out: o_cond"); } }
bool outop(op_t &x) { uval_t v; int dir, bit; char buf[MAXSTR]; switch ( x.type ) { case o_reg: OutReg(x.reg); break; case o_phrase: if ( x.phrase == fRi ) { out_symbol('@'); OutReg(x.indreg); break; } out_colored_register_line(phrases[x.phrase]); break; case o_displ: out_symbol('@'); OutReg(x.reg); out_symbol('+'); OutValue(x, OOF_ADDR | OOFS_IFSIGN | OOFW_16); break; case o_imm: out_symbol('#'); if ( cmd.auxpref & aux_0ext ) out_symbol('0'); if ( cmd.auxpref & aux_1ext ) out_symbol('1'); OutValue(x, OOFS_IFSIGN | OOFW_IMM); break; case o_mem: case o_near: v = map_addr(x.addr, x.n, x.type==o_mem); if ( get_name_expr(cmd.ea+x.offb, x.n, v, x.addr, buf, sizeof(buf)) <= 0 ) { /* int nbit; if ( cmd.itype == I51_ecall || cmd.itype == I51_ejmp ) nbit = OOFW_32; else nbit = OOFW_16;*/ OutValue(x, OOF_ADDR | OOF_NUMBER | OOFS_NOSIGN | OOFW_32); QueueMark(Q_noName, cmd.ea); break; } // we want to output SFR register names always in COLOR_REG, // so remove the color tags and output it manually: if ( x.type == o_mem && x.addr >= 0x80 ) { tag_remove(buf, buf, sizeof(buf)); out_register(buf); break; } OutLine(buf); break; case o_void: return false; case o_bit251: if ( x.b251_bitneg ) out_symbol('/'); dir = x.addr; bit = x.b251_bit; goto OUTBIT; case o_bitnot: out_symbol('/'); case o_bit: dir = (x.reg & 0xF8); bit = x.reg & 7; if ( (dir & 0x80) == 0 ) dir = dir/8 + 0x20; OUTBIT: if(ash.uflag & UAS_PBIT) { const ioport_bit_t *predef = find_bit( dir, bit); if ( predef != NULL ) { out_line(predef->name, COLOR_REG); break; } } { v = map_addr(dir, x.n, true); ssize_t len = get_name_expr(cmd.ea+x.offb, x.n, v, dir, buf, sizeof(buf)); if ( len > 0 && strchr(buf, '+') == NULL ) { // we want to output the bit names always in COLOR_REG, // so remove the color tags and output it manually: if ( dir < 0x80 ) { OutLine(buf); } else { tag_remove(buf, buf, sizeof(buf)); out_register(buf); } } else { out_long(dir, 16); } out_symbol(ash.uflag & UAS_NOBIT ? '_' : '.'); out_symbol('0'+bit); } break; default: warning("out: %a: bad optype",cmd.ea,x.type); break; } return true; }