static int format_att_mnemonic( x86_insn_t *insn, char *buf, int len) { int size = 0; char *suffix; if (! insn || ! buf || ! len ) return(0); memset( buf, 0, len ); /* do long jump/call prefix */ if ( insn->type == insn_jmp || insn->type == insn_call ) { if (! is_imm_jmp( x86_operand_1st(insn) ) || (x86_operand_1st(insn))->datatype != op_byte ) { /* far jump/call, use "l" prefix */ STRNCAT( buf, "l", len ); } STRNCAT( buf, insn->mnemonic, len ); return ( strlen( buf ) ); } /* do mnemonic */ STRNCAT( buf, insn->mnemonic, len ); /* do suffixes for memory operands */ if (!(insn->note & insn_note_nosuffix) && (insn->group == insn_arithmetic || insn->group == insn_logic || insn->group == insn_move || insn->group == insn_stack || insn->group == insn_string || insn->group == insn_comparison || insn->type == insn_in || insn->type == insn_out )) { if ( x86_operand_count( insn, op_explicit ) > 0 && is_memory_op( x86_operand_1st(insn) ) ){ size = x86_operand_size( x86_operand_1st( insn ) ); } else if ( x86_operand_count( insn, op_explicit ) > 1 && is_memory_op( x86_operand_2nd(insn) ) ){ size = x86_operand_size( x86_operand_2nd( insn ) ); } } if ( size == 1 ) suffix = "b"; else if ( size == 2 ) suffix = "w"; else if ( size == 4 ) suffix = "l"; else if ( size == 8 ) suffix = "q"; else suffix = ""; STRNCAT( buf, suffix, len ); return ( strlen( buf ) ); }
static int format_att_mnemonic( x86_insn_t *insn, char *buf, int len) { int size = 0; char *suffix; if (! insn || ! buf || ! len ) return(0); memset( buf, 0, len ); /* intel callf/call far is always an lcall */ if (! strcmp( "callf", insn->mnemonic ) ) { STRNCAT( buf, "lcall", len ); return ( strlen( buf ) ); } /* do long jump/call prefix */ if ( insn->type == insn_jmp || insn->type == insn_call ) { if (! is_imm_jmp( x86_operand_1st(insn) ) || (x86_operand_1st(insn))->datatype != op_byte ) { /* far jump/call, use "l" prefix */ STRNCAT( buf, "l", len ); } STRNCAT( buf, insn->mnemonic, len ); return ( strlen( buf ) ); } /* do mnemonic */ STRNCAT( buf, insn->mnemonic, len ); /* do suffixes for memory operands */ if ( x86_operand_count( insn, op_explicit ) > 0 && is_memory_op( x86_operand_1st(insn) ) ) { size = x86_operand_size( x86_operand_1st( insn ) ); } else if ( x86_operand_count( insn, op_explicit ) > 1 && is_memory_op( x86_operand_2nd(insn) ) ) { size = x86_operand_size( x86_operand_2nd( insn ) ); } if ( size == 1 ) suffix = "b"; else if ( size == 2 ) suffix = "w"; else if ( size == 4 ) suffix = "l"; else if ( size == 8 ) suffix = "q"; else suffix = ""; STRNCAT( buf, suffix, len ); return ( strlen( buf ) ); }