diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2014-12-03 22:41:29 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2014-12-03 22:41:29 (GMT) |
commit | 172fce9bab61de1ffa89f731b5d10f96e209afc1 (patch) | |
tree | 31aee5a141979fa99bbf88cbf2b7990de0ec3832 /src/arch/arm/v7/thumb_16.c | |
parent | f7ef27195f8c9dc35e5e210a333b74fcfae5ad71 (diff) |
Begun to support more than the only 'ARMv7' architecture for ARM (ARM / Thumb16 / Thumb32).
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@433 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/arm/v7/thumb_16.c')
-rw-r--r-- | src/arch/arm/v7/thumb_16.c | 500 |
1 files changed, 250 insertions, 250 deletions
diff --git a/src/arch/arm/v7/thumb_16.c b/src/arch/arm/v7/thumb_16.c index a27183d..9365708 100644 --- a/src/arch/arm/v7/thumb_16.c +++ b/src/arch/arm/v7/thumb_16.c @@ -27,7 +27,7 @@ #include <stdint.h> -#include "opcodes/opcodes_thumb_16.h" +#include "opcodes/thumb_16_opcodes.h" #include "opcodes/opcodes_tmp_thumb_16.h" #include "../../../common/bconst.h" @@ -82,49 +82,49 @@ GArchInstruction *process_armv7_thumb_16_instruction_set_encoding(uint16_t raw) opcode = (raw >> 10) & b111111; - if ((opcode & b110000) == b000000) - result = process_armv7_thumb_16_shift_immediate_add_subtract_move_and_compare(raw); + if ((opcode & b110000) == b000000) + result = process_armv7_thumb_16_shift_immediate_add_subtract_move_and_compare(raw); - else if (opcode == b010000) - result = process_armv7_thumb_16_data_processing(raw); + else if (opcode == b010000) + result = process_armv7_thumb_16_data_processing(raw); - else if (opcode == b010001) - result = process_armv7_thumb_16_special_data_instructions_and_branch_and_exchange(raw); + else if (opcode == b010001) + result = process_armv7_thumb_16_special_data_instructions_and_branch_and_exchange(raw); - else if ((opcode & b111110) == b010010) - result = armv7_read_thumb_16_instr_ldr_literal(raw); + else if ((opcode & b111110) == b010010) + result = armv7_read_thumb_16_instr_ldr_literal(raw); - else if ((opcode & b111100) == b010100) - result = armv7_read_thumb_16_instr_ldr_literal(raw); + else if ((opcode & b111100) == b010100) + result = armv7_read_thumb_16_instr_ldr_literal(raw); - else if ((opcode & b111000) == b011000) - result = armv7_read_thumb_16_instr_ldr_literal(raw); + else if ((opcode & b111000) == b011000) + result = armv7_read_thumb_16_instr_ldr_literal(raw); - else if ((opcode & b111000) == b100000) - result = process_armv7_thumb_16_load_store_single_data_item(raw); + else if ((opcode & b111000) == b100000) + result = process_armv7_thumb_16_load_store_single_data_item(raw); - else if ((opcode & b111110) == b101000) - result = armv7_read_thumb_16_instr_adr(raw); + else if ((opcode & b111110) == b101000) + result = armv7_read_thumb_16_instr_adr(raw); - else if ((opcode & b111110) == b101010) - result = armv7_read_thumb_16_instr_add_sp_plus_immediate(raw); + else if ((opcode & b111110) == b101010) + result = armv7_read_thumb_16_instr_add_sp_plus_immediate(raw); - else if ((opcode & b111100) == b101100) - result = process_armv7_thumb_16_miscellaneous_16_bit_instructions(raw); + else if ((opcode & b111100) == b101100) + result = process_armv7_thumb_16_miscellaneous_16_bit_instructions(raw); - else if ((opcode & b111110) == b110000) - result = armv7_read_thumb_16_instr_stm_stmia_stmea(raw); + else if ((opcode & b111110) == b110000) + result = armv7_read_thumb_16_instr_stm_stmia_stmea(raw); - else if ((opcode & b111110) == b110010) - result = armv7_read_thumb_16_instr_ldm_ldmia_ldmfd_thumb(raw); + else if ((opcode & b111110) == b110010) + result = armv7_read_thumb_16_instr_ldm_ldmia_ldmfd_thumb(raw); - else if ((opcode & b111100) == b110100) - result = process_armv7_thumb_16_conditional_branch_and_supervisor_call(raw); + else if ((opcode & b111100) == b110100) + result = process_armv7_thumb_16_conditional_branch_and_supervisor_call(raw); - else if ((opcode & b111110) == b111000) - result = armv7_read_thumb_16_instr_b(raw); + else if ((opcode & b111110) == b111000) + result = armv7_read_thumb_16_instr_b(raw); - return result; + return result; } @@ -157,38 +157,38 @@ static GArchInstruction *process_armv7_thumb_16_shift_immediate_add_subtract_mov opcode = (raw >> 9) & b11111; - if ((opcode & b11100) == b00000) - result = armv7_read_thumb_16_instr_lsl_immediate(raw); + if ((opcode & b11100) == b00000) + result = armv7_read_thumb_16_instr_lsl_immediate(raw); - else if ((opcode & b11100) == b00100) - result = armv7_read_thumb_16_instr_lsr_immediate(raw); + else if ((opcode & b11100) == b00100) + result = armv7_read_thumb_16_instr_lsr_immediate(raw); - else if ((opcode & b11100) == b01000) - result = armv7_read_thumb_16_instr_asr_immediate(raw); + else if ((opcode & b11100) == b01000) + result = armv7_read_thumb_16_instr_asr_immediate(raw); - else if (opcode == b01100) - result = armv7_read_thumb_16_instr_add_register_thumb(raw); + else if (opcode == b01100) + result = armv7_read_thumb_16_instr_add_register_thumb(raw); - else if (opcode == b01101) - result = armv7_read_thumb_16_instr_sub_register(raw); + else if (opcode == b01101) + result = armv7_read_thumb_16_instr_sub_register(raw); - else if (opcode == b01110) - result = armv7_read_thumb_16_instr_add_immediate_thumb(raw); + else if (opcode == b01110) + result = armv7_read_thumb_16_instr_add_immediate_thumb(raw); - else if (opcode == b01111) - result = armv7_read_thumb_16_instr_sub_immediate_thumb(raw); + else if (opcode == b01111) + result = armv7_read_thumb_16_instr_sub_immediate_thumb(raw); - else if ((opcode & b11100) == b10000) - result = armv7_read_thumb_16_instr_mov_immediate(raw); + else if ((opcode & b11100) == b10000) + result = armv7_read_thumb_16_instr_mov_immediate(raw); - else if ((opcode & b11100) == b10100) - result = armv7_read_thumb_16_instr_cmp_immediate(raw); + else if ((opcode & b11100) == b10100) + result = armv7_read_thumb_16_instr_cmp_immediate(raw); - else if ((opcode & b11100) == b11000) - result = armv7_read_thumb_16_instr_add_immediate_thumb(raw); + else if ((opcode & b11100) == b11000) + result = armv7_read_thumb_16_instr_add_immediate_thumb(raw); - else if ((opcode & b11100) == b11100) - result = armv7_read_thumb_16_instr_sub_immediate_thumb(raw); + else if ((opcode & b11100) == b11100) + result = armv7_read_thumb_16_instr_sub_immediate_thumb(raw); return result; @@ -223,73 +223,73 @@ static GArchInstruction *process_armv7_thumb_16_data_processing(uint16_t raw) opcode = (raw >> 6) & b1111; - switch (opcode) - { - case b0000: - result = armv7_read_thumb_16_instr_and_register(raw); - break; + switch (opcode) + { + case b0000: + result = armv7_read_thumb_16_instr_and_register(raw); + break; - case b0001: - result = armv7_read_thumb_16_instr_eor_register(raw); - break; + case b0001: + result = armv7_read_thumb_16_instr_eor_register(raw); + break; - case b0010: - result = armv7_read_thumb_16_instr_lsl_register(raw); - break; + case b0010: + result = armv7_read_thumb_16_instr_lsl_register(raw); + break; - case b0011: - result = armv7_read_thumb_16_instr_lsr_register(raw); - break; + case b0011: + result = armv7_read_thumb_16_instr_lsr_register(raw); + break; - case b0100: - result = armv7_read_thumb_16_instr_asr_register(raw); - break; + case b0100: + result = armv7_read_thumb_16_instr_asr_register(raw); + break; - case b0101: - result = armv7_read_thumb_16_instr_adc_register(raw); - break; + case b0101: + result = armv7_read_thumb_16_instr_adc_register(raw); + break; - case b0110: - result = armv7_read_thumb_16_instr_sbc_register(raw); - break; + case b0110: + result = armv7_read_thumb_16_instr_sbc_register(raw); + break; - case b0111: - result = armv7_read_thumb_16_instr_ror_register(raw); - break; + case b0111: + result = armv7_read_thumb_16_instr_ror_register(raw); + break; - case b1000: - result = armv7_read_thumb_16_instr_tst_register(raw); - break; + case b1000: + result = armv7_read_thumb_16_instr_tst_register(raw); + break; - case b1001: - result = armv7_read_thumb_16_instr_rsb_immediate(raw); - break; + case b1001: + result = armv7_read_thumb_16_instr_rsb_immediate(raw); + break; - case b1010: - result = armv7_read_thumb_16_instr_cmp_register(raw); - break; + case b1010: + result = armv7_read_thumb_16_instr_cmp_register(raw); + break; - case b1011: - result = armv7_read_thumb_16_instr_cmn_register(raw); - break; + case b1011: + result = armv7_read_thumb_16_instr_cmn_register(raw); + break; - case b1100: - result = armv7_read_thumb_16_instr_orr_register(raw); - break; + case b1100: + result = armv7_read_thumb_16_instr_orr_register(raw); + break; - case b1101: - result = armv7_read_thumb_16_instr_mul(raw); - break; + case b1101: + result = armv7_read_thumb_16_instr_mul(raw); + break; - case b1110: - result = armv7_read_thumb_16_instr_bic_register(raw); - break; + case b1110: + result = armv7_read_thumb_16_instr_bic_register(raw); + break; - case b1111: - result = armv7_read_thumb_16_instr_mvn_register(raw); - break; + case b1111: + result = armv7_read_thumb_16_instr_mvn_register(raw); + break; - } + } return result; @@ -324,34 +324,34 @@ static GArchInstruction *process_armv7_thumb_16_special_data_instructions_and_br opcode = (raw >> 6) & b1111; - if (opcode == b0000) - result = armv7_read_thumb_16_instr_add_register_thumb(raw); + if (opcode == b0000) + result = armv7_read_thumb_16_instr_add_register_thumb(raw); - else if (opcode == b0001) - result = armv7_read_thumb_16_instr_add_register_thumb(raw); + else if (opcode == b0001) + result = armv7_read_thumb_16_instr_add_register_thumb(raw); - else if ((opcode & b1110) == b0010) - result = armv7_read_thumb_16_instr_add_register_thumb(raw); + else if ((opcode & b1110) == b0010) + result = armv7_read_thumb_16_instr_add_register_thumb(raw); - else if ((opcode & b1100) == b0100) - result = armv7_read_thumb_16_instr_cmp_register(raw); + else if ((opcode & b1100) == b0100) + result = armv7_read_thumb_16_instr_cmp_register(raw); - else if (opcode == b1000) - result = armv7_read_thumb_16_instr_mov_register_thumb(raw); + else if (opcode == b1000) + result = armv7_read_thumb_16_instr_mov_register_thumb(raw); - else if (opcode == b1001) - result = armv7_read_thumb_16_instr_mov_register_thumb(raw); + else if (opcode == b1001) + result = armv7_read_thumb_16_instr_mov_register_thumb(raw); - else if ((opcode & b1110) == b1010) - result = armv7_read_thumb_16_instr_mov_register_thumb(raw); + else if ((opcode & b1110) == b1010) + result = armv7_read_thumb_16_instr_mov_register_thumb(raw); - else if ((opcode & b1110) == b1100) - result = armv7_read_thumb_16_instr_bx(raw); + else if ((opcode & b1110) == b1100) + result = armv7_read_thumb_16_instr_bx(raw); - else if ((opcode & b1110) == b1110) - result = armv7_read_thumb_16_instr_blx_register(raw); + else if ((opcode & b1110) == b1110) + result = armv7_read_thumb_16_instr_blx_register(raw); - return result; + return result; } @@ -382,87 +382,87 @@ static GArchInstruction *process_armv7_thumb_16_load_store_single_data_item(uint result = NULL; opa = (raw >> 12) & b1111; - opb = (raw >> 9) & b111; + opb = (raw >> 9) & b111; - switch (opa) - { + switch (opa) + { case b0101: - switch (opb) - { - case b000: - result = armv7_read_thumb_16_instr_str_register(raw); - break; + switch (opb) + { + case b000: + result = armv7_read_thumb_16_instr_str_register(raw); + break; - case b001: - result = armv7_read_thumb_16_instr_strh_register(raw); - break; + case b001: + result = armv7_read_thumb_16_instr_strh_register(raw); + break; - case b010: - result = armv7_read_thumb_16_instr_strb_register(raw); - break; + case b010: + result = armv7_read_thumb_16_instr_strb_register(raw); + break; - case b011: - result = armv7_read_thumb_16_instr_ldrsb_register(raw); - break; + case b011: + result = armv7_read_thumb_16_instr_ldrsb_register(raw); + break; - case b100: - result = armv7_read_thumb_16_instr_ldr_register_thumb(raw); - break; + case b100: + result = armv7_read_thumb_16_instr_ldr_register_thumb(raw); + break; - case b101: - result = armv7_read_thumb_16_instr_ldrh_register(raw); - break; + case b101: + result = armv7_read_thumb_16_instr_ldrh_register(raw); + break; - case b110: - result = armv7_read_thumb_16_instr_ldrb_register(raw); - break; + case b110: + result = armv7_read_thumb_16_instr_ldrb_register(raw); + break; - case b111: - result = armv7_read_thumb_16_instr_ldrsh_register(raw); - break; + case b111: + result = armv7_read_thumb_16_instr_ldrsh_register(raw); + break; - } - break; + } + break; case b0110: - if ((opb & b100) == b000) - result = armv7_read_thumb_16_instr_str_immediate_thumb(raw); - else /*if ((opb & b100) == b100)*/ - result = armv7_read_thumb_16_instr_ldr_immediate_thumb(raw); + if ((opb & b100) == b000) + result = armv7_read_thumb_16_instr_str_immediate_thumb(raw); + else /*if ((opb & b100) == b100)*/ + result = armv7_read_thumb_16_instr_ldr_immediate_thumb(raw); - break; + break; case b0111: - if ((opb & b100) == b000) - result = armv7_read_thumb_16_instr_strb_immediate_thumb(raw); - else /*if ((opb & b100) == b100)*/ - result = armv7_read_thumb_16_instr_ldrb_immediate_thumb(raw); + if ((opb & b100) == b000) + result = armv7_read_thumb_16_instr_strb_immediate_thumb(raw); + else /*if ((opb & b100) == b100)*/ + result = armv7_read_thumb_16_instr_ldrb_immediate_thumb(raw); - break; + break; case b1000: - if ((opb & b100) == b000) - result = armv7_read_thumb_16_instr_strh_immediate_thumb(raw); - else /*if ((opb & b100) == b100)*/ - result = armv7_read_thumb_16_instr_ldrh_immediate_thumb(raw); + if ((opb & b100) == b000) + result = armv7_read_thumb_16_instr_strh_immediate_thumb(raw); + else /*if ((opb & b100) == b100)*/ + result = armv7_read_thumb_16_instr_ldrh_immediate_thumb(raw); - break; + break; case b1001: - if ((opb & b100) == b000) - result = armv7_read_thumb_16_instr_str_immediate_thumb(raw); - else /*if ((opb & b100) == b100)*/ - result = armv7_read_thumb_16_instr_ldr_immediate_thumb(raw); + if ((opb & b100) == b000) + result = armv7_read_thumb_16_instr_str_immediate_thumb(raw); + else /*if ((opb & b100) == b100)*/ + result = armv7_read_thumb_16_instr_ldr_immediate_thumb(raw); - break; + break; - } + } - return result; + return result; } @@ -495,64 +495,64 @@ static GArchInstruction *process_armv7_thumb_16_miscellaneous_16_bit_instruction opcode = (raw >> 5) & b1111111; - if ((opcode & b1111100) == b0000000) - result = armv7_read_thumb_16_instr_add_sp_plus_immediate(raw); + if ((opcode & b1111100) == b0000000) + result = armv7_read_thumb_16_instr_add_sp_plus_immediate(raw); - else if ((opcode & b1111100) == b0000100) - result = armv7_read_thumb_16_instr_sub_sp_minus_immediate(raw); + else if ((opcode & b1111100) == b0000100) + result = armv7_read_thumb_16_instr_sub_sp_minus_immediate(raw); - else if ((opcode & b1111000) == b0001000) - result = armv7_read_thumb_16_instr_cbnz_cbz(raw); + else if ((opcode & b1111000) == b0001000) + result = armv7_read_thumb_16_instr_cbnz_cbz(raw); - else if ((opcode & b1111110) == b0010000) - result = armv7_read_thumb_16_instr_sxth(raw); + else if ((opcode & b1111110) == b0010000) + result = armv7_read_thumb_16_instr_sxth(raw); - else if ((opcode & b1111110) == b0010010) - result = armv7_read_thumb_16_instr_sxtb(raw); + else if ((opcode & b1111110) == b0010010) + result = armv7_read_thumb_16_instr_sxtb(raw); - else if ((opcode & b1111110) == b0010100) - result = armv7_read_thumb_16_instr_uxth(raw); + else if ((opcode & b1111110) == b0010100) + result = armv7_read_thumb_16_instr_uxth(raw); - else if ((opcode & b1111110) == b0010110) - result = armv7_read_thumb_16_instr_uxtb(raw); + else if ((opcode & b1111110) == b0010110) + result = armv7_read_thumb_16_instr_uxtb(raw); - else if ((opcode & b1111000) == b0011000) - result = armv7_read_thumb_16_instr_cbnz_cbz(raw); + else if ((opcode & b1111000) == b0011000) + result = armv7_read_thumb_16_instr_cbnz_cbz(raw); - else if ((opcode & b1110000) == b0100000) - result = armv7_read_thumb_16_instr_push(raw); + else if ((opcode & b1110000) == b0100000) + result = armv7_read_thumb_16_instr_push(raw); - else if (opcode == b0110010) - result = armv7_read_thumb_16_instr_setend(raw); + else if (opcode == b0110010) + result = armv7_read_thumb_16_instr_setend(raw); - else if (opcode == b0110011) - result = armv7_read_thumb_16_instr_cps_thumb(raw); + else if (opcode == b0110011) + result = armv7_read_thumb_16_instr_cps_thumb(raw); - else if ((opcode & b1111000) == b1001000) - result = armv7_read_thumb_16_instr_cbnz_cbz(raw); + else if ((opcode & b1111000) == b1001000) + result = armv7_read_thumb_16_instr_cbnz_cbz(raw); - else if ((opcode & b1111110) == b1010000) - result = armv7_read_thumb_16_instr_rev(raw); + else if ((opcode & b1111110) == b1010000) + result = armv7_read_thumb_16_instr_rev(raw); - else if ((opcode & b1111110) == b1010010) - result = armv7_read_thumb_16_instr_rev16(raw); + else if ((opcode & b1111110) == b1010010) + result = armv7_read_thumb_16_instr_rev16(raw); - else if ((opcode & b1111110) == b1010110) - result = armv7_read_thumb_16_instr_revsh(raw); + else if ((opcode & b1111110) == b1010110) + result = armv7_read_thumb_16_instr_revsh(raw); - else if ((opcode & b1111000) == b1011000) - result = armv7_read_thumb_16_instr_cbnz_cbz(raw); + else if ((opcode & b1111000) == b1011000) + result = armv7_read_thumb_16_instr_cbnz_cbz(raw); - else if ((opcode & b1110000) == b1100000) - result = armv7_read_thumb_16_instr_pop_thumb(raw); + else if ((opcode & b1110000) == b1100000) + result = armv7_read_thumb_16_instr_pop_thumb(raw); - else if ((opcode & b1111000) == b1110000) - result = armv7_read_thumb_16_instr_bkpt(raw); + else if ((opcode & b1111000) == b1110000) + result = armv7_read_thumb_16_instr_bkpt(raw); - else if ((opcode & b1111000) == b1111000) - result = process_armv7_thumb_16_miscellaneous_16_bit_instructions_if_then_and_hints(raw); + else if ((opcode & b1111000) == b1111000) + result = process_armv7_thumb_16_miscellaneous_16_bit_instructions_if_then_and_hints(raw); - return result; + return result; } @@ -578,7 +578,7 @@ static GArchInstruction *process_armv7_thumb_16_miscellaneous_16_bit_instruction /** * Suit les directives de : * ยง A6.2.5 Miscellaneous 16-bit instructions - * |-> If-Then, and hints + * |-> If-Then, and hints */ if ((raw & 0xff00) != 0xbf00) return NULL; @@ -588,35 +588,35 @@ static GArchInstruction *process_armv7_thumb_16_miscellaneous_16_bit_instruction opa = (raw >> 4) & b1111; opb = (raw >> 0) & b1111; - if (opb == b0000) - switch (opa) - { - case b0000: - result = armv7_read_thumb_16_instr_nop(raw); - break; + if (opb == b0000) + switch (opa) + { + case b0000: + result = armv7_read_thumb_16_instr_nop(raw); + break; - case b0001: - result = armv7_read_thumb_16_instr_yield(raw); - break; + case b0001: + result = armv7_read_thumb_16_instr_yield(raw); + break; - case b0010: - result = armv7_read_thumb_16_instr_wfe(raw); - break; + case b0010: + result = armv7_read_thumb_16_instr_wfe(raw); + break; - case b0011: - result = armv7_read_thumb_16_instr_wfi(raw); - break; + case b0011: + result = armv7_read_thumb_16_instr_wfi(raw); + break; - case b0100: - result = armv7_read_thumb_16_instr_sev(raw); - break; + case b0100: + result = armv7_read_thumb_16_instr_sev(raw); + break; - } + } - else - result = armv7_read_thumb_16_instr_it(raw); + else + result = armv7_read_thumb_16_instr_it(raw); - return result; + return result; } @@ -649,22 +649,22 @@ static GArchInstruction *process_armv7_thumb_16_conditional_branch_and_superviso opcode = (raw >> 8) & b1111; - switch (opcode) - { - case b1110: - result = armv7_read_thumb_16_instr_udf(raw); - break; + switch (opcode) + { + case b1110: + result = armv7_read_thumb_16_instr_udf(raw); + break; - case b1111: - result = armv7_read_thumb_16_instr_svc_previously_swi(raw); - break; + case b1111: + result = armv7_read_thumb_16_instr_svc_previously_swi(raw); + break; - default: - result = armv7_read_thumb_16_instr_b(raw); - break; + default: + result = armv7_read_thumb_16_instr_b(raw); + break; - } + } - return result; + return result; } |