Re-implemented asm_guess_format()

This commit is contained in:
Pierre Pronchery 2012-11-30 14:40:04 +01:00
parent fb4de7ccdf
commit 65f26c5a51
2 changed files with 20 additions and 1 deletions

View File

@ -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 */ /* asm_instruction */
int asm_instruction(Asm * a, char const * name, unsigned int operands_cnt, ...) int asm_instruction(Asm * a, char const * name, unsigned int operands_cnt, ...)
{ {

View File

@ -257,7 +257,9 @@ char const * asmcode_get_filename(AsmCode * code)
/* asmcode_get_format */ /* asmcode_get_format */
char const * asmcode_get_format(AsmCode * code) 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);
} }