//-------------------------------------------------------------------------- void segstart(ea_t ea) { segment_t *Sarea = getseg(ea); if ( is_spec_segm(Sarea->type) ) return; char sname[MAXNAMELEN]; char sclas[MAXNAMELEN]; get_segm_name(Sarea, sname, sizeof(sname)); get_segm_class(Sarea, sclas, sizeof(sclas)); printf_line(0, COLSTR("%s", SCOLOR_ASMDIR) " " COLSTR("%s %s", SCOLOR_AUTOCMT), strcmp(sclas,"CODE") == 0 ? ".CSEG" : strcmp(sclas,"DATA") == 0 ? ".DSEG" : ".ESEG", ash.cmnt, sname); if ( Sarea->orgbase != 0 ) { char buf[MAX_NUMBUF]; btoa(buf, sizeof(buf), Sarea->orgbase); printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.origin, buf); } }
//-------------------------------------------------------------------------- void idaapi gen_stkvar_def(char *buf, size_t bufsize, const member_t *mptr, sval_t v) { char sign = ' '; if ( v < 0 ) { sign = '-'; v = -v; } char name[MAXNAMELEN]; name[0] = '\0'; get_member_name(mptr->id, name, sizeof(name)); char vstr[MAX_NUMBUF]; btoa(vstr, sizeof(vstr), v); qsnprintf(buf, bufsize, COLSTR("%s",SCOLOR_KEYWORD) " " COLSTR("%c%s",SCOLOR_DNUM) COLSTR(",",SCOLOR_SYMBOL) " " COLSTR("%s",SCOLOR_LOCNAME), ash.a_equ, sign, vstr, name); }
// Generate a segment header void gen_segm_header(ea_t ea) { segment_t *Sarea = getseg(ea); char sname[MAXNAMELEN]; get_segm_name(Sarea, sname, sizeof(sname)); char *segname = sname; if ( *segname == '_' ) segname++; if ( ash.uflag & UAS_ASW ) { printf_line(inf.indent, COLSTR("SEGMENT %s", SCOLOR_ASMDIR), segname); } else { printf_line(inf.indent, COLSTR(".section .%s", SCOLOR_ASMDIR), segname); } ea_t orgbase = ea - get_segm_para(Sarea); if ( orgbase != 0 ) { char buf[MAX_NUMBUF]; btoa(buf, sizeof(buf), orgbase); printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.origin, buf); } }
//-------------------------------------------------------------------------- void footer(void) { char name[MAXSTR]; get_name(BADADDR, inf.beginEA, name, sizeof(name)); printf_line(inf.indent,COLSTR("%s",SCOLOR_ASMDIR) " " COLSTR("%s %s",SCOLOR_AUTOCMT), ash.end, ash.cmnt, name); }
// prints function header static void mits_func_header(func_t *pfn) { std_gen_func_header(pfn); char buf[MAXSTR]; const char *name = mits_get_func_name(pfn, buf, sizeof(buf)); if ( name != NULL ) { printf_line(inf.indent, COLSTR(".FUNC %s", SCOLOR_ASMDIR), name); printf_line(0, COLSTR("%s:", SCOLOR_ASMDIR), name); } }
//-------------------------------------------------------------------------- void idaapi footer(void) { char name[MAXSTR]; get_colored_name(BADADDR, inf.beginEA, name, sizeof(name)); const char *end = ash.end; if ( end == NULL ) printf_line(inf.indent,COLSTR("%s end %s",SCOLOR_AUTOCMT), ash.cmnt, name); else printf_line(inf.indent,COLSTR("%s",SCOLOR_ASMDIR) " " COLSTR("%s %s",SCOLOR_AUTOCMT), ash.end, ash.cmnt, name); }
// prints function header static void idaapi gnu_func_header(func_t *pfn) { std_gen_func_header(pfn); char buf[MAXSTR]; const char *name = fr_get_func_name(pfn, buf, sizeof(buf)); if ( name != NULL ) { if ( is_public_name(pfn->startEA) && ash.a_public != NULL ) printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.a_public, name); printf_line(inf.indent, COLSTR(".type %s, @function", SCOLOR_ASMDIR), name); printf_line(0, COLSTR("%s:", SCOLOR_ASMDIR), name); } }
// prints function header static void idaapi gnu_func_header(func_t *pfn) { std_gen_func_header(pfn); qstring namebuf; if ( fr_get_func_name(&namebuf, pfn) ) { const char *name = namebuf.begin(); if ( is_public_name(pfn->startEA) && ash.a_public != NULL ) printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.a_public, name); printf_line(inf.indent, COLSTR(".type %s, @function", SCOLOR_ASMDIR), name); printf_line(0, COLSTR("%s:", SCOLOR_ASMDIR), name); } }
// prints function header static void gnu_func_header(func_t *pfn) { std_gen_func_header(pfn); char buf[MAXSTR]; const char *name = gnu_get_func_name(pfn, buf, sizeof(buf)); if ( name != NULL ) { printf_line(inf.indent, COLSTR(".desc %s, %s", SCOLOR_ASMDIR), name, pfn->is_far() ? "far" : "near"); printf_line(inf.indent, COLSTR(".proc %s", SCOLOR_ASMDIR), name); } gl_xref = 1; printf_line(0, COLSTR("%s:", SCOLOR_ASMDIR), name); }
// prints function footer static void idaapi gnu_func_footer(func_t *pfn) { char buf[MAXSTR]; const char *name = fr_get_func_name(pfn, buf, sizeof(buf)); if ( name != NULL ) printf_line(inf.indent, COLSTR(".size %s, .-%s", SCOLOR_ASMDIR), name, name); }
//-------------------------------------------------------------------------- void header(void) { gen_cmt_line("Processor : %-8.8s", inf.procName); gen_cmt_line("Target assembler: %s", ash.name); gen_cmt_line("Byte sex : %s, %s", inf.mf ? "big-endian" : "little-endian", inf.wide_high_byte_first ? "high_byte_first" : "high_byte_last"); if ( ash.header != NULL ) for ( const char **ptr=ash.header; *ptr != NULL; ptr++ ) printf_line(0,COLSTR("%s",SCOLOR_ASMDIR),*ptr); MakeNull(); printf_line(0,COLSTR("MY_BYTE .macro BYTE",SCOLOR_ASMDIR)); printf_line(0,COLSTR(" .emsg \"ERROR - Impossible to generate 8bit bytes on this processor. Please convert them to 16bit words.\"",SCOLOR_ASMDIR)); printf_line(0,COLSTR(" .endm",SCOLOR_ASMDIR)); MakeNull(); }
//-------------------------------------------------------------------------- void idaapi z8_assumes(ea_t ea) { segreg_t *Darea = get_srarea(ea); segment_t *Sarea = getseg(ea); if ( Sarea == NULL || Darea == NULL || !inf.s_assume ) return; // always show at the start of code segments int show = (ea == Sarea->startEA) && (Sarea->type == SEG_CODE); if ( show || Darea->startEA == ea ) { segreg_t our = *Darea; segreg_t *prev = show ? NULL : get_srarea(ea-1); sel_t rp = our.reg(rRp); if ( prev == NULL || prev->reg(rRp) != rp ) { if ( rp == BADSEL ) rp = 0; char num[MAX_NUMBUF]; btoa(num, sizeof(num), rp); char nbuf[MAXSTR]; qsnprintf(nbuf, sizeof(nbuf), COLSTR(".rp %s", SCOLOR_ASMDIR), num); MakeLine(nbuf, inf.indent); } } }
// prints function footer static void mits_func_footer(func_t *pfn) { char buf[MAXSTR]; const char *name = mits_get_func_name(pfn, buf, sizeof(buf)); if ( name != NULL ) printf_line(inf.indent, COLSTR(".ENDFUNC %s", SCOLOR_ASMDIR), name); }
//-------------------------------------------------------------------------- void segend(ea_t) { #if 0 segment_t *s = getseg(ea-1); if ( is_spec_segm(s->type) ) return; printf_line(0,COLSTR(";%-*s ends",SCOLOR_AUTOCMT),inf.indent-2,get_segm_name(s)); #endif }
//---------------------------------------------------------------------- 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); }
// prints function footer static void gnu_func_footer(func_t *pfn) { char buf[MAXSTR]; const char *name = gnu_get_func_name(pfn, buf, sizeof(buf)); if ( name != NULL ) printf_line(inf.indent, COLSTR(".endproc", SCOLOR_ASMDIR)); }
// -------------------------------------------------------------------------- // customised address output void idaapi out_data(ea_t ea) { // if addres is valid, use normal output function if (isLoaded(ea)) { intel_data(ea); } else { MakeLine(COLSTR("; db ?", SCOLOR_SYMBOL)); } }
//-------------------------------------------------------------------------- void header(void) { gen_cmt_line("Processor : %-8.8s [%s]", inf.procName, device); gen_cmt_line("Target assembler: %s", ash.name); gen_cmt_line("Byte sex : %s", inf.mf ? "Big endian" : "Little endian"); if ( ash.header != NULL ) for ( const char **ptr=ash.header; *ptr != NULL; ptr++ ) printf_line(0, COLSTR("%s",SCOLOR_ASMDIR),*ptr); }
// prints function footer static void idaapi gnu_func_footer(func_t *pfn) { qstring namebuf; if ( fr_get_func_name(&namebuf, pfn) ) { const char *name = namebuf.begin(); printf_line(inf.indent, COLSTR(".size %s, .-%s", SCOLOR_ASMDIR), name, name); } }
//-------------------------------------------------------------------------- void segstart(ea_t ea) { const char *predefined[] = { ".text", // Text section ".rdata", // Read-only data section ".data", // Data sections ".lit8", // Data sections ".lit4", // Data sections ".sdata", // Small data section, addressed through register $gp ".sbss", // Small bss section, addressed through register $gp ".bss", // bss (block started by storage) section, which loads zero-initialized data }; segment_t *Sarea = getseg(ea); if ( is_spec_segm(Sarea->type) ) return; char sname[MAXNAMELEN]; char sclas[MAXNAMELEN]; get_true_segm_name(Sarea, sname, sizeof(sname)); get_segm_class(Sarea, sclas, sizeof(sclas)); int i; for ( i=0; i < qnumber(predefined); i++ ) if ( strcmp(sname, predefined[i]) == 0 ) break; if ( i != qnumber(predefined) ) printf_line(inf.indent, COLSTR("%s", SCOLOR_ASMDIR), sname); else printf_line(inf.indent, COLSTR("%s", SCOLOR_ASMDIR) "" COLSTR("%s %s", SCOLOR_AUTOCMT), strcmp(sclas,"CODE") == 0 ? ".text" : strcmp(sclas,"BSS") == 0 ? ".bss" : ".data", ash.cmnt, sname); if ( Sarea->orgbase != 0 ) { char buf[MAX_NUMBUF]; btoa(buf, sizeof(buf), Sarea->orgbase); printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.origin, buf); } }
void segstart(ea_t ea) { char buf[MAXSTR]; segment_t *Sarea = getseg(ea); char name[MAXNAMELEN]; get_segm_name(Sarea, name, sizeof(name)); if ( ash.uflag & UAS_SECT ) { if ( Sarea->type == SEG_IMEM ) { MakeLine(".RSECT", inf.indent); } else { printf_line(0, COLSTR("%s: .section", SCOLOR_ASMDIR), name); } } else { if(ash.uflag & UAS_NOSEG) printf_line(inf.indent, COLSTR("%s.segment %s", SCOLOR_AUTOCMT), ash.cmnt, name); else printf_line(inf.indent, COLSTR("segment %s",SCOLOR_ASMDIR), name); if(ash.uflag & UAS_SELSG) MakeLine(name, inf.indent); if(ash.uflag & UAS_CDSEG) MakeLine(Sarea->type == SEG_IMEM ? COLSTR("DSEG", SCOLOR_ASMDIR) : COLSTR("CSEG", SCOLOR_ASMDIR), inf.indent); // XSEG - eXternal memory } if ( inf.s_org ) { adiff_t org = ea - get_segm_base(Sarea); if ( org != 0 ) { btoa(buf, sizeof(buf), org); gen_cmt_line("%s %s", ash.origin, buf); } } }
static int out_equ(ea_t ea) { char buf[MAXSTR]; char *const end = buf + sizeof(buf); segment_t *s = getseg(ea); if ( s != NULL && s->type == SEG_IMEM && ash.a_equ != NULL) { char nbuf[MAXSTR]; char *name = get_name(BADADDR, ea, nbuf, sizeof(nbuf)); if ( name != NULL && ((ash.uflag & UAS_PBYTNODEF) == 0 || !IsPredefined(name)) ) { get_colored_name(BADADDR, ea, buf, sizeof(buf)); uchar off = uchar(ea - get_segm_base(s)); do_out_equ(buf, ash.a_equ, off); if ( (ash.uflag & UAS_AUBIT) == 0 && (off & 0xF8) == off ) { char *ptr = tag_on(tail(buf), end, COLOR_SYMBOL); APPCHAR(ptr, end, ash.uflag & UAS_NOBIT ? '_' : '.'); APPCHAR(ptr, end, '0'); tag_off(ptr, end, COLOR_SYMBOL); for ( int i=0; i < 8; i++ ) { const ioport_bit_t *b = find_bit(off, i); char *p2 = ptr; if ( b == NULL || b->name == NULL ) ptr[-1] = '0' + i; else p2 = tag_addstr(ptr-1, end, COLOR_HIDNAME, b->name); tag_off(p2, end, COLOR_SYMBOL); do_out_equ(buf, ash.a_equ, off+i); } MakeNull(); } } else { gl_name = 0; MakeLine(""); } return 1; } if ( ash.uflag & UAS_NODS ) { if ( !isLoaded(ea) && s->type == SEG_CODE ) { adiff_t org = ea - get_segm_base(s) + get_item_size(ea); btoa(buf, sizeof(buf), org); printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.origin, buf); return 1; } } return 0; }
// generate segment header void idaapi gen_segm_header(ea_t ea) { segment_t *Sarea = getseg(ea); char sname[MAXNAMELEN]; get_segm_name(Sarea, sname, sizeof(sname)); char *segname = sname; if ( ash.uflag & UAS_SEGM ) printf_line(inf.indent, COLSTR("SEGMENT %s", SCOLOR_ASMDIR), segname); else if ( ash.uflag & UAS_RSEG ) printf_line(inf.indent, COLSTR("RSEG %s", SCOLOR_ASMDIR), segname); ea_t orgbase = ea - get_segm_para(Sarea); if ( orgbase != 0 ) { char buf[MAX_NUMBUF]; btoa(buf, sizeof(buf), orgbase); printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.origin, buf); } }
//-------------------------------------------------------------------------- void idaapi segstart(ea_t ea) { segment_t *Sarea = getseg(ea); if ( is_spec_segm(Sarea->type) ) return; char sclas[MAXNAMELEN]; get_segm_class(Sarea, sclas, sizeof(sclas)); if ( strcmp(sclas,"CODE") == 0 ) printf_line(inf.indent, COLSTR(".text", SCOLOR_ASMDIR)); else if ( strcmp(sclas,"DATA") == 0 ) printf_line(inf.indent, COLSTR(".data", SCOLOR_ASMDIR)); if ( Sarea->orgbase != 0 ) { char buf[MAX_NUMBUF]; btoa(buf, sizeof(buf), Sarea->orgbase); printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.origin, buf); } }
//-------------------------------------------------------------------------- void idaapi header(void) { gen_cmt_line("Processor : %-8.8s", inf.procName); gen_cmt_line("Target assembler: %s", ash.name); gen_cmt_line("Byte sex : %s, %s", inf.mf ? "big-endian" : "little-endian", inf.wide_high_byte_first ? "high_byte_first" : "high_byte_last"); if ( ash.header != NULL ) for ( const char **ptr=ash.header; *ptr != NULL; ptr++ ) printf_line(0,COLSTR("%s",SCOLOR_ASMDIR),*ptr); MakeNull(); }
// generate segment header void idaapi gen_segm_header(ea_t ea) { segment_t *Sarea = getseg(ea); char sname[MAXNAMELEN]; get_segm_name(Sarea, sname, sizeof(sname)); char *segname = sname; if ( *segname == '_' ) *segname = '.'; printf_line(0, COLSTR(".section %s", SCOLOR_ASMDIR), segname); }
//-------------------------------------------------------------------------- static void print_segment_register(int reg, sel_t value) { if ( reg == ph.regDataSreg ) return; char buf[MAX_NUMBUF]; btoa(buf, sizeof(buf), value); switch (reg) { case ARMS: if (value == -1) break; printf_line(inf.indent,COLSTR(".arms_%s",SCOLOR_ASMDIR), value ? "on":"off"); return; case CPL: if (value == -1) break; printf_line(inf.indent,COLSTR(".cpl_%s",SCOLOR_ASMDIR), value ? "on":"off"); return; case DP: if (value == -1) break; printf_line(inf.indent,COLSTR(".dp %s",SCOLOR_ASMDIR), buf); return; } gen_cmt_line("assume %s = %s", ph.regNames[reg], buf); }
// generate header void idaapi header(void) { gen_header(GH_PRINT_ALL_BUT_BYTESEX, NULL, device); char buf[MAXSTR]; const char *n = ptype_str(); // print the processor directive .m32r, or .m32rx if ( n != NULL ) { qsnprintf(buf, sizeof(buf), COLSTR(".%s", SCOLOR_ASMDIR), n); MakeLine(buf,0); } }
//-------------------------------------------------------------------------- uchar out_problems(char str[MAXSTR], const char *prefix) { if ( curClass.extflg & XFL_C_ERRLOAD ) { myBorder(); printf_line(inf.indent, COLSTR("%s This class has had loading time problem(s)", SCOLOR_ERROR), prefix); if ( curClass.msgNode ) { MakeNull(); if ( print_loader_messages(str, prefix) == -1) return(1 ); } myBorder(); } return(0); }
void segstart( ea_t ea ) { segment_t *Sarea = getseg( ea ); char name[MAXNAMELEN]; get_segm_name(Sarea, name, sizeof(name)); gen_cmt_line( COLSTR("segment %s", SCOLOR_AUTOCMT), name ); ea_t org = ea - get_segm_base( Sarea ); if ( org != 0 ) { char buf[MAX_NUMBUF]; btoa(buf, sizeof(buf), org); gen_cmt_line("%s %s", ash.origin, buf); } }