diff options
Diffstat (limited to 'src/arch/dalvik/dop_arithm.c')
-rw-r--r-- | src/arch/dalvik/dop_arithm.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/arch/dalvik/dop_arithm.c b/src/arch/dalvik/dop_arithm.c index 7657f99..ace8724 100644 --- a/src/arch/dalvik/dop_arithm.c +++ b/src/arch/dalvik/dop_arithm.c @@ -44,6 +44,77 @@ * * ******************************************************************************/ +GDecInstruction *dalvik_decomp_instr_arithm(const GArchInstruction *instr, GDecContext *ctx) +{ + GDecInstruction *result; /* Instruction à retourner */ + ArithmOperationType type; /* Type d'opération menée */ + GArchOperand *operand; /* Opérande de l'instruction */ + GDecInstruction *dest; /* Enregistrement du résultat */ + GDecInstruction *op1; /* Premier opérande utilisé */ + GDecInstruction *op2; /* Second opérande utilisé */ + GDecInstruction *arithm; /* Opération arithmétique */ + + switch (g_dalvik_instruction_get_opcode(G_DALVIK_INSTRUCTION(instr))) + { + case DOP_ADD_INT: + type = AOT_ADD; + break; + case DOP_SUB_INT: + type = AOT_SUB; + break; + case DOP_MUL_INT: + type = AOT_MUL; + break; + case DOP_DIV_INT: + type = AOT_DIV; + break; + case DOP_REM_INT: + type = AOT_REM; + break; + case DOP_AND_INT: + type = AOT_AND; + break; + case DOP_OR_INT: + type = AOT_OR; + break; + case DOP_XOR_INT: + type = AOT_XOR; + break; + default: + type = AOT_COUNT; + break; + } + + operand = g_arch_instruction_get_operand(instr, 0); + dest = g_dec_context_convert_register(ctx, operand); + + operand = g_arch_instruction_get_operand(instr, 1); + op1 = g_dec_context_convert_register(ctx, operand); + + operand = g_arch_instruction_get_operand(instr, 2); + op2 = g_dec_context_convert_register(ctx, operand); + + arithm = g_arithm_expression_new(G_DEC_EXPRESSION(op1), type, G_DEC_EXPRESSION(op2)); + result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(arithm)); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction d'origine à convertir. * +* ctx = contexte de la phase de décompilation. * +* * +* Description : Décompile une instruction de type 'opérations arithmétiques'.* +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + GDecInstruction *dalvik_decomp_instr_arithm_2addr(const GArchInstruction *instr, GDecContext *ctx) { GDecInstruction *result; /* Instruction à retourner */ |