//--------------------------------------------------------------------------- uchar out_nodelist(uval_t nodeid, uchar pos, const char *pref) { uval_t cnt, off = 0; netnode node(nodeid); if ( (cnt = node.altval(0)) == 0) DESTROYED("out::nodelist" ); if ( pref ) { // jasmin if ( change_line() ) { bad: return(0); } off = strlen(pref); } for(register unsigned i = 0; ; ) { if ( pref) { // jasmin (single directive per line ) curpos = pos; out_keyword(pref); outcnt = (size_t)off; } else if ( i && chkOutSymSpace(',') ) goto bad; // prompted list if ( out_alt_ind((uint32)node.altval(++i)) ) goto bad; if ( i >= cnt) return(1 ); if ( pref && change_line() ) goto bad; // jasmin } }
//---------------------------------------------------------------------- // 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); }
//--------------------------------------------------------------------------- uchar out_nodelist(uval_t nodeid, uchar pos, const char *pref) { netnode node(nodeid); uval_t cnt = node.altval(0); if ( cnt == 0 ) DESTROYED("out::nodelist"); uval_t off = 0; if ( pref ) // jasmin { if ( change_line() ) { bad: return 0; } off = strlen(pref); } for ( uint i = 0; ; ) { if ( pref ) // jasmin (single directive per line) { curpos = pos; out_keyword(pref); outcnt = off; } else if ( i && chkOutSymSpace(',') ) { goto bad; // prompted list } if ( out_alt_ind((uint32)node.altval(++i)) ) goto bad; if ( i >= cnt ) return 1; if ( pref && change_line() ) goto bad; // jasmin } }
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; }
//---------------------------------------------------------------------- // вывод одного операнда bool N78K_outop(op_t &x) { #if IDP_INTERFACE_VERSION <= 37 uFlag = getFlags(cmd.ea); #endif switch(x.type){ case o_void: return 0; case o_reg: if(x.FormOut & FORM_OUT_SKOBA) out_symbol('['); OutReg(x.reg); if(x.FormOut & FORM_OUT_PLUS) out_symbol('+'); if(x.FormOut & FORM_OUT_DISP){ if(isOff(uFlag, x.n)){ OutVarNameVal(x); } else OutValue(x, OOFW_IMM ); } if(x.FormOut & FORM_OUT_REG){ out_keyword( ph.regNames[x.SecondReg] ); } if(x.FormOut & FORM_OUT_SKOBA) out_symbol(']'); break; case o_bit: switch(x.FormOut){ case FORM_OUT_S_ADDR: case FORM_OUT_SFR: OutVarName(x); out_symbol('.'); #if IDP_INTERFACE_VERSION > 37 if( !nec_find_ioport_bit(x.addr, x.value) ) #endif { OutValue(x, OOFW_IMM); } break; case FORM_OUT_A: OutLine("A."); OutValue(x, OOFW_IMM); break; case FORM_OUT_PSW: OutLine("PSW."); switch(x.value){ case 0: OutLine("CY");break; case 1: OutLine("ISP");break; case 3: OutLine("RBS0");break; case 4: OutLine("AC");break; case 5: OutLine("RBS1");break; case 6: OutLine("Z");break; case 7: OutLine("IE");break; default:OutValue(x, OOFW_IMM); } break; case FORM_OUT_HL: out_symbol('['); OutReg(rHL); out_symbol(']'); out_symbol('.'); if(isOff(uFlag, x.n)){ OutVarNameVal(x); } else OutValue(x, OOFW_IMM ); break; } break; case o_imm: out_symbol('#'); if(isOff(uFlag, x.n)){ OutVarNameVal(x); } else OutValue(x, OOFW_IMM ); break; case o_mem: //выводит имя переменной из памяти(например byte_98) if(x.FormOut & FORM_OUT_VSK) out_symbol('!'); if(x.FormOut & FORM_OUT_SKOBA) out_symbol('['); //Вывод имени переменной OutVarName(x); if(x.FormOut & FORM_OUT_SKOBA) out_symbol(']'); break; case o_near: if(x.FormOut & FORM_OUT_VSK) out_symbol('!'); if(x.FormOut & FORM_OUT_SKOBA) out_symbol('['); { ulong adr; adr = toEA(codeSeg(x.addr,x.n),x.addr); #if IDP_INTERFACE_VERSION > 37 if( !out_name_expr(x, adr, x.addr)){ OutValue(x, OOF_ADDR | OOF_NUMBER | OOFW_16); QueueMark(Q_noName, cmd.ea); } #else {const char *ptr; ptr=get_name_expr(cmd.ea+x.offb, adr, x.addr); if( ptr == NULL ){ OutValue(x, OOF_ADDR | OOF_NUMBER | OOFW_16); QueueMark(Q_noName, cmd.ea); } else OutLine(ptr); } #endif } if(x.FormOut & FORM_OUT_SKOBA) out_symbol(']'); break; // неизвестный операнд default: warning("out: %lx: bad optype",cmd.ea,x.type); break; } return(1); }
static inline void OutKeyword(const char *str, size_t len) { outcnt += len; out_keyword(str); }
//---------------------------------------------------------------------- bool idaapi outop(op_t &x) { uval_t v; switch ( x.type ) { case o_imm: out_symbol('#'); OutValue(x, OOFW_IMM); break; case o_ind_reg: out_symbol('@'); case o_reg: OutReg(x.reg); break; case o_phrase: //ig: лучше out_keyword, чем простой OutLine() // так цвет будет правильный out_keyword(phrases[x.phrase]); break; case o_displ: OutValue(x, OOF_ADDR | OOFW_IMM); // x.addr out_symbol('('); OutReg(x.reg); out_symbol(')'); break; case o_ind_mem: out_symbol('@'); case o_mem: case o_near: v = map_addr(x.addr, x.n, x.type != o_near); if ( !out_name_expr(x, v, x.addr) ) { const char *name = z8_find_ioport(v); if ( name != NULL ) { out_line(name, COLOR_IMPNAME); } else { OutValue(x, OOF_ADDR | OOF_NUMBER | OOFS_NOSIGN | OOFW_16); QueueSet(Q_noName, cmd.ea); } } break; case o_void: return 0; default: warning("out: %a: bad optype %d", cmd.ea, x.type); } return 1; }