diff --git a/src/asm.c b/src/asm.c index 2d21621..bbc53a1 100644 --- a/src/asm.c +++ b/src/asm.c @@ -243,6 +243,23 @@ int asm_guess_arch(Asm * a) } +/* asm_guess_format */ +int asm_guess_format(Asm * a) +{ + int ret = -1; + AsmCode * code; + char const * format; + + if((code = asmcode_new(a->arch, a->format)) == NULL) + return -1; + if((format = asmcode_get_format(code)) != NULL + && asm_set_format(a, format) == 0) + ret = 0; + asmcode_delete(code); + return ret; +} + + /* asm_instruction */ int asm_instruction(Asm * a, char const * name, unsigned int operands_cnt, ...) { diff --git a/src/code.c b/src/code.c index a159372..953a2f9 100644 --- a/src/code.c +++ b/src/code.c @@ -257,7 +257,9 @@ char const * asmcode_get_filename(AsmCode * code) /* asmcode_get_format */ char const * asmcode_get_format(AsmCode * code) { - return format_get_name(code->format); + if(code->format != NULL) + return format_get_name(code->format); + return arch_get_format(code->arch); }