Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef ARM7TDMI_INL
- #define ARM7TDMI_INL 1
- #include "gba.h"
- #include "mbus.inl"
- /* =================== ARM7 HELPER =================== */
- struct arm_alu_rot_imm32 {
- uint32_t immed_8:8;
- uint32_t rorate_imm:4;
- uint32_t rd:4;
- uint32_t rn:4;
- uint32_t s:1;
- uint32_t opcode:4;
- uint32_t _0_0_1:3;
- uint32_t cond:4;
- };
- struct arm_alu_shift_imm5 {
- uint32_t rm:4;
- uint32_t _0:1;
- uint32_t shift:2;
- uint32_t shift_imm:5;
- uint32_t rd:4;
- uint32_t rn:4;
- uint32_t s:1;
- uint32_t opcode:4;
- uint32_t _0_0_0:3;
- uint32_t cond:4;
- };
- struct arm_alu_shift_rs {
- uint32_t rm:4;
- uint32_t _1:1;
- uint32_t shift:2;
- uint32_t _0:1;
- uint32_t rs:4;
- uint32_t rd:4;
- uint32_t rn:4;
- uint32_t s:1;
- uint32_t opcode:4;
- uint32_t _0_0_0:3;
- uint32_t cond:4;
- };
- struct arm_memory_access_ubw_imm12 {
- uint32_t offset12:12;
- uint32_t rd:4;
- uint32_t rn:4;
- uint32_t l:1;
- uint32_t w:1;
- uint32_t b:1;
- uint32_t u:1;
- uint32_t p:1;
- uint32_t _0_1_0:3;
- uint32_t cond:4;
- };
- struct arm_memory_access_ubw_reg {
- uint32_t rm:4;
- uint32_t _0_0_0_0_0_0_0_0:8;
- uint32_t rd:4;
- uint32_t rn:4;
- uint32_t l:1;
- uint32_t w:1;
- uint32_t b:1;
- uint32_t u:1;
- uint32_t p:1;
- uint32_t _0_1_1:3;
- uint32_t cond:4;
- };
- struct arm_memory_access_ubw_scaled {
- uint32_t rm:4;
- uint32_t _0:1;
- uint32_t shift:2;
- uint32_t shift_imm:5;
- uint32_t rd:4;
- uint32_t rn:4;
- uint32_t l:1;
- uint32_t w:1;
- uint32_t b:1;
- uint32_t u:1;
- uint32_t p:1;
- uint32_t _0_1_1:3;
- uint32_t cond:4;
- };
- struct arm_memory_access_sbh_imm8 {
- uint32_t imm_l:4;
- uint32_t _1:1;
- uint32_t h:1;
- uint32_t s:1;
- uint32_t __1:1;
- uint32_t imm_h:4;
- uint32_t rd:4;
- uint32_t rn:4;
- uint32_t l:1;
- uint32_t w:1;
- uint32_t ___1:1;
- uint32_t u:1;
- uint32_t p:1;
- uint32_t _0_0_0:3;
- uint32_t cond:4;
- };
- struct arm_memory_access_sbh_reg {
- uint32_t rm:4;
- uint32_t _1:1;
- uint32_t h:1;
- uint32_t s:1;
- uint32_t __1:1;
- uint32_t sbz:4;
- uint32_t rd:4;
- uint32_t rn:4;
- uint32_t l:1;
- uint32_t w:1;
- uint32_t _0:1;
- uint32_t u:1;
- uint32_t p:1;
- uint32_t _0_0_0:3;
- uint32_t cond:4;
- };
- struct arm_list_memory_access {
- uint32_t r0:1;
- uint32_t r1:1;
- uint32_t r2:1;
- uint32_t r3:1;
- uint32_t r4:1;
- uint32_t r5:1;
- uint32_t r6:1;
- uint32_t r7:1;
- uint32_t r8:1;
- uint32_t r9:1;
- uint32_t r10:1;
- uint32_t r11:1;
- uint32_t r12:1;
- uint32_t r13:1; /* sp */
- uint32_t r14:1; /* lr */
- uint32_t r15:1; /* pc */
- uint32_t rn:4;
- uint32_t l:1;
- uint32_t w:1;
- uint32_t s:1;
- uint32_t u:1;
- uint32_t p:1;
- uint32_t _1_0_0:3;
- uint32_t cond:4;
- };
- struct arm_atomic_memory_access {
- uint32_t rm:4;
- uint32_t _1_0_0_1:4;
- uint32_t sbz:4;
- uint32_t rd:4;
- uint32_t rn:4;
- uint32_t _0_0:2;
- uint32_t b:1;
- uint32_t _0_0_0_1_0:5;
- uint32_t cond:4;
- };
- struct arm_swi {
- uint32_t imm_24:24;
- uint32_t _1_1_1_1:4;
- uint32_t cond:4;
- };
- struct arm_mul {
- uint32_t rm:4;
- uint32_t _1_0_0_1:4;
- uint32_t rs:4;
- uint32_t rn:4;
- uint32_t rd:4;
- uint32_t s:1;
- uint32_t a:1;
- uint32_t _0_0_0_0_0_0:6;
- uint32_t cond:4;
- };
- struct arm_mul_long {
- uint32_t rm:4;
- uint32_t _1_0_0_1:4;
- uint32_t rs:4;
- uint32_t rd_lo:4;
- uint32_t rd_hi:4;
- uint32_t s:1;
- uint32_t a:1;
- uint32_t u:1;
- uint32_t _0_0_0_0_1:5;
- uint32_t cond:4;
- };
- struct arm_msr_rot_imm32 {
- uint32_t imm8:8;
- uint32_t rotate_imm:4;
- uint32_t sbo:4;
- uint32_t field_c:1;
- uint32_t field_x:1;
- uint32_t field_s:1;
- uint32_t field_f:1;
- uint32_t _1_0:2;
- uint32_t r:1;
- uint32_t _0_0_1_1_0:5;
- uint32_t cond:4;
- };
- struct arm_msr_reg {
- uint32_t rm:4;
- uint32_t _0_0_0_0:4;
- uint32_t sbz:4;
- uint32_t sbo:4;
- uint32_t field_c:1;
- uint32_t field_x:1;
- uint32_t field_s:1;
- uint32_t field_f:1;
- uint32_t _1_0:2;
- uint32_t r:1;
- uint32_t _0_0_0_1_0:5;
- uint32_t cond:4;
- };
- struct arm_mrs {
- uint32_t sbz:12;
- uint32_t rd:4;
- uint32_t sbo:4;
- uint32_t _0_0:2;
- uint32_t r:1;
- uint32_t _0_0_0_1_0:5;
- uint32_t cond:4;
- };
- struct arm_branch {
- uint32_t sign_imm:23;
- uint32_t sign_bit:1;
- uint32_t l:1;
- uint32_t _1_0_1:3;
- uint32_t cond:4;
- };
- struct arm_branch_exchange {
- uint32_t rm:4;
- uint32_t _0_0_0_1:4;
- uint32_t sbo:12;
- uint32_t _0_0_0_1_0_0_1_0:8;
- uint32_t cond:4;
- };
- /* =================== THUMB HELPER =================== */
- struct thumb_alu {
- uint16_t rd_rn:3;
- uint16_t rm_rs:3;
- uint16_t opcode:4;
- uint16_t _0_1_0_0_0_0:6;
- };
- struct thumb_branch {
- uint16_t imm10:10;
- uint16_t sign_bit:1;
- uint16_t h:2;
- uint16_t _1_1_1:3;
- };
- #define LSHIFT_RANGE_MASK(rn_mask, shift)\
- ((rn_mask) <<(shift))
- #define RSHIFT_RANGE_MASK(rn_mask, shift)\
- ((rn_mask) >>(shift))
- #define THUMB_CODE_MASK 0xffffffe
- #define ARM7_CODE_MASK 0xffffffc
- #define ARM7_MEM_MASK 0xffffffc
- finline kable
- arm7_privilege_mode (struct gba *const agb) {
- const uint32_t mode = agb->arm7.cpsr.mode & 0x0F;
- if (mode != 0)
- return true;
- else
- return false;
- }
- finline
- struct psr *arm7_mode_spsr (struct gba *const agb, const uint32_t mode) {
- struct arm7 *const arm = & agb->arm7;
- switch (mode & 0x0F) {
- case ARM7_MODE_USER: return & arm->spsr_t[SPSRb_SYSUSER];
- case ARM7_MODE_SYS: return & arm->spsr_t[SPSRb_SYSUSER];
- case ARM7_MODE_FIQ: return & arm->spsr_t[SPSRb_FIQ];
- case ARM7_MODE_MGR: return & arm->spsr_t[SPSRb_MGR];
- case ARM7_MODE_ABT: return & arm->spsr_t[SPSRb_ABT];
- case ARM7_MODE_UNDEF: return & arm->spsr_t[SPSRb_UDEF];
- case ARM7_MODE_IRQ: return & arm->spsr_t[SPSRb_IRQ];
- default: assert (0); break;
- }
- return null;
- }
- finline
- struct psr *arm7_cur_spsr (struct gba *const agb) {
- struct arm7 *const arm = & agb->arm7;
- return arm7_mode_spsr (agb, arm->cpsr.mode);
- }
- finline void
- arm7_mode_switch (struct gba *const agb, const uint32_t new_mode) {
- struct arm7 *const arm = & agb->arm7;
- const uint32_t mode = arm->cpsr.mode & 0x0F;
- kable saveR8bank = false;
- kable self_fiq = false;
- uint32_t *const regs = & arm->regs[0];
- if ( arm7_mode_spsr (agb, new_mode)
- != arm7_cur_spsr (agb) )
- {
- if (mode == ARM7_MODE_FIQ
- || (new_mode & 0x0F) == ARM7_MODE_FIQ)
- {
- saveR8bank = true;
- }
- switch (mode & 0x0F) {
- case ARM7_MODE_USER:
- case ARM7_MODE_SYS:
- arm->r1314_t[R1314b_SYSUSER+0] = regs[13];
- arm->r1314_t[R1314b_SYSUSER+1] = regs[14];
- break;
- case ARM7_MODE_MGR:
- arm->r1314_t[R1314b_MGR+0] = regs[13];
- arm->r1314_t[R1314b_MGR+1] = regs[14];
- break;
- case ARM7_MODE_ABT:
- arm->r1314_t[R1314b_ABT+0] = regs[13];
- arm->r1314_t[R1314b_ABT+1] = regs[14];
- break;
- case ARM7_MODE_UNDEF:
- arm->r1314_t[R1314b_UDEF+0] = regs[13];
- arm->r1314_t[R1314b_UDEF+1] = regs[14];
- break;
- case ARM7_MODE_IRQ:
- arm->r1314_t[R1314b_IRQ+0] = regs[13];
- arm->r1314_t[R1314b_IRQ+1] = regs[14];
- break;
- case ARM7_MODE_FIQ:
- arm->r1314_t[R1314b_FIQ+0] = regs[13];
- arm->r1314_t[R1314b_FIQ+1] = regs[14];
- self_fiq = true;
- break;
- default:
- assert (0);
- break;
- }
- if (saveR8bank != false) {
- if (self_fiq != false) {
- arm->r812_t[R812b_FIQ+0] = regs[8];
- arm->r812_t[R812b_FIQ+1] = regs[9];
- arm->r812_t[R812b_FIQ+2] = regs[10];
- arm->r812_t[R812b_FIQ+3] = regs[11];
- arm->r812_t[R812b_FIQ+4] = regs[12];
- } else {
- arm->r812_t[R812b_EXCEPT_FIQ+0] = regs[8];
- arm->r812_t[R812b_EXCEPT_FIQ+1] = regs[9];
- arm->r812_t[R812b_EXCEPT_FIQ+2] = regs[10];
- arm->r812_t[R812b_EXCEPT_FIQ+3] = regs[11];
- arm->r812_t[R812b_EXCEPT_FIQ+4] = regs[12];
- }
- }
- switch (new_mode & 0x0F) {
- case ARM7_MODE_USER:
- case ARM7_MODE_SYS:
- regs[13] = arm->r1314_t[R1314b_SYSUSER+0];
- regs[14] = arm->r1314_t[R1314b_SYSUSER+1];
- break;
- case ARM7_MODE_MGR:
- regs[13] = arm->r1314_t[R1314b_MGR+0];
- regs[14] = arm->r1314_t[R1314b_MGR+1];
- break;
- case ARM7_MODE_ABT:
- regs[13] = arm->r1314_t[R1314b_ABT+0];
- regs[14] = arm->r1314_t[R1314b_ABT+1];
- break;
- case ARM7_MODE_UNDEF:
- regs[13] = arm->r1314_t[R1314b_UDEF+0];
- regs[14] = arm->r1314_t[R1314b_UDEF+1];
- break;
- case ARM7_MODE_IRQ:
- regs[13] = arm->r1314_t[R1314b_IRQ+0];
- regs[14] = arm->r1314_t[R1314b_IRQ+1];
- break;
- case ARM7_MODE_FIQ:
- regs[13] = arm->r1314_t[R1314b_FIQ+0];
- regs[14] = arm->r1314_t[R1314b_FIQ+1];
- break;
- default:
- assert (0);
- break;
- }
- if (saveR8bank != false) {
- if (self_fiq == false) {
- regs[8] = arm->r812_t[R812b_FIQ+0];
- regs[9] = arm->r812_t[R812b_FIQ+1];
- regs[10] = arm->r812_t[R812b_FIQ+2];
- regs[11] = arm->r812_t[R812b_FIQ+3];
- regs[12] = arm->r812_t[R812b_FIQ+4];
- } else {
- regs[8] = arm->r812_t[R812b_EXCEPT_FIQ+0];
- regs[9] = arm->r812_t[R812b_EXCEPT_FIQ+1];
- regs[10] = arm->r812_t[R812b_EXCEPT_FIQ+2];
- regs[11] = arm->r812_t[R812b_EXCEPT_FIQ+3];
- regs[12] = arm->r812_t[R812b_EXCEPT_FIQ+4];
- }
- }
- }
- }
- finline void
- spsr_to_cpsr (struct gba *const agb) {
- struct psr *spsr = arm7_cur_spsr (agb);
- const uint32_t psrc = spsr->blk;
- arm7_mode_switch (agb, spsr->mode);
- agb->arm7.cpsr.blk = psrc;
- }
- finline
- int32_t mul_clks (uint32_t rs_value) {
- /* multiplier's clks, m
- see ARM7TDMI Technical Reference Manual's 6.20 Instruction speed summary
- m is:
- 1 if bits [31:8] of the multiplier operand (Rs) are all zero or one, else
- 2 if bits [31:16] of the multiplier operand (Rs) are all zero or one, else
- 3 if bits [31:24] of the multiplier operand (Rs) are all zero or all one, else
- 4. */
- if (rs_value & 0x80000000)
- rs_value = ~rs_value;
- if ((rs_value & 0xFFFFFF00) == 0)
- return 1;
- else if ((rs_value & 0xFFFF0000) == 0)
- return 2;
- else if ((rs_value & 0xFF000000) == 0)
- return 3;
- else
- return 4;
- }
- finline
- int32_t isa_arm7_mul (struct gba *const agb,
- const uint32_t opcode,
- const uint32_t a_bit,
- const uint32_t s_bit)
- {
- /* 27 26 25 24 23 22 21 20 19 - 16 15 - 12 11 10 9 8 7 6 5 4 3 2 1 0
- 0 0 0 0 0 0 A S Rd Rn Rs 1 0 0 1 Rm MUL/MLA */
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_mul *const m_code = (const struct arm_mul *const) & opcode;
- const uint32_t rs_value = arm->regs[m_code->rs];
- if (a_bit != 0) {
- /* MLA instruction */
- const uint32_t output = rs_value * regs[m_code->rm] + regs[m_code->rn];
- arm->regs[m_code->rd] = output;
- if (s_bit != 0) {
- arm->cpsr.c = 0; /* Destroy flag-c */
- arm->cpsr.z = output == 0 ? 1 : 0;
- arm->cpsr.n = output & 0x80000000 ? 1 : 0;
- }
- return mul_clks (rs_value) + 1;
- } else {
- /* MUL instruction */
- const uint32_t output = rs_value * regs[m_code->rm];
- arm->regs[m_code->rd] = output;
- if (s_bit != 0) {
- arm->cpsr.c = 0; /* Destroy flag-c */
- arm->cpsr.z = output == 0 ? 1 : 0;
- arm->cpsr.n = output & 0x80000000 ? 1 : 0;
- }
- return mul_clks (rs_value) + 1 + 1;
- }
- return 0;
- }
- finline
- int32_t isa_arm7_mul_long (struct gba *const agb,
- const uint32_t opcode,
- const uint32_t u_bit,
- const uint32_t a_bit,
- const uint32_t s_bit)
- {
- /* 27 26 25 24 23 22 21 20 19 - 16 15 - 12 11 10 9 8 7 6 5 4 3 2 1 0
- 0 0 0 0 1 U A S RdHi RdLo Rs 1 0 0 1 Rm UMULL/UMLAL/SMULL/SMLAL */
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_mul_long *const m_code = (const struct arm_mul_long *const) & opcode;
- const uint32_t rs_value = arm->regs[m_code->rs];
- if (a_bit != 0) {
- if (u_bit == 0) {
- /* UMLAL instruction */
- const uint64_t rs_value_u64 = rs_value;
- const uint64_t rm_value_u64 = regs[m_code->rm];
- const uint64_t rd_lo_value_u64 = regs[m_code->rd_lo];
- const uint64_t rd_hi_value_u64 = regs[m_code->rd_hi];
- const uint64_t output = rs_value_u64 * rm_value_u64 + (( rd_hi_value_u64 << 32) | rd_lo_value_u64);
- regs[m_code->rd_lo] = * (uint32_t *) & output;
- regs[m_code->rd_hi] = ((uint32_t *) & output) [1];
- if (s_bit != 0) {
- arm->cpsr.v = 0; /* Destroy flag-v ?? */
- arm->cpsr.c = 0; /* Destroy flag-c */
- arm->cpsr.z = output == 0 ? 1 : 0;
- arm->cpsr.n = ((uint32_t *) & output) [1] & LSHIFT_RANGE_MASK (1, 31) ? 1 : 0;
- }
- } else {
- /* SMLAL instruction */
- const int32_t rs_value_s32 = rs_value;
- const int64_t rs_value_s64 = rs_value_s32;
- const int32_t rm_value_s32 = regs[m_code->rm];
- const int64_t rm_value_s64 = rm_value_s32;
- const uint64_t rd_lo_value_u64 = regs[m_code->rd_lo];
- const uint64_t rd_hi_value_u64 = regs[m_code->rd_hi];
- const uint64_t output = rs_value_s64 * rm_value_s64 + (( rd_hi_value_u64 << 32) | rd_lo_value_u64);
- regs[m_code->rd_lo] = * (uint32_t *) & output;
- regs[m_code->rd_hi] = ((uint32_t *) & output) [1];
- if (s_bit != 0) {
- arm->cpsr.v = 0; /* Destroy flag-v ?? */
- arm->cpsr.c = 0; /* Destroy flag-c */
- arm->cpsr.z = output == 0 ? 1 : 0;
- arm->cpsr.n = ((uint32_t *) & output) [1] & LSHIFT_RANGE_MASK (1, 31) ? 1 : 0;
- }
- }
- return mul_clks (rs_value) + 1 + 2;
- } else {
- if (u_bit == 0) {
- /* UMULL instruction */
- const uint64_t rs_value_u64 = rs_value;
- const uint64_t rm_value_u64 = regs[m_code->rm];
- const uint64_t output = rs_value_u64 * rm_value_u64;
- regs[m_code->rd_lo] = * (uint32_t *) & output;
- regs[m_code->rd_hi] = ((uint32_t *) & output) [1];
- if (s_bit != 0) {
- arm->cpsr.v = 0; /* Destroy flag-v ?? */
- arm->cpsr.c = 0; /* Destroy flag-c */
- arm->cpsr.z = output == 0 ? 1 : 0;
- arm->cpsr.n = ((uint32_t *) & output) [1] & LSHIFT_RANGE_MASK (1, 31) ? 1 : 0;
- }
- } else {
- /* SMULL instruction */
- const int32_t rs_value_s32 = rs_value;
- const int64_t rs_value_s64 = rs_value_s32;
- const int32_t rm_value_s32 = regs[m_code->rm];
- const int64_t rm_value_s64 = rm_value_s32;
- const int64_t output = rs_value_s64 * rm_value_s64;
- regs[m_code->rd_lo] = * (uint32_t *) & output;
- regs[m_code->rd_hi] = ((uint32_t *) & output) [1];
- if (s_bit != 0) {
- arm->cpsr.v = 0; /* Destroy flag-v ?? */
- arm->cpsr.c = 0; /* Destroy flag-c */
- arm->cpsr.z = output == 0 ? 1 : 0;
- arm->cpsr.n = ((uint32_t *) & output) [1] & LSHIFT_RANGE_MASK (1, 31) ? 1 : 0;
- }
- }
- return mul_clks (rs_value) + 1 + 1;
- }
- return 0;
- }
- finline
- int32_t isa_arm7_atomic_swap (struct gba *const agb,
- const uint32_t opcode,
- const uint32_t b_bit)
- {
- /* 27 26 25 24 23 22 21 20 19 - 16 15 - 12 11 10 9 8 7 6 5 4 3 2 1 0
- 0 0 0 1 0 B 0 0 Rn Rd 0 0 0 0 1 0 0 1 Rm SWP/SWPB */
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_atomic_memory_access *const m_code = (const struct arm_atomic_memory_access *const) & opcode;
- if (b_bit != 0) {
- /* SWPB instruction */
- uint8_t memory;
- const int32_t wait_state = agb_mbus_rb (agb, regs[m_code->rn], & memory, false)
- + agb_mbus_wb (agb, regs[m_code->rn], regs[m_code->rm], false) + 4;
- regs[m_code->rd] = memory;
- return wait_state;
- } else {
- /* SWP instruction */
- uint32_t memory;
- const uint32_t rn_address = regs[m_code->rn];
- const uint32_t rn_rorate = (rn_address & 3) << 3;
- const int32_t wait_state = agb_mbus_rw (agb, rn_address, & memory, false)
- + agb_mbus_ww (agb, rn_address, regs[m_code->rm], false) + 4;
- if (rn_rorate != 0)
- regs[m_code->rd] = memory >> rn_rorate | memory << 32 - rn_rorate;
- else
- regs[m_code->rd] = memory;
- return wait_state;
- }
- return 0;
- }
- finline
- int32_t isa_arm7_memory_access_sbh_base (struct gba *const agb,
- const uint32_t p,
- const uint32_t u,
- const uint32_t w,
- const uint32_t l,
- const uint32_t s,
- const uint32_t h,
- const uint32_t rn,
- const uint32_t rd,
- const uint32_t rhs)
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- int32_t wait_state;
- uint32_t rn_writeback;
- uint32_t rn_address;
- if (u != 0)
- rn_writeback = regs[rn] + rhs;
- else
- rn_writeback = regs[rn] - rhs;
- if (p != 0)
- rn_address = rn_writeback;
- else
- rn_address = regs[rn];
- assert ( (l == 0 && s == 0 && h != 0) /* STRH instruction 0, 0, 1 */
- || (l != 0 && s == 0 && h != 0) /* LDRH instruction 1, 0, 1*/
- || (l != 0 && s != 0 && h == 0) /* LDRSB instruction 1, 1, 0*/
- || (l != 0 && s != 0 && h != 0) ); /* LDRSH instruction 1, 1, 1 */
- if (l == 0 && s == 0 && h != 0) {
- /* STRH instruction */
- wait_state = agb_mbus_whw ( agb, rn_address, regs[rd], false) + 2;
- if ( (w != 0 || p == 0))
- regs[rn] = rn_writeback;
- }
- if (l != 0 && s == 0 && h != 0) {
- /* LDRH instruction */
- uint32_t memory;
- wait_state = agb_mbus_rhw ( agb, rn_address,
- (uint16_t *)& memory, false) + 3;
- memory &= 0xFFFF;
- if (rn_address & 1)
- regs[rd] = memory >> 8 | memory << 24;
- else
- regs[rd] = memory;
- if ( (w != 0 || p == 0)
- && rd != rn)
- regs[rn] = rn_writeback;
- }
- if (l != 0 && s != 0 && h == 0) {
- /* LDRSB instruction */
- int8_t memory;
- wait_state = agb_mbus_rb ( agb, rn_address,
- (uint8_t *) & memory, false) + 3;
- *(int32_t *)& regs[rd] = memory;
- if ( (w != 0 || p == 0)
- && rd != rn)
- regs[rn] = rn_writeback;
- }
- if (l != 0 && s != 0 && h != 0) {
- /* LDRSH instruction */
- int16_t memory;
- wait_state = agb_mbus_rhw ( agb, rn_address,
- (uint16_t *)& memory, false) + 3;
- if (rn_address & 1)
- * (int32_t *)& regs[rd] = ((int8_t *)& memory)[1];
- else
- * (int32_t *)& regs[rd] = memory;
- if ( (w != 0 || p == 0)
- && rd != rn)
- regs[rn] = rn_writeback;
- }
- return wait_state;
- }
- finline
- int32_t isa_arm7_memory_access_sbh_pad_imm8 (struct gba *const agb,
- const uint32_t opcode,
- const uint32_t p,
- const uint32_t u,
- const uint32_t w,
- const uint32_t l,
- const uint32_t s,
- const uint32_t h)
- {
- /* 27 26 25 24 23 22 21 20 19 - 16 15 - 12 11 10 9 8 7 6 5 4 3 2 1 0
- 0 0 0 P U 1 W L Rn Rd Offset1 1 S H 1 Offset2 LDRH/STRH/LDRSB/LDRSH Imm8 */
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_memory_access_sbh_imm8 *const m_code = (const struct arm_memory_access_sbh_imm8 *const) & opcode;
- const uint32_t pad =(m_code->imm_l + (m_code->imm_h << 4));
- return isa_arm7_memory_access_sbh_base (agb, p, u, w, l, s, h, m_code->rn, m_code->rd, pad);
- }
- finline
- int32_t isa_arm7_memory_access_sbh_reg (struct gba *const agb,
- const uint32_t opcode,
- const uint32_t p,
- const uint32_t u,
- const uint32_t w,
- const uint32_t l,
- const uint32_t s,
- const uint32_t h)
- {
- /* 27 26 25 24 23 22 21 20 19 - 16 15 - 12 11 10 9 8 7 6 5 4 3 2 1 0
- 0 0 0 P U 0 W L Rn Rd 0 0 0 0 1 S H 1 Rm LDRH/STRH/LDRSB/LDRSH Register */
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_memory_access_sbh_reg *const m_code = (const struct arm_memory_access_sbh_reg *const) & opcode;
- return isa_arm7_memory_access_sbh_base (agb, p, u, w, l, s, h, m_code->rn, m_code->rd, regs[m_code->rm]);
- }
- finline
- int32_t isa_arm7_branch_exchange (struct gba *const agb,
- const uint32_t opcode)
- {
- /* 27 26 25 24 23 22 21 20 19 - 16 15 - 12 11 10 9 8 7 6 5 4 3 2 1 0
- 0 0 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 Rn BX */
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_branch_exchange *const m_code = (const struct arm_branch_exchange *const) & opcode;
- const uint32_t rm_value = regs[m_code->rm];
- if (rm_value & 1) {
- /* to thumb mode, flush thumb pipeline */
- regs[15] = rm_value & THUMB_CODE_MASK;
- arm->cpsr.thumb = 1;
- return thumb_flush (agb) + 3;
- } else {
- /* to arm7 mode, flush arm7 pipeline */
- regs[15] = rm_value & ARM7_CODE_MASK;
- arm->cpsr.thumb = 0;
- return arm7_flush (agb) + 3;
- }
- return 0;
- }
- finline
- uint32_t arm7_alu_helper_rot_imm32 (uint32_t imm8, uint32_t shift_even, uint32_t *const carry) {
- if (shift_even == 0)
- return imm8;
- else {
- if (carry == null) {
- const uint32_t shift = shift_even << 1;
- return imm8 >> shift | imm8 << 32 - shift;
- } else {
- const uint32_t shift = shift_even << 1;
- const uint32_t imm32 = imm8 >> shift | imm8 << 32 - shift;
- if (imm32 & LSHIFT_RANGE_MASK (1, 31))
- * carry = 1;
- else
- * carry = 0;
- return imm32;
- }
- }
- }
- finline
- uint32_t arm7_alu_shift_imm5 (struct arm7 *const arm, uint32_t rm /* value */, const uint32_t shift, const uint32_t imm5, uint32_t *const carry) {
- if (carry != null) {
- if (shift == 0) {
- /* shift - lsl */
- if (imm5 != 0)
- *carry = rm & LSHIFT_RANGE_MASK (1, 32 - imm5) ? 1 : 0;
- return rm << imm5;
- } else if (shift == 1) {
- /* shift - lsr */
- if (imm5 == 0) {
- *carry = rm & LSHIFT_RANGE_MASK (1, 31) ? 1 : 0;
- return 0;
- } else {
- *carry = rm & LSHIFT_RANGE_MASK (1, imm5 - 1) ? 1 : 0;
- return rm >> imm5;
- }
- } else if (shift ==2) {
- /* shift - asr */
- if (imm5 == 0) {
- if (rm & LSHIFT_RANGE_MASK (1, 31)) {
- *carry = 1;
- return 0xFFFFFFFF;
- } else {
- *carry = 0;
- return 0;
- }
- } else {
- *carry = rm & LSHIFT_RANGE_MASK (1, imm5 - 1) ? 1 : 0;
- return (int32_t) rm >> imm5;
- }
- } else if (shift == 3) {
- /* shift - ror */
- if (imm5 == 0) {
- /* shift - rrx */
- *carry = rm & LSHIFT_RANGE_MASK (1, 0) ? 1 : 0;
- return rm >> 1 | (arm->cpsr.c ? LSHIFT_RANGE_MASK (1, 31) : 0);
- } else {
- *carry = rm & LSHIFT_RANGE_MASK (1, imm5 - 1) ? 1 : 0;
- return rm >> imm5 | rm << 32 - imm5;
- }
- } else {
- assert (0);
- }
- } else {
- if (shift == 0) {
- /* shift - lsl */
- return rm << imm5;
- } else if (shift == 1) {
- /* shift - lsr */
- if (imm5 == 0)
- return 0;
- else
- return rm >> imm5;
- } else if (shift ==2) {
- /* shift - asr */
- if (imm5 == 0)
- if (rm & LSHIFT_RANGE_MASK (1, 31))
- return 0xFFFFFFFF;
- else
- return 0;
- else
- return (int32_t) rm >> imm5;
- } else if (shift == 3) {
- /* shift - ror */
- if (imm5 == 0) {
- /* shift - rrx */
- return rm >> 1 | (arm->cpsr.c != 0 ? LSHIFT_RANGE_MASK (1, 31) : 0);
- } else {
- return rm >> imm5 | rm << 32 - imm5;
- }
- } else {
- assert (0);
- }
- }
- assert (0);
- return 0;
- }
- finline
- uint32_t arm7_alu_shift_rs (struct arm7 *const arm, uint32_t rm /* value */, const uint32_t shift, const uint32_t rs /* value */, uint32_t *const carry) {
- const uint32_t rs_8bit = rs & 0xFF;
- if (rs_8bit == 0)
- return rm;
- else {
- if (carry == null) {
- if (shift == 0) {
- /* shift - lsl */
- if (rs_8bit < 32)
- return rm << rs_8bit;
- else if (rs_8bit == 32)
- return 0;
- else
- return 0;
- } else if (shift == 1) {
- /* shift - lsr */
- if (rs_8bit < 32)
- return rm >> rs_8bit;
- else if (rs_8bit == 32)
- return 0;
- else
- return 0;
- } else if (shift ==2) {
- /* shift - asr */
- if (rs_8bit < 32)
- return (int32_t) rm >> rs_8bit;
- else if (rs_8bit >= 32)
- if (rm & LSHIFT_RANGE_MASK (1, 31))
- return 0xFFFFFFFF;
- else
- return 0;
- } else if (shift == 3) {
- /* shift - ror */
- if ( (rs_8bit & 31) == 0)
- return rm;
- else
- return rm >> (rs_8bit & 31) | rm << 32 - (rs_8bit & 31);
- } else {
- assert (0);
- }
- } else {
- if (shift == 0) {
- /* shift - lsl */
- if (rs_8bit < 32) {
- * carry = rm & LSHIFT_RANGE_MASK (1, 32 - rs_8bit) ? 1 : 0;
- return rm << rs_8bit;
- } else if (rs_8bit == 32) {
- * carry = rm & 1;
- return 0;
- } else {
- * carry = 0;
- return 0;
- }
- } else if (shift == 1) {
- /* shift - lsr */
- if (rs_8bit < 32) {
- * carry = rm & LSHIFT_RANGE_MASK (1, rs_8bit - 1) ? 1 : 0;
- return rm >> rs_8bit;
- } else if (rs_8bit == 32) {
- * carry = rm & LSHIFT_RANGE_MASK (1, 31) ? 1 : 0;
- return 0;
- } else {
- * carry = 0;
- return 0;
- }
- } else if (shift ==2) {
- /* shift - asr */
- if (rs_8bit < 32) {
- * carry = rm & LSHIFT_RANGE_MASK (1, rs_8bit - 1) ? 1 : 0;
- return (int32_t) rm >> rs_8bit;
- } else if (rs_8bit >= 32) {
- if (rm & LSHIFT_RANGE_MASK (1, 31)) {
- * carry = 1;
- return 0xFFFFFFFF;
- } else {
- * carry = 0;
- return 0;
- }
- }
- } else if (shift == 3) {
- /* shift - ror */
- if ( (rs_8bit & 31) == 0) {
- * carry = rm & LSHIFT_RANGE_MASK (1, 31) ? 1 : 0;
- return rm;
- } else {
- * carry = rm & LSHIFT_RANGE_MASK (1, (rs_8bit & 31) - 1) ? 1 : 0;
- return rm >> (rs_8bit & 31) | rm << 32 - (rs_8bit & 31);
- }
- } else {
- assert (0);
- }
- }
- }
- assert (0);
- return 0;
- }
- /* ============================ ARM7 Rotate imm32 alu ============================== */
- finline int32_t
- isa_arm7_alu_rot_imm32 (struct gba *const agb,
- const uint32_t opcode,
- const kable update_rd,
- uint32_t (*const alu_operate) (const uint32_t rn, const uint32_t oprand2, const uint32_t carry, uint32_t *const output_ext),
- void (*const update_flags) (struct arm7 *const arm,
- const uint32_t shift_c,
- const uint32_t output,
- const uint32_t output_ext,
- const uint32_t sop_lhs,
- const uint32_t sop_rhs),
- const uint32_t s_bit)
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_alu_rot_imm32 *const m_code = (const struct arm_alu_rot_imm32 *const) & opcode;
- uint32_t output_ext;
- uint32_t shift_c = arm->cpsr.c;
- const uint32_t rhs = arm7_alu_helper_rot_imm32 (m_code->immed_8, m_code->rorate_imm, s_bit != 0 ? & shift_c : null);
- const uint32_t lhs = regs[m_code->rn];
- const uint32_t output = alu_operate (lhs, rhs, arm->cpsr.c, & output_ext);
- if (update_rd != false) {
- regs[m_code->rd] = output;
- }
- if (s_bit != 0) {
- if (m_code->rd == 15) {
- /* flush pipeline, switch cpu mode */
- spsr_to_cpsr (agb);
- if (arm->cpsr.thumb != 0) {
- /* FIMXE: internal adjust pc only for arm7 */
- const uint32_t pc = regs[15];
- const int32_t wait_state = thumb_flush (agb) + 3;
- regs[15] = pc;
- return wait_state;
- }
- else
- return arm7_flush (agb) + 3;
- } else {
- update_flags (arm, shift_c, output, output_ext, lhs, rhs);
- return 1;
- }
- } else {
- if (m_code->rd != 15)
- return 1;
- else
- return arm7_flush (agb) + 3;
- }
- return 0;
- }
- /* ============================ ARM7 Shift imm5 alu ============================== */
- finline int32_t
- isa_arm7_alu_shift_imm5 (struct gba *const agb,
- const uint32_t opcode,
- const uint32_t shift,
- const kable update_rd,
- uint32_t (*const alu_operate) (const uint32_t rn, const uint32_t oprand2, const uint32_t carry, uint32_t *const output_ext),
- void (*const update_flags) (struct arm7 *const arm,
- const uint32_t shift_c,
- const uint32_t output,
- const uint32_t output_ext,
- const uint32_t sop_lhs,
- const uint32_t sop_rhs),
- const uint32_t s_bit)
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_alu_shift_imm5 *const m_code = (const struct arm_alu_shift_imm5 *const) & opcode;
- uint32_t output_ext;
- uint32_t shift_c = arm->cpsr.c;
- const uint32_t rhs = arm7_alu_shift_imm5 (arm, regs[m_code->rm], shift, m_code->shift_imm, s_bit != 0 ? & shift_c : null);
- const uint32_t lhs = regs[m_code->rn];
- const uint32_t output = alu_operate (lhs, rhs, arm->cpsr.c, & output_ext);
- if (update_rd != false) {
- regs[m_code->rd] = output;
- }
- if (s_bit != 0) {
- if (m_code->rd == 15) {
- /* flush pipeline, switch cpu mode */
- spsr_to_cpsr (agb);
- if (arm->cpsr.thumb != 0) {
- /* FIMXE: internal adjust pc only for arm7 */
- const uint32_t pc = regs[15];
- const int32_t wait_state = thumb_flush (agb) + 3;
- regs[15] = pc;
- return wait_state;
- }
- else
- return arm7_flush (agb) + 3;
- } else {
- update_flags (arm, shift_c, output, output_ext, lhs, rhs);
- return 1;
- }
- } else {
- if (m_code->rd != 15)
- return 1;
- else
- return arm7_flush (agb) + 3;
- }
- return 0;
- }
- /* ============================ ARM7 Shift rs alu ============================== */
- finline int32_t
- isa_arm7_alu_shift_rs (struct gba *const agb,
- const uint32_t opcode,
- const uint32_t shift,
- const kable update_rd,
- uint32_t (*const alu_operate) (const uint32_t rn, const uint32_t oprand2, const uint32_t carry, uint32_t *const output_ext),
- void (*const update_flags) (struct arm7 *const arm,
- const uint32_t shift_c,
- const uint32_t output,
- const uint32_t output_ext,
- const uint32_t sop_lhs,
- const uint32_t sop_rhs),
- const uint32_t s_bit)
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_alu_shift_rs *const m_code = (const struct arm_alu_shift_rs *const) & opcode;
- uint32_t output_ext;
- uint32_t shift_c = arm->cpsr.c;
- const uint32_t rhs = arm7_alu_shift_rs (arm, m_code->rm == 15 ? regs[m_code->rm] + 4 : regs[m_code->rm], shift, regs[m_code->rs], s_bit != 0 ? & shift_c : null);
- const uint32_t lhs = m_code->rn == 15 ? regs[m_code->rn] + 4 : regs[m_code->rn];
- const uint32_t output = alu_operate (lhs, rhs, arm->cpsr.c, & output_ext);
- if (update_rd != false) {
- regs[m_code->rd] = output;
- }
- if (s_bit != 0) {
- if (m_code->rd == 15) {
- /* flush pipeline, switch cpu mode */
- spsr_to_cpsr (agb);
- if (arm->cpsr.thumb != 0) {
- /* FIMXE: internal adjust pc only for arm7 */
- const uint32_t pc = regs[15];
- const int32_t wait_state = thumb_flush (agb) + 3;
- regs[15] = pc;
- return wait_state;
- }
- else
- return arm7_flush (agb) + 3;
- } else {
- update_flags (arm, shift_c, output, output_ext, lhs, rhs);
- return 2;
- }
- } else {
- if (m_code->rd != 15)
- return 2;
- else
- return arm7_flush (agb) + 4;
- }
- return 0;
- }
- /* ============================ ARM7 operate main ============================== */
- finline uint32_t alu_and (const uint32_t rn, const uint32_t oprand2, const uint32_t carry, uint32_t *const output_ext) { return rn & oprand2; }
- finline uint32_t alu_eor (const uint32_t rn, const uint32_t oprand2, const uint32_t carry, uint32_t *const output_ext) { return rn ^ oprand2; }
- finline uint32_t alu_orr (const uint32_t rn, const uint32_t oprand2, const uint32_t carry, uint32_t *const output_ext) { return rn | oprand2; }
- finline uint32_t alu_mov (const uint32_t rn, const uint32_t oprand2, const uint32_t carry, uint32_t *const output_ext) { return oprand2; }
- finline uint32_t alu_mvn (const uint32_t rn, const uint32_t oprand2, const uint32_t carry, uint32_t *const output_ext) { return ~oprand2; }
- finline uint32_t alu_bic (const uint32_t rn, const uint32_t oprand2, const uint32_t carry, uint32_t *const output_ext) { return rn & ~oprand2; }
- finline
- uint32_t alu_add (const uint32_t rn, const uint32_t oprand2, const uint32_t carry, uint32_t *const output_ext) {
- uint64_t output = (uint64_t) rn + (uint64_t) oprand2;
- assert (output_ext != null);
- if (output_ext != null)
- * output_ext = * (((uint32_t *)& output) + 1);
- return (uint32_t) output;
- }
- finline
- uint32_t alu_adc (const uint32_t rn, const uint32_t oprand2, const uint32_t carry, uint32_t *const output_ext) {
- uint64_t output = (uint64_t) rn + (uint64_t) oprand2 + (carry == 0 ? 0 : 1);;
- assert (output_ext != null);
- if (output_ext != null)
- * output_ext = * (((uint32_t *)& output) + 1);
- return (uint32_t) output;
- }
- finline
- uint32_t alu_sub (const uint32_t rn, const uint32_t oprand2, const uint32_t carry, uint32_t *const output_ext) {
- uint64_t output = (uint64_t) rn - (uint64_t) oprand2;
- assert (output_ext != null);
- if (output_ext != null)
- * output_ext = * (((uint32_t *)& output) + 1);
- return (uint32_t) output;
- }
- finline
- uint32_t alu_sbc (const uint32_t rn, const uint32_t oprand2, const uint32_t carry, uint32_t *const output_ext) {
- uint64_t output = (uint64_t) rn - (uint64_t) oprand2 - (carry != 0 ? 0 : 1);
- assert (output_ext != null);
- if (output_ext != null)
- * output_ext = * (((uint32_t *)& output) + 1);
- return (uint32_t) output;
- }
- finline
- uint32_t alu_rsb (const uint32_t rn, const uint32_t oprand2, const uint32_t carry, uint32_t *const output_ext) {
- uint64_t output = (uint64_t) oprand2 - (uint64_t) rn;
- assert (output_ext != null);
- if (output_ext != null)
- * output_ext = * (((uint32_t *)& output) + 1);
- return (uint32_t) output;
- }
- finline
- uint32_t alu_rsc (const uint32_t rn, const uint32_t oprand2, const uint32_t carry, uint32_t *const output_ext) {
- uint64_t output = (uint64_t) oprand2 - (uint64_t) rn - (carry != 0 ? 0 : 1);
- assert (output_ext != null);
- if (output_ext != null)
- * output_ext = * (((uint32_t *)& output) + 1);
- return (uint32_t) output;
- }
- /* ============================ ARM7 update flags main ============================== */
- finline
- void update_flags_logic_fast (struct arm7 *const arm, const uint32_t output) {
- arm->cpsr.n = output & LSHIFT_RANGE_MASK (1, 31) ? 1 : 0;
- arm->cpsr.z = output == 0 ? 1 : 0;
- }
- finline
- void update_flags_logic (struct arm7 *const arm,
- const uint32_t shift_c,
- const uint32_t output,
- const uint32_t output_ext,
- const uint32_t sop_lhs,
- const uint32_t sop_rhs) {
- arm->cpsr.n = output & LSHIFT_RANGE_MASK (1, 31) ? 1 : 0;
- arm->cpsr.z = output == 0 ? 1 : 0;
- arm->cpsr.c = shift_c;
- }
- finline
- void update_flags_add (struct arm7 *const arm,
- const uint32_t shift_c,
- const uint32_t output,
- const uint32_t output_ext,
- const uint32_t sop_lhs,
- const uint32_t sop_rhs) {
- const uint32_t v_flag = (!((sop_lhs ^ sop_rhs) & LSHIFT_RANGE_MASK (1, 31)) && ((sop_lhs ^ output) & LSHIFT_RANGE_MASK (1, 31)));
- arm->cpsr.n = output & LSHIFT_RANGE_MASK (1, 31) ? 1 : 0;
- arm->cpsr.z = output == 0 ? 1 : 0;
- arm->cpsr.c = output_ext != 0 ? 1 : 0;
- arm->cpsr.v = v_flag != 0 ? 1 : 0;
- }
- finline
- void update_flags_sub (struct arm7 *const arm,
- const uint32_t shift_c,
- const uint32_t output,
- const uint32_t output_ext,
- const uint32_t sop_lhs,
- const uint32_t sop_rhs) {
- const uint32_t v_flag = (((sop_lhs ^ output) & LSHIFT_RANGE_MASK (1, 31)) && ((sop_lhs ^ sop_rhs) & LSHIFT_RANGE_MASK (1, 31)));
- arm->cpsr.n = output & LSHIFT_RANGE_MASK (1, 31) ? 1 : 0;
- arm->cpsr.z = output == 0 ? 1 : 0;
- arm->cpsr.c = output_ext == 0 ? 1 : 0;
- arm->cpsr.v = v_flag != 0 ? 1 : 0;
- }
- /* ============================ ARM7 alu unwind ============================== */
- finline
- int32_t isa_arm7_psr_load (struct gba *const agb,
- const uint32_t opcode)
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_mrs *const m_code = (const struct arm_mrs *const) & opcode;
- assert (m_code->rd != 15);
- if (m_code->r != 0)
- regs[m_code->rd] = arm7_cur_spsr (agb)->blk;
- else
- regs[m_code->rd] = arm->cpsr.blk;
- return 1;
- }
- finline void
- isa_arm7_store_psr_base (struct gba *const agb,
- const uint32_t r,
- const uint32_t c,
- const uint32_t f, const uint32_t value)
- {
- struct psr nw_psr;
- struct psr org_psr;
- nw_psr.blk = value;
- org_psr.blk = agb->arm7.cpsr.blk;
- if (r != 0) {
- /* write spsr */
- struct psr *const spsr = arm7_cur_spsr (agb);
- if (f != 0) {
- spsr->n = nw_psr.n;
- spsr->z = nw_psr.z;
- spsr->c = nw_psr.c;
- spsr->v = nw_psr.v;
- }
- if (c != 0) {
- spsr->mode = nw_psr.mode;
- spsr->irq = nw_psr.irq;
- spsr->fiq = nw_psr.fiq;
- spsr->thumb = nw_psr.thumb;
- spsr->mode |= 0x10;
- }
- } else {
- if (arm7_privilege_mode (agb) != false) {
- if (c == 0) {
- if (f != 0) {
- agb->arm7.cpsr.n = nw_psr.n;
- agb->arm7.cpsr.z = nw_psr.z;
- agb->arm7.cpsr.c = nw_psr.c;
- agb->arm7.cpsr.v = nw_psr.v;
- }
- } else {
- uint32_t nw_mode = nw_psr.mode & 0x0f;
- uint32_t org_mode = agb->arm7.cpsr.mode & 0x0f;
- if (org_mode != nw_mode) {
- /* will swtch mode */
- arm7_mode_switch (agb, nw_mode);
- }
- agb->arm7.cpsr.mode = nw_psr.mode | 0x10; /* or mode mask */
- agb->arm7.cpsr.irq = nw_psr.irq;
- agb->arm7.cpsr.fiq = nw_psr.fiq;
- agb->arm7.cpsr.thumb = 0;
- if (f != 0) {
- agb->arm7.cpsr.n = nw_psr.n;
- agb->arm7.cpsr.z = nw_psr.z;
- agb->arm7.cpsr.c = nw_psr.c;
- agb->arm7.cpsr.v = nw_psr.v;
- } else {
- agb->arm7.cpsr.n = org_psr.n;
- agb->arm7.cpsr.z = org_psr.z;
- agb->arm7.cpsr.c = org_psr.c;
- agb->arm7.cpsr.v = org_psr.v;
- }
- }
- } else {
- /* in user mode, only write field_f */
- if (f != 0) {
- agb->arm7.cpsr.n = nw_psr.n;
- agb->arm7.cpsr.z = nw_psr.z;
- agb->arm7.cpsr.c = nw_psr.c;
- agb->arm7.cpsr.v = nw_psr.v;
- }
- }
- }
- }
- finline
- int32_t isa_arm7_psr_store_imm (struct gba *const agb,
- const uint32_t opcode)
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_msr_rot_imm32 *const m_code = (const struct arm_msr_rot_imm32 *const) & opcode;
- const uint32_t imm32 = arm7_alu_helper_rot_imm32 (m_code->imm8, m_code->rotate_imm, null);
- isa_arm7_store_psr_base (agb, m_code->r, m_code->field_c, m_code->field_f, imm32);
- return 1;
- }
- finline
- int32_t isa_arm7_psr_store_reg (struct gba *const agb,
- const uint32_t opcode)
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_msr_reg *const m_code = (const struct arm_msr_reg *const) & opcode;
- isa_arm7_store_psr_base (agb, m_code->r, m_code->field_c, m_code->field_f, regs [m_code->rm]);
- return 1;
- }
- finline
- int32_t isa_arm7_memory_access_ubw_base (struct gba *const agb,
- const uint32_t p,
- const uint32_t u,
- const uint32_t b,
- const uint32_t w,
- const uint32_t l,
- const uint32_t rn,
- const uint32_t rd,
- const uint32_t rhs)
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- int32_t wait_state;
- uint32_t rn_writeback;
- uint32_t rn_address;
- uint32_t rn_init = regs[rn];
- if (u != 0)
- rn_writeback = regs[rn] + rhs;
- else
- rn_writeback = regs[rn] - rhs;
- if (p != 0)
- rn_address = rn_writeback;
- else
- rn_address = regs[rn];
- if (l != 0) {
- if (b != 0) {
- /* LDRB/LDRBT instruction */
- uint8_t memory;
- wait_state = agb_mbus_rb ( agb, rn_address, & memory, false) + 3;
- regs[rd] = memory;
- } else {
- /* LDR/LDRT instruction */
- uint32_t memory;
- const uint32_t rot_bit = (rn_address & 3) << 3;
- wait_state = agb_mbus_rw ( agb, rn_address, & memory, false) + 3;
- if (rot_bit == 0)
- regs[rd] = memory;
- else
- regs[rd] = memory >> rot_bit | memory << (32 - rot_bit);
- if (rd == 15) {
- /* flush pipeline */
- regs[rd] &= ARM7_CODE_MASK;
- return arm7_flush (agb) + 2 + wait_state;
- }
- }
- if ( (w != 0 || p == 0)
- && rd != rn)
- regs[rn] = rn_writeback;
- } else {
- if (b != 0) {
- /* STRB/STRBT instruction */
- wait_state = agb_mbus_wb ( agb, rn_address, regs[rd], false) + 2;
- } else {
- /* STR/STRT instruction */
- wait_state = agb_mbus_ww ( agb, rn_address, rd == 15 ? regs[rd] + 4 : regs[rd], false) + 2;
- }
- if ( (w != 0 || p == 0))
- regs[rn] = rn_writeback;
- }
- return wait_state;
- }
- finline
- int32_t isa_arm7_memory_access_ubw_imm12 (struct gba *const agb,
- const uint32_t opcode,
- const uint32_t p,
- const uint32_t u,
- const uint32_t b,
- const uint32_t w,
- const uint32_t l )
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_memory_access_ubw_imm12 *const m_code = (const struct arm_memory_access_ubw_imm12 *const) & opcode;
- return isa_arm7_memory_access_ubw_base (agb, p, u, b, w, l, m_code->rn, m_code->rd, m_code->offset12);
- }
- finline
- int32_t isa_arm7_memory_access_ubw_reg(struct gba *const agb,
- const uint32_t opcode,
- const uint32_t p,
- const uint32_t u,
- const uint32_t b,
- const uint32_t w,
- const uint32_t l )
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_memory_access_sbh_reg *const m_code = (const struct arm_memory_access_sbh_reg *const) & opcode;
- return isa_arm7_memory_access_ubw_base (agb, p, u, b, w, l, m_code->rn, m_code->rd, regs[m_code->rm]);
- }
- finline
- int32_t isa_arm7_memory_access_ubw_scaled(struct gba *const agb,
- const uint32_t opcode,
- const uint32_t shift,
- const uint32_t p,
- const uint32_t u,
- const uint32_t b,
- const uint32_t w,
- const uint32_t l )
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_memory_access_ubw_scaled *const m_code = (const struct arm_memory_access_ubw_scaled *const) & opcode;
- const uint32_t scaled = arm7_alu_shift_imm5 (arm, regs[m_code->rm], shift, m_code->shift_imm, null);
- return isa_arm7_memory_access_ubw_base (agb, p, u, b, w, l, m_code->rn, m_code->rd, scaled);
- }
- finline
- int32_t isa_arm7_list_memory_access_load (struct gba *const agb,
- const uint32_t opcode,
- const uint32_t p,
- const uint32_t u,
- const uint32_t s,
- const uint32_t w)
- #undef LDM_VECTOR_ADD
- #define LDM_VECTOR_ADD 0
- #undef LDM_VECTOR_SUB
- #define LDM_VECTOR_SUB 1
- #undef LDM_ELEM
- #define LDM_ELEM(n, vector)\
- do { \
- if (m_code->r##n != 0) { \
- wait_state += agb_mbus_rw (agb, rn_base, & regs[n], true) + 1;\
- if (vector == LDM_VECTOR_ADD)\
- rn_base += 4; \
- else if (vector == LDM_VECTOR_SUB)\
- rn_base -= 4;\
- else \
- assert (0);\
- }\
- } while (0)
- #undef LDM_ELEM_R13_R14_BANK
- #define LDM_ELEM_R13_R14_BANK(n, vector)\
- do { \
- if (m_code->r##n != 0) { \
- wait_state += agb_mbus_rw (agb, rn_base, & arm->r1314_t[R1314b_SYSUSER+((n) - 13)], true) + 1;\
- if (vector == LDM_VECTOR_ADD)\
- rn_base += 4; \
- else if (vector == LDM_VECTOR_SUB)\
- rn_base -= 4;\
- else \
- assert (0);\
- }\
- } while (0)
- #undef LDM_ELEM_R8_R12_BANK
- #define LDM_ELEM_R8_R12_BANK(n, vector)\
- do { \
- if (m_code->r##n != 0) { \
- wait_state += agb_mbus_rw (agb, rn_base, & arm->r812_t[R812b_EXCEPT_FIQ+((n) - 8)], true) + 1;\
- if (vector == LDM_VECTOR_ADD)\
- rn_base += 4; \
- else if (vector == LDM_VECTOR_SUB)\
- rn_base -= 4;\
- else \
- assert (0);\
- }\
- } while (0)
- #define LDM_ALL_BASE_POST() \
- do { \
- LDM_ELEM (0, LDM_VECTOR_ADD); \
- LDM_ELEM (1, LDM_VECTOR_ADD); \
- LDM_ELEM (2, LDM_VECTOR_ADD); \
- LDM_ELEM (3, LDM_VECTOR_ADD); \
- LDM_ELEM (4, LDM_VECTOR_ADD); \
- LDM_ELEM (5, LDM_VECTOR_ADD); \
- LDM_ELEM (6, LDM_VECTOR_ADD); \
- LDM_ELEM (7, LDM_VECTOR_ADD); \
- } while (0)
- #define LDM_ALL_BASE_NEG() \
- do { \
- LDM_ELEM (7, LDM_VECTOR_SUB); \
- LDM_ELEM (6, LDM_VECTOR_SUB); \
- LDM_ELEM (5, LDM_VECTOR_SUB); \
- LDM_ELEM (4, LDM_VECTOR_SUB); \
- LDM_ELEM (3, LDM_VECTOR_SUB); \
- LDM_ELEM (2, LDM_VECTOR_SUB); \
- LDM_ELEM (1, LDM_VECTOR_SUB); \
- LDM_ELEM (0, LDM_VECTOR_SUB); \
- } while (0)
- #undef LDM_ALL_STD_POST
- #define LDM_ALL_STD_POST() \
- do { \
- LDM_ALL_BASE_POST (); \
- LDM_ELEM (8, LDM_VECTOR_ADD); \
- LDM_ELEM (9, LDM_VECTOR_ADD); \
- LDM_ELEM (10, LDM_VECTOR_ADD); \
- LDM_ELEM (11, LDM_VECTOR_ADD); \
- LDM_ELEM (12, LDM_VECTOR_ADD); \
- LDM_ELEM (13, LDM_VECTOR_ADD); \
- LDM_ELEM (14, LDM_VECTOR_ADD); \
- LDM_ELEM (15, LDM_VECTOR_ADD);\
- } while (0)
- #undef LDM_ALL_STD_NEG
- #define LDM_ALL_STD_NEG() \
- do { \
- LDM_ELEM (15, LDM_VECTOR_SUB); \
- LDM_ELEM (14, LDM_VECTOR_SUB); \
- LDM_ELEM (13, LDM_VECTOR_SUB); \
- LDM_ELEM (12, LDM_VECTOR_SUB); \
- LDM_ELEM (11, LDM_VECTOR_SUB); \
- LDM_ELEM (10, LDM_VECTOR_SUB); \
- LDM_ELEM (9, LDM_VECTOR_SUB); \
- LDM_ELEM (8, LDM_VECTOR_SUB);\
- LDM_ALL_BASE_NEG ();\
- } while (0)
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_list_memory_access *const m_code = (const struct arm_list_memory_access *const) & opcode;
- uint32_t rn_base = rn_base = regs[m_code->rn] & ARM7_MEM_MASK;
- uint32_t wait_state = 0;
- uint32_t list = opcode & 0xffff;
- if (p != 0)
- if (u != 0)
- rn_base = regs[m_code->rn] + 4 & ARM7_MEM_MASK;
- else
- rn_base = regs[m_code->rn] - 4 & ARM7_MEM_MASK;
- else ;
- if (s != 0) {
- if (m_code->r15 != 0) {
- /* current mode ldm, switch sys-mode */
- if (u != 0) {
- LDM_ALL_STD_POST ();
- } else {
- LDM_ALL_STD_NEG ();
- }
- spsr_to_cpsr (agb);
- } else {
- /* user-mode ldm */
- const uint32_t mode = arm->cpsr.mode & 0x0f;
- if (mode == 0x0f
- || mode == 0x00)
- {
- /* sys or user mode, use same register bank */
- if (u != 0)
- {
- LDM_ALL_STD_POST ();
- }
- else
- {
- LDM_ALL_STD_NEG ();
- }
- }
- else
- {
- if (mode == 0x01)
- {
- /* fiq mode */
- if (u != 0)
- {
- LDM_ALL_BASE_POST ();
- LDM_ELEM_R8_R12_BANK (8, LDM_VECTOR_ADD);
- LDM_ELEM_R8_R12_BANK (9, LDM_VECTOR_ADD);
- LDM_ELEM_R8_R12_BANK (10, LDM_VECTOR_ADD);
- LDM_ELEM_R8_R12_BANK (11, LDM_VECTOR_ADD);
- LDM_ELEM_R8_R12_BANK (12, LDM_VECTOR_ADD);
- LDM_ELEM_R13_R14_BANK (13, LDM_VECTOR_ADD);
- LDM_ELEM_R13_R14_BANK (14, LDM_VECTOR_ADD);
- LDM_ELEM (15, LDM_VECTOR_ADD);
- }
- else
- {
- LDM_ELEM (15, LDM_VECTOR_SUB);
- LDM_ELEM_R13_R14_BANK (14, LDM_VECTOR_SUB);
- LDM_ELEM_R13_R14_BANK (13, LDM_VECTOR_SUB);
- LDM_ELEM_R8_R12_BANK (12, LDM_VECTOR_SUB);
- LDM_ELEM_R8_R12_BANK (11, LDM_VECTOR_SUB);
- LDM_ELEM_R8_R12_BANK (10, LDM_VECTOR_SUB);
- LDM_ELEM_R8_R12_BANK (9, LDM_VECTOR_SUB);
- LDM_ELEM_R8_R12_BANK (8, LDM_VECTOR_SUB);
- LDM_ALL_BASE_NEG ();
- }
- }
- else
- {
- /* not fiq mode */
- if (u != 0)
- {
- LDM_ALL_BASE_POST ();
- LDM_ELEM (8, LDM_VECTOR_ADD);
- LDM_ELEM (9, LDM_VECTOR_ADD);
- LDM_ELEM (10, LDM_VECTOR_ADD);
- LDM_ELEM (11, LDM_VECTOR_ADD);
- LDM_ELEM (12, LDM_VECTOR_ADD);
- LDM_ELEM_R13_R14_BANK (13, LDM_VECTOR_ADD);
- LDM_ELEM_R13_R14_BANK (14, LDM_VECTOR_ADD);
- LDM_ELEM (15, LDM_VECTOR_ADD);
- }
- else
- {
- LDM_ELEM (15, LDM_VECTOR_SUB);
- LDM_ELEM_R13_R14_BANK (14, LDM_VECTOR_SUB);
- LDM_ELEM_R13_R14_BANK (13, LDM_VECTOR_SUB);
- LDM_ELEM (12, LDM_VECTOR_SUB);
- LDM_ELEM (11, LDM_VECTOR_SUB);
- LDM_ELEM (10, LDM_VECTOR_SUB);
- LDM_ELEM (9, LDM_VECTOR_SUB);
- LDM_ELEM (8, LDM_VECTOR_SUB);
- LDM_ALL_BASE_NEG ();
- }
- }
- }
- }
- } else {
- /* current mode ldm */
- if (u != 0)
- {
- LDM_ALL_STD_POST ();
- }
- else
- {
- LDM_ALL_STD_NEG ();
- }
- }
- if (w != 0
- && (list & 1 << m_code->rn) == 0)
- if (p != 0)
- regs[m_code->rn] = rn_base + (u == 0 ? 4 : -4);
- else
- regs[m_code->rn] = rn_base;
- regs[m_code->rn] &= ARM7_CODE_MASK;
- if (m_code->r15 != 0)
- if (arm->cpsr.thumb !=0)
- return thumb_flush (agb) + wait_state + 4;
- else
- return arm7_flush (agb) + wait_state + 4;
- else
- return wait_state + 2;
- }
- finline
- int32_t isa_arm7_list_memory_access_store (struct gba *const agb,
- const uint32_t opcode,
- const uint32_t p,
- const uint32_t u,
- const uint32_t s,
- const uint32_t w)
- #undef STM_VECTOR_ADD
- #define STM_VECTOR_ADD 0
- #undef STM_VECTOR_SUB
- #define STM_VECTOR_SUB 1
- #undef STM_ELEM
- #define STM_ELEM(n, vector)\
- do { \
- if (m_code->r##n != 0) { \
- wait_state += agb_mbus_ww (agb, rn_base, regs[n], true) + 1;\
- if (vector == STM_VECTOR_ADD)\
- rn_base += 4; \
- else if (vector == STM_VECTOR_SUB)\
- rn_base -= 4;\
- else \
- assert (0);\
- }\
- } while (0)
- #undef STM_ELEM_R13_R14_BANK
- #define STM_ELEM_R13_R14_BANK(n, vector)\
- do { \
- if (m_code->r##n != 0) { \
- wait_state += agb_mbus_ww (agb, rn_base, arm->r1314_t[R1314b_SYSUSER+((n) - 13)], true) + 1;\
- if (vector == STM_VECTOR_ADD)\
- rn_base += 4; \
- else if (vector == STM_VECTOR_SUB)\
- rn_base -= 4;\
- else \
- assert (0);\
- }\
- } while (0)
- #undef STM_ELEM_R8_R12_BANK
- #define STM_ELEM_R8_R12_BANK(n, vector)\
- do { \
- if (m_code->r##n != 0) { \
- wait_state += agb_mbus_ww (agb, rn_base, arm->r812_t[R812b_EXCEPT_FIQ+((n) - 8)], true) + 1;\
- if (vector == STM_VECTOR_ADD)\
- rn_base += 4; \
- else if (vector == STM_VECTOR_SUB)\
- rn_base -= 4;\
- else \
- assert (0);\
- }\
- } while (0)
- #define STM_ALL_BASE_POST() \
- do { \
- STM_ELEM (0, STM_VECTOR_ADD); \
- STM_ELEM (1, STM_VECTOR_ADD); \
- STM_ELEM (2, STM_VECTOR_ADD); \
- STM_ELEM (3, STM_VECTOR_ADD); \
- STM_ELEM (4, STM_VECTOR_ADD); \
- STM_ELEM (5, STM_VECTOR_ADD); \
- STM_ELEM (6, STM_VECTOR_ADD); \
- STM_ELEM (7, STM_VECTOR_ADD); \
- } while (0)
- #define STM_ALL_BASE_NEG() \
- do { \
- STM_ELEM (7, STM_VECTOR_SUB); \
- STM_ELEM (6, STM_VECTOR_SUB); \
- STM_ELEM (5, STM_VECTOR_SUB); \
- STM_ELEM (4, STM_VECTOR_SUB); \
- STM_ELEM (3, STM_VECTOR_SUB); \
- STM_ELEM (2, STM_VECTOR_SUB); \
- STM_ELEM (1, STM_VECTOR_SUB); \
- STM_ELEM (0, STM_VECTOR_SUB); \
- } while (0)
- #undef STM_ALL_STD_POST
- #define STM_ALL_STD_POST() \
- do { \
- STM_ALL_BASE_POST (); \
- STM_ELEM (8, STM_VECTOR_ADD); \
- STM_ELEM (9, STM_VECTOR_ADD); \
- STM_ELEM (10, STM_VECTOR_ADD); \
- STM_ELEM (11, STM_VECTOR_ADD); \
- STM_ELEM (12, STM_VECTOR_ADD); \
- STM_ELEM (13, STM_VECTOR_ADD); \
- STM_ELEM (14, STM_VECTOR_ADD); \
- STM_ELEM (15, STM_VECTOR_ADD);\
- } while (0)
- #undef STM_ALL_STD_NEG
- #define STM_ALL_STD_NEG() \
- do { \
- STM_ELEM (15, STM_VECTOR_SUB); \
- STM_ELEM (14, STM_VECTOR_SUB); \
- STM_ELEM (13, STM_VECTOR_SUB); \
- STM_ELEM (12, STM_VECTOR_SUB); \
- STM_ELEM (11, STM_VECTOR_SUB); \
- STM_ELEM (10, STM_VECTOR_SUB); \
- STM_ELEM (9, STM_VECTOR_SUB); \
- STM_ELEM (8, STM_VECTOR_SUB);\
- STM_ALL_BASE_NEG ();\
- } while (0)
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_list_memory_access *const m_code = (const struct arm_list_memory_access *const) & opcode;
- uint32_t rn_base = regs[m_code->rn] & ARM7_MEM_MASK;
- uint32_t wait_state = 0;
- uint32_t list = opcode & 0xffff;
- if (p != 0)
- if (u != 0)
- rn_base = regs[m_code->rn] + 4 & ARM7_MEM_MASK;
- else
- rn_base = regs[m_code->rn] - 4 & ARM7_MEM_MASK;
- else ;
- if (s != 0) {
- /* user-mode stm */
- const uint32_t mode = arm->cpsr.mode & 0x0f;
- if (mode == 0x0f
- || mode == 0x00)
- {
- /* sys or user mode, use same register bank */
- if (u != 0)
- {
- STM_ALL_STD_POST ();
- }
- else
- {
- STM_ALL_STD_NEG ();
- }
- }
- else
- {
- if (mode == 0x01)
- {
- /* fiq mode */
- if (u != 0)
- {
- STM_ALL_BASE_POST ();
- STM_ELEM_R8_R12_BANK (8, STM_VECTOR_ADD);
- STM_ELEM_R8_R12_BANK (9, STM_VECTOR_ADD);
- STM_ELEM_R8_R12_BANK (10, STM_VECTOR_ADD);
- STM_ELEM_R8_R12_BANK (11, STM_VECTOR_ADD);
- STM_ELEM_R8_R12_BANK (12, STM_VECTOR_ADD);
- STM_ELEM_R13_R14_BANK (13, STM_VECTOR_ADD);
- STM_ELEM_R13_R14_BANK (14, STM_VECTOR_ADD);
- STM_ELEM (15, STM_VECTOR_ADD);
- }
- else
- {
- STM_ELEM (15, STM_VECTOR_SUB);
- STM_ELEM_R13_R14_BANK (14, STM_VECTOR_SUB);
- STM_ELEM_R13_R14_BANK (13, STM_VECTOR_SUB);
- STM_ELEM_R8_R12_BANK (12, STM_VECTOR_SUB);
- STM_ELEM_R8_R12_BANK (11, STM_VECTOR_SUB);
- STM_ELEM_R8_R12_BANK (10, STM_VECTOR_SUB);
- STM_ELEM_R8_R12_BANK (9, STM_VECTOR_SUB);
- STM_ELEM_R8_R12_BANK (8, STM_VECTOR_SUB);
- STM_ALL_BASE_NEG ();
- }
- }
- else
- {
- /* not fiq mode */
- if (u != 0)
- {
- STM_ALL_BASE_POST ();
- STM_ELEM (8, STM_VECTOR_ADD);
- STM_ELEM (9, STM_VECTOR_ADD);
- STM_ELEM (10, STM_VECTOR_ADD);
- STM_ELEM (11, STM_VECTOR_ADD);
- STM_ELEM (12, STM_VECTOR_ADD);
- STM_ELEM_R13_R14_BANK (13, STM_VECTOR_ADD);
- STM_ELEM_R13_R14_BANK (14, STM_VECTOR_ADD);
- STM_ELEM (15, STM_VECTOR_ADD);
- }
- else
- {
- STM_ELEM (15, STM_VECTOR_SUB);
- STM_ELEM_R13_R14_BANK (14, STM_VECTOR_SUB);
- STM_ELEM_R13_R14_BANK (13, STM_VECTOR_SUB);
- STM_ELEM (12, STM_VECTOR_SUB);
- STM_ELEM (11, STM_VECTOR_SUB);
- STM_ELEM (10, STM_VECTOR_SUB);
- STM_ELEM (9, STM_VECTOR_SUB);
- STM_ELEM (8, STM_VECTOR_SUB);
- STM_ALL_BASE_NEG ();
- }
- }
- }
- } else {
- /* current mode ldm */
- if (u != 0)
- {
- STM_ALL_STD_POST ();
- }
- else
- {
- STM_ALL_STD_NEG ();
- }
- }
- if (w != 0)
- if (p != 0)
- regs[m_code->rn] = rn_base + (u == 0 ? 4 : -4);
- else
- regs[m_code->rn] = rn_base;
- else ;
- regs[m_code->rn] &= ARM7_CODE_MASK;
- return wait_state + 1;
- }
- finline
- int32_t isa_arm7_branch_with_link (struct gba *const agb,
- const uint32_t opcode)
- {
- /* 27 26 25 24 23 22 21 20 19 - 16 15 - 12 11 10 9 8 7 6 5 4 3 2 1 0
- 1 0 1 L Offset (d23-d0) B/BL */
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_branch *const m_code = (const struct arm_branch *const) & opcode;
- const uint32_t pipeline_pc = (regs[15] & ARM7_CODE_MASK);
- const uint32_t link_reg = pipeline_pc - 4;
- uint32_t offset;
- if (m_code->sign_bit != 0) {
- const uint32_t _mask_0_22 = 0x7FFFFF;
- offset = (m_code->sign_imm & _mask_0_22 | ~_mask_0_22) << 2;
- } else {
- offset = m_code->sign_imm << 2;
- }
- regs[14] = link_reg;
- regs[15] = pipeline_pc + offset;
- return arm7_flush (agb) + 3;
- }
- finline
- int32_t isa_arm7_branch_without_link (struct gba *const agb,
- const uint32_t opcode)
- {
- /* 27 26 25 24 23 22 21 20 19 - 16 15 - 12 11 10 9 8 7 6 5 4 3 2 1 0
- 1 0 1 L Offset (d23-d0) B/BL */
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_branch *const m_code = (const struct arm_branch *const) & opcode;
- const uint32_t pipeline_pc = (regs[15] & ARM7_CODE_MASK);
- uint32_t offset;
- if (m_code->sign_bit != 0) {
- const uint32_t _mask_0_22 = 0x7FFFFF;
- offset = (m_code->sign_imm & _mask_0_22 | ~_mask_0_22) << 2;
- } else {
- offset = m_code->sign_imm << 2;
- }
- regs[15] = pipeline_pc + offset;
- return arm7_flush (agb) + 3;
- }
- finline
- int32_t isa_arm7_swi (struct gba *const agb,
- const uint32_t opcode)
- {
- /* 27 26 25 24 23 22 21 20 19 - 16 15 - 12 11 10 9 8 7 6 5 4 3 2 1 0
- 1 1 1 1 SWI Number (d23-d0) SWI */
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_swi *const m_code = (const struct arm_swi *const) & opcode;
- const uint32_t pipeline_pc = regs[15] & ARM7_CODE_MASK;
- arm7_mode_switch (agb, ARM7_MODE_MGR);
- arm->r1314_t[1+R1314b_MGR] = pipeline_pc - 4;
- arm->spsr_t[SPSRb_MGR].blk = arm->cpsr.blk;
- arm->regs[14] = pipeline_pc - 4;
- arm->cpsr.mode = ARM7_MODE_MGR;
- arm->cpsr.thumb = 0;
- arm->cpsr.irq = 1;
- arm->regs[15] = 8;
- return arm7_flush (agb) + 3;
- }
- finline
- int32_t isa_thumb_swi (struct gba *const agb,
- const uint32_t opcode)
- {
- /* 27 26 25 24 23 22 21 20 19 - 16 15 - 12 11 10 9 8 7 6 5 4 3 2 1 0
- 1 1 1 1 SWI Number (d23-d0) SWI */
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- const struct arm_swi *const m_code = (const struct arm_swi *const) & opcode;
- const uint32_t pipeline_pc = regs[15] & THUMB_CODE_MASK;
- int32_t wait_state;
- arm7_mode_switch (agb, ARM7_MODE_MGR);
- arm->r1314_t[1+R1314b_MGR] = pipeline_pc - 2;
- arm->spsr_t[SPSRb_MGR].blk = arm->cpsr.blk;
- arm->cpsr.mode = ARM7_MODE_MGR;
- arm->cpsr.thumb = 0;
- arm->cpsr.irq = 1;
- arm->regs[15] = 8;
- arm->regs[14] = pipeline_pc - 2;
- wait_state = arm7_flush (agb) + 3;
- arm->regs[15] = 14;
- return wait_state;
- }
- finline int32_t
- isa_thumb_alu (struct gba *const agb,
- const uint32_t rm_rs, /* index */
- const uint32_t rd_rn,/* index */
- const kable update_rd,
- uint32_t (*const alu_operate) (const uint32_t rn, const uint32_t oprand2, const uint32_t carry, uint32_t *const output_ext),
- void (*const update_flags) (struct arm7 *const arm,
- const uint32_t shift_c,
- const uint32_t output,
- const uint32_t output_ext,
- const uint32_t sop_lhs,
- const uint32_t sop_rhs))
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- uint32_t output_ext;
- uint32_t shift_c = arm->cpsr.c;
- const uint32_t rhs = regs[rm_rs];
- const uint32_t lhs = regs[rd_rn];
- const uint32_t output = alu_operate (lhs, rhs, arm->cpsr.c, & output_ext);
- if (update_rd != false) {
- regs[rd_rn] = output;
- }
- update_flags (arm, shift_c, output, output_ext, lhs, rhs);
- return 1;
- }
- finline
- int32_t isa_thumb_ldr_pc (struct gba *const agb,
- const uint32_t rd, /* index */
- const uint32_t imm8)
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- uint32_t const pc = regs[15] & ARM7_CODE_MASK;
- uint32_t const address = pc + imm8 * 4;
- return agb_mbus_rw ( agb, address, & regs[rd], false) + 3;
- }
- finline int32_t
- isa_thumb_add (struct gba *const agb,
- const uint32_t rhs,
- const uint32_t rn_value,
- const uint32_t rd/* index */)
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- uint32_t output_ext;
- const uint32_t lhs = rn_value;
- const uint32_t output = alu_add (lhs, rhs, arm->cpsr.c, & output_ext);
- regs[rd] = output;
- update_flags_add (arm, 0, output, output_ext, lhs, rhs);
- return 1;
- }
- finline int32_t
- isa_thumb_sub (struct gba *const agb,
- const uint32_t rhs,
- const uint32_t rn_value,
- const uint32_t rd/* index */)
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- uint32_t output_ext;
- const uint32_t lhs = rn_value;
- const uint32_t output = alu_sub (lhs, rhs, arm->cpsr.c, & output_ext);
- regs[rd] = output;
- update_flags_sub (arm, 0, output, output_ext, lhs, rhs);
- return 1;
- }
- finline int32_t
- isa_thumb_neg (struct gba *const agb,
- const uint32_t rhs,
- const uint32_t rd/* index */)
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- uint32_t output_ext;
- const uint32_t output = alu_sub (0, rhs, arm->cpsr.c, & output_ext);
- regs[rd] = output;
- update_flags_sub (arm, 0, output, output_ext, 0, rhs);
- return 1;
- }
- finline int32_t
- isa_thumb_cmp (struct gba *const agb,
- const uint32_t rhs,
- const uint32_t rn_value)
- {
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- uint32_t output_ext;
- const uint32_t lhs = rn_value;
- const uint32_t output = alu_sub (lhs, rhs, arm->cpsr.c, & output_ext);
- update_flags_sub (arm, 0, output, output_ext, lhs, rhs);
- return 1;
- }
- uint32_t old_r10 = 0;
- uint32_t old_r1 = 0;
- uint32_t old_pc = 0;
- kable show_pc = false;
- #include <Windows.h>
- finline
- uint32_t cpu_tick (struct gba *agb) {
- int consume = 0;
- struct arm7 *const arm = & agb->arm7;
- uint32_t *const regs = & arm->regs[0];
- //if (GetKeyState ('q') == 0x8000)
- // show_pc = ! show_pc;
- //if (show_pc != false)
- // printf ("oldpc %07x\n", old_pc);
- // if (old_pc == 0xA0)
- // __asm int 3
- do {
- /* check cpu mode */
- if (arm->cpsr.thumb != 0) {
- const uint16_t OP_code = arm->opcode[0];
- const uint32_t OP_throat = OP_code >> 6;
- const uint32_t OP_cond = OP_code & LSHIFT_RANGE_MASK (0x0F, 28);
- const uint32_t pc = regs[15] - 4;
- arm->opcode[0] = arm->opcode[1];
- consume += thumb_fecth_n (agb, regs[15], (uint16_t *const)& arm->opcode[1]);
- old_pc = pc;
- // / if (pc == 0x126)
- // __asm int 3
- switch (OP_throat) {
- case 0x100:
- {
- /* and rd, rm */
- const struct thumb_alu *const e5 = (const struct thumb_alu *const) & OP_code;
- const uint32_t output = regs[e5->rd_rn] & regs[e5->rm_rs];
- regs[e5->rd_rn] = output;
- update_flags_logic_fast (arm, output);
- consume ++;
- }
- break;
- case 0x101:
- {
- /* eor rd, rm */
- const struct thumb_alu *const e5 = (const struct thumb_alu *const) & OP_code;
- const uint32_t output = regs[e5->rd_rn] ^ regs[e5->rm_rs];
- regs[e5->rd_rn] = output;
- update_flags_logic_fast (arm, output);
- consume ++;
- }
- break;
- case 0x102:
- {
- /* lsl rd, rs */
- const struct thumb_alu *const e5 = (const struct thumb_alu *const) & OP_code;
- uint32_t carry = arm->cpsr.c;
- const uint32_t output = arm7_alu_shift_rs (arm, regs[e5->rd_rn], 0, regs[e5->rm_rs], & carry);
- regs[e5->rd_rn] = output;
- update_flags_logic_fast (arm, output);
- arm->cpsr.c = carry;
- consume += 2;
- }
- break;
- case 0x103:
- {
- /* lsr rd, rs */
- const struct thumb_alu *const e5 = (const struct thumb_alu *const) & OP_code;
- uint32_t carry = arm->cpsr.c;
- const uint32_t output = arm7_alu_shift_rs (arm, regs[e5->rd_rn], 1, regs[e5->rm_rs], & carry);
- regs[e5->rd_rn] = output;
- update_flags_logic_fast (arm, output);
- arm->cpsr.c = carry;
- consume += 2;
- }
- break;
- case 0x104:
- {
- /* asr rd, rs */
- const struct thumb_alu *const e5 = (const struct thumb_alu *const) & OP_code;
- uint32_t carry = arm->cpsr.c;
- const uint32_t output = arm7_alu_shift_rs (arm, regs[e5->rd_rn], 2, regs[e5->rm_rs], & carry);
- regs[e5->rd_rn] = output;
- update_flags_logic_fast (arm, output);
- arm->cpsr.c = carry;
- consume += 2;
- }
- break;
- case 0x105:
- {
- /* adc rd, rm */
- const struct thumb_alu *const e5 = (const struct thumb_alu *const) & OP_code;
- consume += isa_thumb_alu (agb, e5->rm_rs, e5->rd_rn, true, alu_adc, update_flags_add);
- }
- break;
- case 0x106:
- {
- /* sbc rd, rm */
- const struct thumb_alu *const e5 = (const struct thumb_alu *const) & OP_code;
- consume += isa_thumb_alu (agb, e5->rm_rs, e5->rd_rn, true, alu_sbc, update_flags_sub);
- }
- break;
- case 0x107:
- {
- /* ror rd, rs */
- const struct thumb_alu *const e5 = (const struct thumb_alu *const) & OP_code;
- uint32_t carry = arm->cpsr.c;
- const uint32_t output = arm7_alu_shift_rs (arm, regs[e5->rd_rn], 3, regs[e5->rm_rs], & carry);
- regs[e5->rd_rn] = output;
- update_flags_logic_fast (arm, output);
- arm->cpsr.c = carry;
- consume += 2;
- }
- break;
- case 0x108:
- {
- /* tst rn, rm */
- const struct thumb_alu *const e5 = (const struct thumb_alu *const) & OP_code;
- consume += isa_thumb_alu (agb, e5->rm_rs, e5->rd_rn, false, alu_and, update_flags_logic);
- }
- break;
- case 0x109:
- {
- /* neg rd, rm */
- const struct thumb_alu *const e5 = (const struct thumb_alu *const) & OP_code;
- consume += isa_thumb_neg (agb, regs[e5->rm_rs], e5->rd_rn);
- }
- break;
- case 0x10A:
- {
- /* cmp rn, rm */
- const struct thumb_alu *const e5 = (const struct thumb_alu *const) & OP_code;
- consume += isa_thumb_alu (agb, e5->rm_rs, e5->rd_rn, false, alu_sub, update_flags_sub);
- }
- break;
- case 0x10B:
- {
- /* cmn rd, rm */
- const struct thumb_alu *const e5 = (const struct thumb_alu *const) & OP_code;
- consume += isa_thumb_alu (agb, e5->rm_rs, e5->rd_rn, false, alu_add, update_flags_add);
- }
- break;
- case 0x10C:
- {
- /* orr rd, rm */
- const struct thumb_alu *const e5 = (const struct thumb_alu *const) & OP_code;
- consume += isa_thumb_alu (agb, e5->rm_rs, e5->rd_rn, true, alu_orr, update_flags_logic);
- }
- break;
- case 0x10D:
- {
- /* mul rd, rs */
- const struct thumb_alu *const e5 = (const struct thumb_alu *const) & OP_code;
- const uint32_t rs_value = regs[e5->rm_rs];
- const uint32_t output = regs[e5->rd_rn] * rs_value;
- regs[e5->rd_rn] = output;
- arm->cpsr.c = 0; /* Destroy flag-c */
- update_flags_logic_fast (arm, output);
- consume += mul_clks (rs_value) + 1 + 1;
- }
- break;
- case 0x10E:
- {
- /* bic rd, rm */
- const struct thumb_alu *const e5 = (const struct thumb_alu *const) & OP_code;
- consume += isa_thumb_alu (agb, e5->rm_rs, e5->rd_rn, true, alu_bic, update_flags_logic);
- }
- break;
- case 0x10F:
- {
- /* mvn rd, rm */
- const struct thumb_alu *const e5 = (const struct thumb_alu *const) & OP_code;
- consume += isa_thumb_alu (agb, e5->rm_rs, e5->rd_rn, true, alu_mvn, update_flags_logic);
- }
- break;
- case 0x1C << 5 | 0:
- case 0x1C << 5 | 1:
- case 0x1C << 5 | 2:
- case 0x1C << 5 | 3:
- case 0x1C << 5 | 4:
- case 0x1C << 5 | 5:
- case 0x1C << 5 | 6:
- case 0x1C << 5 | 7:
- case 0x1C << 5 | 8:
- case 0x1C << 5 | 9:
- case 0x1C << 5 |10:
- case 0x1C << 5 |11:
- case 0x1C << 5 |12:
- case 0x1C << 5 |13:
- case 0x1C << 5 |14:
- case 0x1C << 5 |15:
- case 0x1C << 5 |16:
- case 0x1C << 5 |17:
- case 0x1C << 5 |18:
- case 0x1C << 5 |19:
- case 0x1C << 5 |20:
- case 0x1C << 5 |21:
- case 0x1C << 5 |22:
- case 0x1C << 5 |23:
- case 0x1C << 5 |24:
- case 0x1C << 5 |25:
- case 0x1C << 5 |26:
- case 0x1C << 5 |27:
- case 0x1C << 5 |28:
- case 0x1C << 5 |29:
- case 0x1C << 5 |30:
- case 0x1C << 5 |31:
- {
- const struct thumb_branch *const m_code = (const struct thumb_branch *const) & OP_code;
- const uint32_t pipeline_pc = regs[15];
- uint32_t offset;
- if (m_code->sign_bit != 0) {
- const uint32_t _mask_0_9 = 0x3FF;
- offset = ((uint32_t) m_code->imm10 & (uint32_t) _mask_0_9 | ~ (uint32_t)_mask_0_9) << 1 ;
- } else {
- offset = (uint32_t) m_code->imm10 << 1;
- }
- regs[15] = pipeline_pc + offset;
- consume += thumb_flush (agb) + 3;
- }
- break;
- case 0x1E << 5 | 0:
- case 0x1E << 5 | 1:
- case 0x1E << 5 | 2:
- case 0x1E << 5 | 3:
- case 0x1E << 5 | 4:
- case 0x1E << 5 | 5:
- case 0x1E << 5 | 6:
- case 0x1E << 5 | 7:
- case 0x1E << 5 | 8:
- case 0x1E << 5 | 9:
- case 0x1E << 5 |10:
- case 0x1E << 5 |11:
- case 0x1E << 5 |12:
- case 0x1E << 5 |13:
- case 0x1E << 5 |14:
- case 0x1E << 5 |15:
- case 0x1E << 5 |16:
- case 0x1E << 5 |17:
- case 0x1E << 5 |18:
- case 0x1E << 5 |19:
- case 0x1E << 5 |20:
- case 0x1E << 5 |21:
- case 0x1E << 5 |22:
- case 0x1E << 5 |23:
- case 0x1E << 5 |24:
- case 0x1E << 5 |25:
- case 0x1E << 5 |26:
- case 0x1E << 5 |27:
- case 0x1E << 5 |28:
- case 0x1E << 5 |29:
- case 0x1E << 5 |30:
- case 0x1E << 5 |31:
- {
- const struct thumb_branch *const m_code = (const struct thumb_branch *const) & OP_code;
- const uint32_t pipeline_pc = regs[15];
- uint32_t offset;
- if (m_code->sign_bit != 0) {
- const uint32_t _mask_0_9 = 0x3FF;
- offset = (uint32_t) m_code->imm10 & _mask_0_9 | ~_mask_0_9;
- } else {
- offset = (uint32_t) m_code->imm10;
- }
- regs[14] = pipeline_pc + (offset << 12);
- consume += 1;
- }
- break;
- case 0x1F << 5 | 0:
- case 0x1F << 5 | 1:
- case 0x1F << 5 | 2:
- case 0x1F << 5 | 3:
- case 0x1F << 5 | 4:
- case 0x1F << 5 | 5:
- case 0x1F << 5 | 6:
- case 0x1F << 5 | 7:
- case 0x1F << 5 | 8:
- case 0x1F << 5 | 9:
- case 0x1F << 5 |10:
- case 0x1F << 5 |11:
- case 0x1F << 5 |12:
- case 0x1F << 5 |13:
- case 0x1F << 5 |14:
- case 0x1F << 5 |15:
- case 0x1F << 5 |16:
- case 0x1F << 5 |17:
- case 0x1F << 5 |18:
- case 0x1F << 5 |19:
- case 0x1F << 5 |20:
- case 0x1F << 5 |21:
- case 0x1F << 5 |22:
- case 0x1F << 5 |23:
- case 0x1F << 5 |24:
- case 0x1F << 5 |25:
- case 0x1F << 5 |26:
- case 0x1F << 5 |27:
- case 0x1F << 5 |28:
- case 0x1F << 5 |29:
- case 0x1F << 5 |30:
- case 0x1F << 5 |31:
- {
- const uint32_t save_lrlink = (regs[15] & THUMB_CODE_MASK) - 2 | 1;
- regs[15] = regs[14] + (OP_code & 0x7FF) * 2;
- regs[14] = save_lrlink;
- consume += thumb_flush (agb) + 3;;
- }
- break;
- case 0x18 << 5 | 0:
- case 0x18 << 5 | 1:
- case 0x18 << 5 | 2:
- case 0x18 << 5 | 3:
- case 0x18 << 5 | 4:
- case 0x18 << 5 | 5:
- case 0x18 << 5 | 6:
- case 0x18 << 5 | 7:
- case 0x18 << 5 | 8:
- case 0x18 << 5 | 9:
- case 0x18 << 5 |10:
- case 0x18 << 5 |11:
- case 0x18 << 5 |12:
- case 0x18 << 5 |13:
- case 0x18 << 5 |14:
- case 0x18 << 5 |15:
- case 0x18 << 5 |16:
- case 0x18 << 5 |17:
- case 0x18 << 5 |18:
- case 0x18 << 5 |19:
- case 0x18 << 5 |20:
- case 0x18 << 5 |21:
- case 0x18 << 5 |22:
- case 0x18 << 5 |23:
- case 0x18 << 5 |24:
- case 0x18 << 5 |25:
- case 0x18 << 5 |26:
- case 0x18 << 5 |27:
- case 0x18 << 5 |28:
- case 0x18 << 5 |29:
- case 0x18 << 5 |30:
- case 0x18 << 5 |31:
- consume += isa_arm7_list_memory_access_store (agb, OP_code & 0xFF | (OP_code >>8 & 7) << 16, 0, 1, 0, 1);
- break;
- case 0x19 << 5 | 0:
- case 0x19 << 5 | 1:
- case 0x19 << 5 | 2:
- case 0x19 << 5 | 3:
- case 0x19 << 5 | 4:
- case 0x19 << 5 | 5:
- case 0x19 << 5 | 6:
- case 0x19 << 5 | 7:
- case 0x19 << 5 | 8:
- case 0x19 << 5 | 9:
- case 0x19 << 5 |10:
- case 0x19 << 5 |11:
- case 0x19 << 5 |12:
- case 0x19 << 5 |13:
- case 0x19 << 5 |14:
- case 0x19 << 5 |15:
- case 0x19 << 5 |16:
- case 0x19 << 5 |17:
- case 0x19 << 5 |18:
- case 0x19 << 5 |19:
- case 0x19 << 5 |20:
- case 0x19 << 5 |21:
- case 0x19 << 5 |22:
- case 0x19 << 5 |23:
- case 0x19 << 5 |24:
- case 0x19 << 5 |25:
- case 0x19 << 5 |26:
- case 0x19 << 5 |27:
- case 0x19 << 5 |28:
- case 0x19 << 5 |29:
- case 0x19 << 5 |30:
- case 0x19 << 5 |31:
- consume += isa_arm7_list_memory_access_load (agb, OP_code & 0xFF | (OP_code >>8 & 7) << 16, 0, 1, 0, 1);
- break;
- case 0xB4 << 2 | 0:
- case 0xB4 << 2 | 1:
- case 0xB4 << 2 | 2:
- case 0xB4 << 2 | 3:
- consume += isa_arm7_list_memory_access_store (agb, OP_code & 0xFF | 13 << 16, 1, 0, 0, 1);
- break;
- case 0xB5 << 2 | 0:
- case 0xB5 << 2 | 1:
- case 0xB5 << 2 | 2:
- case 0xB5 << 2 | 3:
- consume += isa_arm7_list_memory_access_store (agb, OP_code & 0xFF | 13 << 16 | 1 << 14, 1, 0, 0, 1);
- break;
- case 0xBC << 2 | 0:
- case 0xBC << 2 | 1:
- case 0xBC << 2 | 2:
- case 0xBC << 2 | 3:
- consume += isa_arm7_list_memory_access_load (agb, OP_code & 0xFF | 13 << 16, 0, 1, 0, 1);
- break;
- case 0xBD << 2 | 0:
- case 0xBD << 2 | 1:
- case 0xBD << 2 | 2:
- case 0xBD << 2 | 3:
- consume += isa_arm7_list_memory_access_load (agb, OP_code & 0xFF | 13 << 16 | 1 << 15, 0, 1, 0, 1);
- break;
- case 0xDF << 2 | 0:
- case 0xDF << 2 | 1:
- case 0xDF << 2 | 2:
- case 0xDF << 2 | 3:
- consume += isa_thumb_swi (agb, OP_code & 0xFF);
- break;
- case 0xB0 << 2 | 0:
- case 0xB0 << 2 | 1:
- regs[13] += (OP_code & 0x7F) * 4;
- consume++;
- break;
- case 0xB0 << 2 | 2:
- case 0xB0 << 2 | 3:
- regs[13] -= (OP_code & 0x7F) * 4;
- consume++;
- break;
- case 0x00 << 5 | 0: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0, 0, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 | 1: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0, 1, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 | 2: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0, 2, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 | 3: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0, 3, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 | 4: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0, 4, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 | 5: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0, 5, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 | 6: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0, 6, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 | 7: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0, 7, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 | 8: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0, 8, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 | 9: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0, 9, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |10: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,10, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |11: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,11, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |12: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,12, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |13: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,13, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |14: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,14, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |15: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,15, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |16: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,16, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |17: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,17, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |18: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,18, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |19: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,19, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |20: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,20, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |21: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,21, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |22: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,22, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |23: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,23, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |24: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,24, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |25: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,25, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |26: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,26, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |27: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,27, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |28: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,28, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |29: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,29, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |30: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,30, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x00 << 5 |31: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 0,31, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 | 0: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1, 0, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 | 1: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1, 1, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 | 2: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1, 2, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 | 3: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1, 3, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 | 4: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1, 4, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 | 5: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1, 5, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 | 6: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1, 6, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 | 7: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1, 7, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 | 8: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1, 8, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 | 9: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1, 9, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |10: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,10, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |11: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,11, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |12: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,12, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |13: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,13, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |14: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,14, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |15: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,15, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |16: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,16, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |17: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,17, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |18: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,18, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |19: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,19, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |20: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,20, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |21: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,21, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |22: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,22, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |23: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,23, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |24: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,24, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |25: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,25, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |26: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,26, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |27: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,27, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |28: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,28, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |29: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,29, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |30: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,30, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x01 << 5 |31: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 1,31, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 | 0: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2, 0, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 | 1: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2, 1, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 | 2: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2, 2, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 | 3: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2, 3, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 | 4: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2, 4, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 | 5: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2, 5, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 | 6: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2, 6, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 | 7: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2, 7, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 | 8: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2, 8, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 | 9: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2, 9, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |10: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,10, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |11: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,11, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |12: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,12, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |13: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,13, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |14: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,14, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |15: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,15, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |16: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,16, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |17: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,17, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |18: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,18, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |19: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,19, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |20: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,20, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |21: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,21, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |22: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,22, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |23: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,23, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |24: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,24, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |25: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,25, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |26: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,26, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |27: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,27, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |28: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,28, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |29: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,29, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |30: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,30, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x02 << 5 |31: { uint32_t carry = arm->cpsr.c; regs[OP_code & 7] = arm7_alu_shift_imm5 (arm, regs[OP_code >> 3 & 7], 2,31, & carry); update_flags_logic (arm, carry, regs[OP_code & 7], 0, 0, 0); consume ++; } break;
- case 0x03 << 5 | 0: isa_thumb_add (agb, regs[0], regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 | 1: isa_thumb_add (agb, regs[1], regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 | 2: isa_thumb_add (agb, regs[2], regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 | 3: isa_thumb_add (agb, regs[3], regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 | 4: isa_thumb_add (agb, regs[4], regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 | 5: isa_thumb_add (agb, regs[5], regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 | 6: isa_thumb_add (agb, regs[6], regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 | 7: isa_thumb_add (agb, regs[7], regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 | 8: isa_thumb_sub (agb, regs[0], regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 | 9: isa_thumb_sub (agb, regs[1], regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |10: isa_thumb_sub (agb, regs[2], regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |11: isa_thumb_sub (agb, regs[3], regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |12: isa_thumb_sub (agb, regs[4], regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |13: isa_thumb_sub (agb, regs[5], regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |14: isa_thumb_sub (agb, regs[6], regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |15: isa_thumb_sub (agb, regs[7], regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |16: isa_thumb_add (agb, 0, regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |17: isa_thumb_add (agb, 1, regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |18: isa_thumb_add (agb, 2, regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |19: isa_thumb_add (agb, 3, regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |20: isa_thumb_add (agb, 4, regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |21: isa_thumb_add (agb, 5, regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |22: isa_thumb_add (agb, 6, regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |23: isa_thumb_add (agb, 7, regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |24: isa_thumb_sub (agb, 0, regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |25: isa_thumb_sub (agb, 1, regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |26: isa_thumb_sub (agb, 2, regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |27: isa_thumb_sub (agb, 3, regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |28: isa_thumb_sub (agb, 4, regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |29: isa_thumb_sub (agb, 5, regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |30: isa_thumb_sub (agb, 6, regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- case 0x03 << 5 |31: isa_thumb_sub (agb, 7, regs[OP_code >> 3 & 7], OP_code & 7); consume ++; break;
- #define MCAS_CASE(n) \
- case 0x04 << 5 | (n) * 4 + 0:\
- case 0x04 << 5 | (n) * 4 + 1:\
- case 0x04 << 5 | (n) * 4 + 2:\
- case 0x04 << 5 | (n) * 4 + 3: regs[n] = OP_code & 255; update_flags_logic_fast (arm, OP_code & 255); consume ++; break;\
- case 0x05 << 5 | (n) * 4 + 0:\
- case 0x05 << 5 | (n) * 4 + 1:\
- case 0x05 << 5 | (n) * 4 + 2:\
- case 0x05 << 5 | (n) * 4 + 3: isa_thumb_cmp (agb, OP_code & 255, regs[n]); consume ++; break; \
- case 0x06 << 5 | (n) * 4 + 0:\
- case 0x06 << 5 | (n) * 4 + 1:\
- case 0x06 << 5 | (n) * 4 + 2:\
- case 0x06 << 5 | (n) * 4 + 3: isa_thumb_add (agb, OP_code & 255, regs[n], n); consume ++; break; \
- case 0x07 << 5 | (n) * 4 + 0:\
- case 0x07 << 5 | (n) * 4 + 1:\
- case 0x07 << 5 | (n) * 4 + 2:\
- case 0x07 << 5 | (n) * 4 + 3: isa_thumb_sub (agb, OP_code & 255, regs[n], n); consume ++; break;
- MCAS_CASE (0)
- MCAS_CASE (1)
- MCAS_CASE (2)
- MCAS_CASE (3)
- MCAS_CASE (4)
- MCAS_CASE (5)
- MCAS_CASE (6)
- MCAS_CASE (7)
- case 0x08 << 5 |16:
- case 0x08 << 5 |17:
- case 0x08 << 5 |18:
- case 0x08 << 5 |19:
- {
- const uint32_t rm = OP_code >> 3 & 15;
- const uint32_t rn_rd = OP_code & 7 | (OP_code >> 7 & 1) << 3;
- regs[rn_rd] += regs[rm];
- if (rn_rd == 15) {
- regs[rn_rd] &= THUMB_CODE_MASK; /* FIXME: and -4 ?? */
- consume += thumb_flush (agb) + 3;
- } else
- consume += 1;
- }
- break;
- case 0x08 << 5 |20:
- case 0x08 << 5 |21:
- case 0x08 << 5 |22:
- case 0x08 << 5 |23:
- {
- const uint32_t rm = OP_code >> 3 & 15;
- const uint32_t rn_rd = OP_code & 7 | (OP_code >> 7 & 1) << 3;
- isa_thumb_cmp (agb, regs[rm], regs[rn_rd]);
- consume ++;
- }
- break;
- case 0x08 << 5 |24:
- case 0x08 << 5 |25:
- case 0x08 << 5 |26:
- case 0x08 << 5 |27:
- {
- const uint32_t rm = OP_code >> 3 & 15;
- const uint32_t rn_rd = OP_code & 7 | (OP_code >> 7 & 1) << 3;
- regs[rn_rd] = regs[rm];
- if (rn_rd == 15) {
- regs[rn_rd] &= THUMB_CODE_MASK; /* FIXME: and -4 ?? */
- consume += thumb_flush (agb) + 3;
- } else
- consume += 1;
- consume ++;
- }
- break;
- case 0x08 << 5 |28:
- case 0x08 << 5 |29:
- case 0x08 << 5 |30:
- case 0x08 << 5 |31:
- {
- const uint32_t rm = OP_code >> 3 & 15;
- const uint32_t thumb = regs[rm] & 1;
- const uint32_t pc = regs[rm] & THUMB_CODE_MASK;
- arm->cpsr.thumb = thumb;
- if (thumb != 0) {
- regs[15] = pc;
- consume += thumb_flush (agb) + 3;
- } else {
- const uint32_t temp_pc = pc & ARM7_CODE_MASK;
- regs[15] = temp_pc;
- consume += arm7_flush (agb) + 3;
- regs[15] = temp_pc + 8 - 2;
- }
- }
- break;
- case 0x09 << 5 | 0: consume += isa_thumb_ldr_pc (agb, 0 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 | 1: consume += isa_thumb_ldr_pc (agb, 1 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 | 2: consume += isa_thumb_ldr_pc (agb, 2 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 | 3: consume += isa_thumb_ldr_pc (agb, 3 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 | 4: consume += isa_thumb_ldr_pc (agb, 4 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 | 5: consume += isa_thumb_ldr_pc (agb, 5 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 | 6: consume += isa_thumb_ldr_pc (agb, 6 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 | 7: consume += isa_thumb_ldr_pc (agb, 7 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 | 8: consume += isa_thumb_ldr_pc (agb, 8 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 | 9: consume += isa_thumb_ldr_pc (agb, 9 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |10: consume += isa_thumb_ldr_pc (agb, 10 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |11: consume += isa_thumb_ldr_pc (agb, 11 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |12: consume += isa_thumb_ldr_pc (agb, 12 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |13: consume += isa_thumb_ldr_pc (agb, 13 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |14: consume += isa_thumb_ldr_pc (agb, 14 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |15: consume += isa_thumb_ldr_pc (agb, 15 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |16: consume += isa_thumb_ldr_pc (agb, 16 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |17: consume += isa_thumb_ldr_pc (agb, 17 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |18: consume += isa_thumb_ldr_pc (agb, 18 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |19: consume += isa_thumb_ldr_pc (agb, 19 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |20: consume += isa_thumb_ldr_pc (agb, 20 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |21: consume += isa_thumb_ldr_pc (agb, 21 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |22: consume += isa_thumb_ldr_pc (agb, 22 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |23: consume += isa_thumb_ldr_pc (agb, 23 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |24: consume += isa_thumb_ldr_pc (agb, 24 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |25: consume += isa_thumb_ldr_pc (agb, 25 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |26: consume += isa_thumb_ldr_pc (agb, 26 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |27: consume += isa_thumb_ldr_pc (agb, 27 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |28: consume += isa_thumb_ldr_pc (agb, 28 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |29: consume += isa_thumb_ldr_pc (agb, 29 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |30: consume += isa_thumb_ldr_pc (agb, 30 >> 2, OP_code & 0xFF); break;
- case 0x09 << 5 |31: consume += isa_thumb_ldr_pc (agb, 31 >> 2, OP_code & 0xFF); break;
- case 0x0A << 5 | 1 << 3 | 0: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[0]); break;
- case 0x0A << 5 | 1 << 3 | 1: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[1]); break;
- case 0x0A << 5 | 1 << 3 | 2: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[2]); break;
- case 0x0A << 5 | 1 << 3 | 3: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[3]); break;
- case 0x0A << 5 | 1 << 3 | 4: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[4]); break;
- case 0x0A << 5 | 1 << 3 | 5: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[5]); break;
- case 0x0A << 5 | 1 << 3 | 6: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[6]); break;
- case 0x0A << 5 | 1 << 3 | 7: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[7]); break;
- case 0x0A << 5 | 3 << 3 | 0: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 1, 0, OP_code >> 3 & 7, OP_code & 7, regs[0]); break;
- case 0x0A << 5 | 3 << 3 | 1: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 1, 0, OP_code >> 3 & 7, OP_code & 7, regs[1]); break;
- case 0x0A << 5 | 3 << 3 | 2: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 1, 0, OP_code >> 3 & 7, OP_code & 7, regs[2]); break;
- case 0x0A << 5 | 3 << 3 | 3: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 1, 0, OP_code >> 3 & 7, OP_code & 7, regs[3]); break;
- case 0x0A << 5 | 3 << 3 | 4: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 1, 0, OP_code >> 3 & 7, OP_code & 7, regs[4]); break;
- case 0x0A << 5 | 3 << 3 | 5: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 1, 0, OP_code >> 3 & 7, OP_code & 7, regs[5]); break;
- case 0x0A << 5 | 3 << 3 | 6: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 1, 0, OP_code >> 3 & 7, OP_code & 7, regs[6]); break;
- case 0x0A << 5 | 3 << 3 | 7: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 1, 0, OP_code >> 3 & 7, OP_code & 7, regs[7]); break;
- case 0x0B << 5 | 1 << 3 | 0: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[0]); break;
- case 0x0B << 5 | 1 << 3 | 1: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[1]); break;
- case 0x0B << 5 | 1 << 3 | 2: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[2]); break;
- case 0x0B << 5 | 1 << 3 | 3: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[3]); break;
- case 0x0B << 5 | 1 << 3 | 4: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[4]); break;
- case 0x0B << 5 | 1 << 3 | 5: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[5]); break;
- case 0x0B << 5 | 1 << 3 | 6: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[6]); break;
- case 0x0B << 5 | 1 << 3 | 7: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[7]); break;
- case 0x0B << 5 | 3 << 3 | 0: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 1, 1, OP_code >> 3 & 7, OP_code & 7, regs[0]); break;
- case 0x0B << 5 | 3 << 3 | 1: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 1, 1, OP_code >> 3 & 7, OP_code & 7, regs[1]); break;
- case 0x0B << 5 | 3 << 3 | 2: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 1, 1, OP_code >> 3 & 7, OP_code & 7, regs[2]); break;
- case 0x0B << 5 | 3 << 3 | 3: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 1, 1, OP_code >> 3 & 7, OP_code & 7, regs[3]); break;
- case 0x0B << 5 | 3 << 3 | 4: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 1, 1, OP_code >> 3 & 7, OP_code & 7, regs[4]); break;
- case 0x0B << 5 | 3 << 3 | 5: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 1, 1, OP_code >> 3 & 7, OP_code & 7, regs[5]); break;
- case 0x0B << 5 | 3 << 3 | 6: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 1, 1, OP_code >> 3 & 7, OP_code & 7, regs[6]); break;
- case 0x0B << 5 | 3 << 3 | 7: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 1, 1, OP_code >> 3 & 7, OP_code & 7, regs[7]); break;
- case 0x0A << 5 | 0 << 3 | 0: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, regs[0]); break;
- case 0x0A << 5 | 0 << 3 | 1: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, regs[1]); break;
- case 0x0A << 5 | 0 << 3 | 2: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, regs[2]); break;
- case 0x0A << 5 | 0 << 3 | 3: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, regs[3]); break;
- case 0x0A << 5 | 0 << 3 | 4: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, regs[4]); break;
- case 0x0A << 5 | 0 << 3 | 5: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, regs[5]); break;
- case 0x0A << 5 | 0 << 3 | 6: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, regs[6]); break;
- case 0x0A << 5 | 0 << 3 | 7: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, regs[7]); break;
- case 0x0A << 5 | 2 << 3 | 0: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, regs[0]); break;
- case 0x0A << 5 | 2 << 3 | 1: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, regs[1]); break;
- case 0x0A << 5 | 2 << 3 | 2: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, regs[2]); break;
- case 0x0A << 5 | 2 << 3 | 3: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, regs[3]); break;
- case 0x0A << 5 | 2 << 3 | 4: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, regs[4]); break;
- case 0x0A << 5 | 2 << 3 | 5: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, regs[5]); break;
- case 0x0A << 5 | 2 << 3 | 6: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, regs[6]); break;
- case 0x0A << 5 | 2 << 3 | 7: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, regs[7]); break;
- case 0x0B << 5 | 0 << 3 | 0: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[0]); break;
- case 0x0B << 5 | 0 << 3 | 1: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[1]); break;
- case 0x0B << 5 | 0 << 3 | 2: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[2]); break;
- case 0x0B << 5 | 0 << 3 | 3: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[3]); break;
- case 0x0B << 5 | 0 << 3 | 4: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[4]); break;
- case 0x0B << 5 | 0 << 3 | 5: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[5]); break;
- case 0x0B << 5 | 0 << 3 | 6: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[6]); break;
- case 0x0B << 5 | 0 << 3 | 7: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[7]); break;
- case 0x0B << 5 | 2 << 3 | 0: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[0]); break;
- case 0x0B << 5 | 2 << 3 | 1: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[1]); break;
- case 0x0B << 5 | 2 << 3 | 2: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[2]); break;
- case 0x0B << 5 | 2 << 3 | 3: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[3]); break;
- case 0x0B << 5 | 2 << 3 | 4: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[4]); break;
- case 0x0B << 5 | 2 << 3 | 5: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[5]); break;
- case 0x0B << 5 | 2 << 3 | 6: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[6]); break;
- case 0x0B << 5 | 2 << 3 | 7: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, regs[7]); break;
- case 0x0C << 5 | 0: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 0 * 4); break;
- case 0x0C << 5 | 1: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 1 * 4); break;
- case 0x0C << 5 | 2: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 2 * 4); break;
- case 0x0C << 5 | 3: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 3 * 4); break;
- case 0x0C << 5 | 4: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 4 * 4); break;
- case 0x0C << 5 | 5: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 5 * 4); break;
- case 0x0C << 5 | 6: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 6 * 4); break;
- case 0x0C << 5 | 7: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 7 * 4); break;
- case 0x0C << 5 | 8: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 8 * 4); break;
- case 0x0C << 5 | 9: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 9 * 4); break;
- case 0x0C << 5 |10: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 10 * 4); break;
- case 0x0C << 5 |11: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 11 * 4); break;
- case 0x0C << 5 |12: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 12 * 4); break;
- case 0x0C << 5 |13: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 13 * 4); break;
- case 0x0C << 5 |14: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 14 * 4); break;
- case 0x0C << 5 |15: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 15 * 4); break;
- case 0x0C << 5 |16: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 16 * 4); break;
- case 0x0C << 5 |17: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 17 * 4); break;
- case 0x0C << 5 |18: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 18 * 4); break;
- case 0x0C << 5 |19: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 19 * 4); break;
- case 0x0C << 5 |20: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 20 * 4); break;
- case 0x0C << 5 |21: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 21 * 4); break;
- case 0x0C << 5 |22: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 22 * 4); break;
- case 0x0C << 5 |23: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 23 * 4); break;
- case 0x0C << 5 |24: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 24 * 4); break;
- case 0x0C << 5 |25: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 25 * 4); break;
- case 0x0C << 5 |26: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 26 * 4); break;
- case 0x0C << 5 |27: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 27 * 4); break;
- case 0x0C << 5 |28: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 28 * 4); break;
- case 0x0C << 5 |29: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 29 * 4); break;
- case 0x0C << 5 |30: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 30 * 4); break;
- case 0x0C << 5 |31: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, OP_code >> 3 & 7, OP_code & 7, 31 * 4); break;
- case 0x0D << 5 | 0: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 0 * 4); break;
- case 0x0D << 5 | 1: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 1 * 4); break;
- case 0x0D << 5 | 2: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 2 * 4); break;
- case 0x0D << 5 | 3: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 3 * 4); break;
- case 0x0D << 5 | 4: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 4 * 4); break;
- case 0x0D << 5 | 5: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 5 * 4); break;
- case 0x0D << 5 | 6: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 6 * 4); break;
- case 0x0D << 5 | 7: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 7 * 4); break;
- case 0x0D << 5 | 8: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 8 * 4); break;
- case 0x0D << 5 | 9: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 9 * 4); break;
- case 0x0D << 5 |10: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 10 * 4); break;
- case 0x0D << 5 |11: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 11 * 4); break;
- case 0x0D << 5 |12: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 12 * 4); break;
- case 0x0D << 5 |13: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 13 * 4); break;
- case 0x0D << 5 |14: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 14 * 4); break;
- case 0x0D << 5 |15: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 15 * 4); break;
- case 0x0D << 5 |16: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 16 * 4); break;
- case 0x0D << 5 |17: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 17 * 4); break;
- case 0x0D << 5 |18: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 18 * 4); break;
- case 0x0D << 5 |19: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 19 * 4); break;
- case 0x0D << 5 |20: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 20 * 4); break;
- case 0x0D << 5 |21: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 21 * 4); break;
- case 0x0D << 5 |22: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 22 * 4); break;
- case 0x0D << 5 |23: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 23 * 4); break;
- case 0x0D << 5 |24: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 24 * 4); break;
- case 0x0D << 5 |25: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 25 * 4); break;
- case 0x0D << 5 |26: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 26 * 4); break;
- case 0x0D << 5 |27: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 27 * 4); break;
- case 0x0D << 5 |28: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 28 * 4); break;
- case 0x0D << 5 |29: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 29 * 4); break;
- case 0x0D << 5 |30: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 30 * 4); break;
- case 0x0D << 5 |31: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 31 * 4); break;
- case 0x0E << 5 | 0: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 0); break;
- case 0x0E << 5 | 1: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 1); break;
- case 0x0E << 5 | 2: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 2); break;
- case 0x0E << 5 | 3: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 3); break;
- case 0x0E << 5 | 4: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 4); break;
- case 0x0E << 5 | 5: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 5); break;
- case 0x0E << 5 | 6: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 6); break;
- case 0x0E << 5 | 7: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 7); break;
- case 0x0E << 5 | 8: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 8); break;
- case 0x0E << 5 | 9: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 9); break;
- case 0x0E << 5 |10: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 10); break;
- case 0x0E << 5 |11: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 11); break;
- case 0x0E << 5 |12: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 12); break;
- case 0x0E << 5 |13: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 13); break;
- case 0x0E << 5 |14: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 14); break;
- case 0x0E << 5 |15: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 15); break;
- case 0x0E << 5 |16: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 16); break;
- case 0x0E << 5 |17: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 17); break;
- case 0x0E << 5 |18: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 18); break;
- case 0x0E << 5 |19: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 19); break;
- case 0x0E << 5 |20: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 20); break;
- case 0x0E << 5 |21: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 21); break;
- case 0x0E << 5 |22: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 22); break;
- case 0x0E << 5 |23: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 23); break;
- case 0x0E << 5 |24: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 24); break;
- case 0x0E << 5 |25: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 25); break;
- case 0x0E << 5 |26: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 26); break;
- case 0x0E << 5 |27: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 27); break;
- case 0x0E << 5 |28: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 28); break;
- case 0x0E << 5 |29: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 29); break;
- case 0x0E << 5 |30: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 30); break;
- case 0x0E << 5 |31: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 0, OP_code >> 3 & 7, OP_code & 7, 31); break;
- case 0x0F << 5 | 0: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 0); break;
- case 0x0F << 5 | 1: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 1); break;
- case 0x0F << 5 | 2: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 2); break;
- case 0x0F << 5 | 3: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 3); break;
- case 0x0F << 5 | 4: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 4); break;
- case 0x0F << 5 | 5: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 5); break;
- case 0x0F << 5 | 6: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 6); break;
- case 0x0F << 5 | 7: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 7); break;
- case 0x0F << 5 | 8: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 8); break;
- case 0x0F << 5 | 9: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 9); break;
- case 0x0F << 5 |10: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 10); break;
- case 0x0F << 5 |11: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 11); break;
- case 0x0F << 5 |12: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 12); break;
- case 0x0F << 5 |13: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 13); break;
- case 0x0F << 5 |14: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 14); break;
- case 0x0F << 5 |15: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 15); break;
- case 0x0F << 5 |16: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 16); break;
- case 0x0F << 5 |17: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 17); break;
- case 0x0F << 5 |18: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 18); break;
- case 0x0F << 5 |19: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 19); break;
- case 0x0F << 5 |20: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 20); break;
- case 0x0F << 5 |21: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 21); break;
- case 0x0F << 5 |22: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 22); break;
- case 0x0F << 5 |23: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 23); break;
- case 0x0F << 5 |24: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 24); break;
- case 0x0F << 5 |25: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 25); break;
- case 0x0F << 5 |26: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 26); break;
- case 0x0F << 5 |27: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 27); break;
- case 0x0F << 5 |28: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 28); break;
- case 0x0F << 5 |29: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 29); break;
- case 0x0F << 5 |30: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 30); break;
- case 0x0F << 5 |31: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 31); break;
- case 0x10 << 5 | 0: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 0 * 2); break;
- case 0x10 << 5 | 1: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 1 * 2); break;
- case 0x10 << 5 | 2: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 2 * 2); break;
- case 0x10 << 5 | 3: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 3 * 2); break;
- case 0x10 << 5 | 4: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 4 * 2); break;
- case 0x10 << 5 | 5: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 5 * 2); break;
- case 0x10 << 5 | 6: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 6 * 2); break;
- case 0x10 << 5 | 7: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 7 * 2); break;
- case 0x10 << 5 | 8: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 8 * 2); break;
- case 0x10 << 5 | 9: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 9 * 2); break;
- case 0x10 << 5 |10: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 10 * 2); break;
- case 0x10 << 5 |11: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 11 * 2); break;
- case 0x10 << 5 |12: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 12 * 2); break;
- case 0x10 << 5 |13: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 13 * 2); break;
- case 0x10 << 5 |14: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 14 * 2); break;
- case 0x10 << 5 |15: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 15 * 2); break;
- case 0x10 << 5 |16: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 16 * 2); break;
- case 0x10 << 5 |17: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 17 * 2); break;
- case 0x10 << 5 |18: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 18 * 2); break;
- case 0x10 << 5 |19: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 19 * 2); break;
- case 0x10 << 5 |20: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 20 * 2); break;
- case 0x10 << 5 |21: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 21 * 2); break;
- case 0x10 << 5 |22: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 22 * 2); break;
- case 0x10 << 5 |23: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 23 * 2); break;
- case 0x10 << 5 |24: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 24 * 2); break;
- case 0x10 << 5 |25: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 25 * 2); break;
- case 0x10 << 5 |26: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 26 * 2); break;
- case 0x10 << 5 |27: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 27 * 2); break;
- case 0x10 << 5 |28: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 28 * 2); break;
- case 0x10 << 5 |29: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 29 * 2); break;
- case 0x10 << 5 |30: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 30 * 2); break;
- case 0x10 << 5 |31: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 0, 0, 1, OP_code >> 3 & 7, OP_code & 7, 31 * 2); break;
- case 0x11 << 5 | 0: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 0 * 2); break;
- case 0x11 << 5 | 1: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 1 * 2); break;
- case 0x11 << 5 | 2: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 2 * 2); break;
- case 0x11 << 5 | 3: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 3 * 2); break;
- case 0x11 << 5 | 4: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 4 * 2); break;
- case 0x11 << 5 | 5: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 5 * 2); break;
- case 0x11 << 5 | 6: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 6 * 2); break;
- case 0x11 << 5 | 7: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 7 * 2); break;
- case 0x11 << 5 | 8: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 8 * 2); break;
- case 0x11 << 5 | 9: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 9 * 2); break;
- case 0x11 << 5 |10: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 10 * 2); break;
- case 0x11 << 5 |11: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 11 * 2); break;
- case 0x11 << 5 |12: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 12 * 2); break;
- case 0x11 << 5 |13: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 13 * 2); break;
- case 0x11 << 5 |14: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 14 * 2); break;
- case 0x11 << 5 |15: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 15 * 2); break;
- case 0x11 << 5 |16: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 16 * 2); break;
- case 0x11 << 5 |17: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 17 * 2); break;
- case 0x11 << 5 |18: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 18 * 2); break;
- case 0x11 << 5 |19: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 19 * 2); break;
- case 0x11 << 5 |20: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 20 * 2); break;
- case 0x11 << 5 |21: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 21 * 2); break;
- case 0x11 << 5 |22: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 22 * 2); break;
- case 0x11 << 5 |23: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 23 * 2); break;
- case 0x11 << 5 |24: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 24 * 2); break;
- case 0x11 << 5 |25: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 25 * 2); break;
- case 0x11 << 5 |26: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 26 * 2); break;
- case 0x11 << 5 |27: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 27 * 2); break;
- case 0x11 << 5 |28: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 28 * 2); break;
- case 0x11 << 5 |29: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 29 * 2); break;
- case 0x11 << 5 |30: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 30 * 2); break;
- case 0x11 << 5 |31: consume += isa_arm7_memory_access_sbh_base (agb, 1, 1, 0, 1, 0, 1, OP_code >> 3 & 7, OP_code & 7, 31 * 2); break;
- case 0x12 << 5 | 0: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 0 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 | 1: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 1 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 | 2: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 2 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 | 3: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 3 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 | 4: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 4 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 | 5: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 5 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 | 6: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 6 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 | 7: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 7 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 | 8: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 8 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 | 9: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 9 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |10: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 10 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |11: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 11 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |12: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 12 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |13: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 13 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |14: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 14 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |15: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 15 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |16: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 16 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |17: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 17 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |18: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 18 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |19: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 19 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |20: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 20 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |21: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 21 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |22: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 22 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |23: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 23 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |24: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 24 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |25: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 25 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |26: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 26 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |27: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 27 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |28: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 28 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |29: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 29 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |30: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 30 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x12 << 5 |31: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 0, 13, 31 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 | 0: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 0 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 | 1: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 1 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 | 2: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 2 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 | 3: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 3 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 | 4: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 4 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 | 5: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 5 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 | 6: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 6 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 | 7: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 7 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 | 8: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 8 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 | 9: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 9 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |10: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 10 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |11: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 11 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |12: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 12 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |13: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 13 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |14: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 14 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |15: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 15 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |16: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 16 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |17: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 17 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |18: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 18 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |19: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 19 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |20: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 20 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |21: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 21 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |22: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 22 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |23: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 23 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |24: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 24 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |25: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 25 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |26: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 26 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |27: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 27 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |28: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 28 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |29: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 29 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |30: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 30 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x13 << 5 |31: consume += isa_arm7_memory_access_ubw_base (agb, 1, 1, 0, 0, 1, 13, 31 >> 2, (OP_code & 0xFF) * 4); break;
- case 0x14 << 5 | 0: regs[0 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 | 1: regs[1 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 | 2: regs[2 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 | 3: regs[3 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 | 4: regs[4 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 | 5: regs[5 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 | 6: regs[6 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 | 7: regs[7 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 | 8: regs[8 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 | 9: regs[9 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |10: regs[10 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |11: regs[11 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |12: regs[12 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |13: regs[13 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |14: regs[14 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |15: regs[15 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |16: regs[16 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |17: regs[17 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |18: regs[18 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |19: regs[19 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |20: regs[20 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |21: regs[21 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |22: regs[22 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |23: regs[23 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |24: regs[24 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |25: regs[25 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |26: regs[26 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |27: regs[27 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |28: regs[28 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |29: regs[29 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |30: regs[30 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x14 << 5 |31: regs[31 >> 2] = (regs[15] & ARM7_CODE_MASK) + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 | 0: regs[0 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 | 1: regs[1 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 | 2: regs[2 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 | 3: regs[3 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 | 4: regs[4 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 | 5: regs[5 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 | 6: regs[6 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 | 7: regs[7 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 | 8: regs[8 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 | 9: regs[9 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |10: regs[10 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |11: regs[11 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |12: regs[12 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |13: regs[13 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |14: regs[14 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |15: regs[15 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |16: regs[16 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |17: regs[17 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |18: regs[18 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |19: regs[19 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |20: regs[20 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |21: regs[21 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |22: regs[22 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |23: regs[23 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |24: regs[24 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |25: regs[25 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |26: regs[26 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |27: regs[27 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |28: regs[28 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |29: regs[29 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |30: regs[30 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- case 0x15 << 5 |31: regs[31 >> 2] = regs[13] + (OP_code & 0xFF) * 4; consume ++; break;
- #define THUMB_COND_CASE(cond_code) \
- case 0xD << 6 | (cond_code) << 2 | 0:\
- case 0xD << 6 | (cond_code) << 2 | 1:\
- case 0xD << 6 | (cond_code) << 2 | 2:\
- case 0xD << 6 | (cond_code) << 2 | 3
- #define THUMB_JCC { const int8_t offset = OP_code & 0xFF; const int32_t offset32 = offset; regs[15] += offset32 * 2; consume += thumb_flush (agb) + 2; break; }
- THUMB_COND_CASE (0x00): if (arm->cpsr.z != 0) THUMB_JCC regs[15] += 2; return consume + 1;
- THUMB_COND_CASE (0x01): if (arm->cpsr.z == 0) THUMB_JCC regs[15] += 2; return consume + 1;
- THUMB_COND_CASE (0x02): if (arm->cpsr.c != 0) THUMB_JCC regs[15] += 2; return consume + 1;
- THUMB_COND_CASE (0x03): if (arm->cpsr.c == 0) THUMB_JCC regs[15] += 2; return consume + 1;
- THUMB_COND_CASE (0x04): if (arm->cpsr.n != 0) THUMB_JCC regs[15] += 2; return consume + 1;
- THUMB_COND_CASE (0x05): if (arm->cpsr.n == 0) THUMB_JCC regs[15] += 2; return consume + 1;
- THUMB_COND_CASE (0x06): if (arm->cpsr.v != 0) THUMB_JCC regs[15] += 2; return consume + 1;
- THUMB_COND_CASE (0x07): if (arm->cpsr.v == 0) THUMB_JCC regs[15] += 2; return consume + 1;
- THUMB_COND_CASE (0x08): if (arm->cpsr.c != 0 && arm->cpsr.z == 0) THUMB_JCC regs[15] += 2; return consume + 1;
- THUMB_COND_CASE (0x09): if (arm->cpsr.c == 0 || arm->cpsr.z != 0) THUMB_JCC regs[15] += 2; return consume + 1;
- THUMB_COND_CASE (0x0A): if (arm->cpsr.n == arm->cpsr.v) THUMB_JCC regs[15] += 2; return consume + 1;
- THUMB_COND_CASE (0x0B): if (arm->cpsr.n != arm->cpsr.v) THUMB_JCC regs[15] += 2; return consume + 1;
- THUMB_COND_CASE (0x0C): if (arm->cpsr.z == 0 && (arm->cpsr.n == arm->cpsr.v)) THUMB_JCC regs[15] += 2; return consume + 1;
- THUMB_COND_CASE (0x0D): if (arm->cpsr.z != 0 || (arm->cpsr.n != arm->cpsr.v)) THUMB_JCC regs[15] += 2; return consume + 1;
- THUMB_COND_CASE (0x0E): THUMB_JCC
- default:
- assert (0);
- break;
- }
- regs[15] += 2;
- } else {
- struct arm7_ldr_sbh_throat {
- uint32_t _1:1;
- uint32_t h:1;
- uint32_t s:1;
- uint32_t __1:1;
- uint32_t l:1;
- uint32_t w:1;
- uint32_t x:1; /* LDR SBH reg | LDR SBH imm */
- uint32_t u:1;
- uint32_t p:1;
- uint32_t align:23;
- };
- struct arm7_ldr_ubw_throat {
- uint32_t l:1;
- uint32_t w:1;
- uint32_t b:1;
- uint32_t u:1;
- uint32_t p:1;
- uint32_t i:1;
- uint32_t align:26;
- };
- struct arm7_ldm_throat {
- uint32_t l:1;
- uint32_t w:1;
- uint32_t s:1;
- uint32_t u:1;
- uint32_t p:1;
- uint32_t align:27;
- };
- const uint32_t OP_code = arm->opcode[0];
- const uint32_t OP_throat = OP_code >> 16 & 0xFF0 | OP_code >> 4 & 0xF;
- const uint32_t OP_cond = OP_code & LSHIFT_RANGE_MASK (0x0F, 28);
- const uint32_t pc = regs[15] - 8;
- arm->opcode[0] = arm->opcode[1];
- consume += arm7_fecth_n (agb, regs[15], & arm->opcode[1]);
- // if (pc == 0xa0)
- // __asm int 3
- //if (old_pc != pc)
- // printf ("pc:arm r12:%d-> %07X\n", regs[12], pc);
- old_r1 = regs[1];
- old_r10 = regs[10];
- old_pc = pc;
- // if (old_r1 == 0x6000000
- // && old_pc == 0xC08)
- // __asm int 3
- /* check arm7 cond field */
- switch (OP_cond) {
- case LSHIFT_RANGE_MASK (0x00, 28): if (arm->cpsr.z != 0) break; regs[15] += 4; return consume + 1;
- case LSHIFT_RANGE_MASK (0x01, 28): if (arm->cpsr.z == 0) break; regs[15] += 4; return consume + 1;
- case LSHIFT_RANGE_MASK (0x02, 28): if (arm->cpsr.c != 0) break; regs[15] += 4; return consume + 1;
- case LSHIFT_RANGE_MASK (0x03, 28): if (arm->cpsr.c == 0) break; regs[15] += 4; return consume + 1;
- case LSHIFT_RANGE_MASK (0x04, 28): if (arm->cpsr.n != 0) break; regs[15] += 4; return consume + 1;
- case LSHIFT_RANGE_MASK (0x05, 28): if (arm->cpsr.n == 0) break; regs[15] += 4; return consume + 1;
- case LSHIFT_RANGE_MASK (0x06, 28): if (arm->cpsr.v != 0) break; regs[15] += 4; return consume + 1;
- case LSHIFT_RANGE_MASK (0x07, 28): if (arm->cpsr.v == 0) break; regs[15] += 4; return consume + 1;
- case LSHIFT_RANGE_MASK (0x08, 28): if (arm->cpsr.c != 0 && arm->cpsr.z == 0) break; regs[15] += 4; return consume + 1;
- case LSHIFT_RANGE_MASK (0x09, 28): if (arm->cpsr.c == 0 || arm->cpsr.z != 0) break; regs[15] += 4; return consume + 1;
- case LSHIFT_RANGE_MASK (0x0A, 28): if (arm->cpsr.n == arm->cpsr.v) break; regs[15] += 4; return consume + 1;
- case LSHIFT_RANGE_MASK (0x0B, 28): if (arm->cpsr.n != arm->cpsr.v) break; regs[15] += 4; return consume + 1;
- case LSHIFT_RANGE_MASK (0x0C, 28): if (arm->cpsr.z == 0 && (arm->cpsr.n == arm->cpsr.v)) break; regs[15] += 4; return consume + 1;
- case LSHIFT_RANGE_MASK (0x0D, 28): if (arm->cpsr.z != 0 || (arm->cpsr.n != arm->cpsr.v)) break; regs[15] += 4; return consume + 1;
- case LSHIFT_RANGE_MASK (0x0E, 28): break;
- case LSHIFT_RANGE_MASK (0x0F, 28): regs[15] += 4; return consume + 1;
- default: assert (0); break;
- }
- /* arm7 opcode decode *.*/
- switch (OP_throat) {
- case 0x009: consume += isa_arm7_mul (agb, OP_code, 0, 0); break;
- case 0x019: consume += isa_arm7_mul (agb, OP_code, 0, 1); break;
- case 0x029: consume += isa_arm7_mul (agb, OP_code, 1, 0); break;
- case 0x039: consume += isa_arm7_mul (agb, OP_code, 1, 1); break;
- case 0x089: consume += isa_arm7_mul_long (agb, OP_code, 0, 0, 0); break;
- case 0x099: consume += isa_arm7_mul_long (agb, OP_code, 0, 0, 1); break;
- case 0x0A9: consume += isa_arm7_mul_long (agb, OP_code, 0, 1, 0); break;
- case 0x0B9: consume += isa_arm7_mul_long (agb, OP_code, 0, 1, 1); break;
- case 0x0C9: consume += isa_arm7_mul_long (agb, OP_code, 1, 0, 0); break;
- case 0x0D9: consume += isa_arm7_mul_long (agb, OP_code, 1, 0, 1); break;
- case 0x0E9: consume += isa_arm7_mul_long (agb, OP_code, 1, 1, 0); break;
- case 0x0F9: consume += isa_arm7_mul_long (agb, OP_code, 1, 1, 1); break;
- case 0x109: consume += isa_arm7_atomic_swap (agb, OP_code, 0); break;
- case 0x149: consume += isa_arm7_atomic_swap (agb, OP_code, 1); break;
- case 0x100: consume += isa_arm7_psr_load (agb, OP_code); break;
- case 0x140: consume += isa_arm7_psr_load (agb, OP_code); break;
- case 0x320: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x321: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x322: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x323: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x324: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x325: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x326: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x327: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x328: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x329: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x32A: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x32B: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x32C: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x32D: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x32E: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x32F: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x360: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x361: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x362: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x363: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x364: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x365: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x366: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x367: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x368: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x369: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x36A: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x36B: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x36C: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x36D: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x36E: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x36F: consume += isa_arm7_psr_store_imm (agb, OP_code); break;
- case 0x120: consume += isa_arm7_psr_store_reg (agb, OP_code); break;
- case 0x160: consume += isa_arm7_psr_store_reg (agb, OP_code); break;
- case 0x121: consume += isa_arm7_branch_exchange (agb, OP_code); if (arm->cpsr.thumb != 0) regs[15] -= 2; break;
- case 0xF00: case 0xF01: case 0xF02: case 0xF03:
- case 0xF04: case 0xF05: case 0xF06: case 0xF07:
- case 0xF08: case 0xF09: case 0xF0A: case 0xF0B:
- case 0xF0C: case 0xF0D: case 0xF0E:
- case 0xF0F:
- case 0xF10: case 0xF11: case 0xF12: case 0xF13:
- case 0xF14: case 0xF15: case 0xF16: case 0xF17:
- case 0xF18: case 0xF19: case 0xF1A: case 0xF1B:
- case 0xF1C: case 0xF1D: case 0xF1E:
- case 0xF1F:
- case 0xF20: case 0xF21: case 0xF22: case 0xF23:
- case 0xF24: case 0xF25: case 0xF26: case 0xF27:
- case 0xF28: case 0xF29: case 0xF2A: case 0xF2B:
- case 0xF2C: case 0xF2D: case 0xF2E:
- case 0xF2F:
- case 0xF30: case 0xF31: case 0xF32: case 0xF33:
- case 0xF34: case 0xF35: case 0xF36: case 0xF37:
- case 0xF38: case 0xF39: case 0xF3A: case 0xF3B:
- case 0xF3C: case 0xF3D: case 0xF3E:
- case 0xF3F:
- case 0xF40: case 0xF41: case 0xF42: case 0xF43:
- case 0xF44: case 0xF45: case 0xF46: case 0xF47:
- case 0xF48: case 0xF49: case 0xF4A: case 0xF4B:
- case 0xF4C: case 0xF4D: case 0xF4E:
- case 0xF4F:
- case 0xF50: case 0xF51: case 0xF52: case 0xF53:
- case 0xF54: case 0xF55: case 0xF56: case 0xF57:
- case 0xF58: case 0xF59: case 0xF5A: case 0xF5B:
- case 0xF5C: case 0xF5D: case 0xF5E:
- case 0xF5F:
- case 0xF60: case 0xF61: case 0xF62: case 0xF63:
- case 0xF64: case 0xF65: case 0xF66: case 0xF67:
- case 0xF68: case 0xF69: case 0xF6A: case 0xF6B:
- case 0xF6C: case 0xF6D: case 0xF6E:
- case 0xF6F:
- case 0xF70: case 0xF71: case 0xF72: case 0xF73:
- case 0xF74: case 0xF75: case 0xF76: case 0xF77:
- case 0xF78: case 0xF79: case 0xF7A: case 0xF7B:
- case 0xF7C: case 0xF7D: case 0xF7E:
- case 0xF7F:
- case 0xF80: case 0xF81: case 0xF82: case 0xF83:
- case 0xF84: case 0xF85: case 0xF86: case 0xF87:
- case 0xF88: case 0xF89: case 0xF8A: case 0xF8B:
- case 0xF8C: case 0xF8D: case 0xF8E:
- case 0xF8F:
- case 0xF90: case 0xF91: case 0xF92: case 0xF93:
- case 0xF94: case 0xF95: case 0xF96: case 0xF97:
- case 0xF98: case 0xF99: case 0xF9A: case 0xF9B:
- case 0xF9C: case 0xF9D: case 0xF9E:
- case 0xF9F:
- case 0xFA0: case 0xFA1: case 0xFA2: case 0xFA3:
- case 0xFA4: case 0xFA5: case 0xFA6: case 0xFA7:
- case 0xFA8: case 0xFA9: case 0xFAA: case 0xFAB:
- case 0xFAC: case 0xFAD: case 0xFAE:
- case 0xFAF:
- case 0xFB0: case 0xFB1: case 0xFB2: case 0xFB3:
- case 0xFB4: case 0xFB5: case 0xFB6: case 0xFB7:
- case 0xFB8: case 0xFB9: case 0xFBA: case 0xFBB:
- case 0xFBC: case 0xFBD: case 0xFBE:
- case 0xFBF:
- case 0xFC0: case 0xFC1: case 0xFC2: case 0xFC3:
- case 0xFC4: case 0xFC5: case 0xFC6: case 0xFC7:
- case 0xFC8: case 0xFC9: case 0xFCA: case 0xFCB:
- case 0xFCC: case 0xFCD: case 0xFCE:
- case 0xFCF:
- case 0xFD0: case 0xFD1: case 0xFD2: case 0xFD3:
- case 0xFD4: case 0xFD5: case 0xFD6: case 0xFD7:
- case 0xFD8: case 0xFD9: case 0xFDA: case 0xFDB:
- case 0xFDC: case 0xFDD: case 0xFDE:
- case 0xFDF:
- case 0xFE0: case 0xFE1: case 0xFE2: case 0xFE3:
- case 0xFE4: case 0xFE5: case 0xFE6: case 0xFE7:
- case 0xFE8: case 0xFE9: case 0xFEA: case 0xFEB:
- case 0xFEC: case 0xFED: case 0xFEE:
- case 0xFEF:
- case 0xFF0: case 0xFF1: case 0xFF2: case 0xFF3:
- case 0xFF4: case 0xFF5: case 0xFF6: case 0xFF7:
- case 0xFF8: case 0xFF9: case 0xFFA: case 0xFFB:
- case 0xFFC: case 0xFFD: case 0xFFE:
- case 0xFFF:
- consume += isa_arm7_swi (agb, OP_code);
- break;
- case 0xA00: case 0xA01: case 0xA02: case 0xA03:
- case 0xA04: case 0xA05: case 0xA06: case 0xA07:
- case 0xA08: case 0xA09: case 0xA0A: case 0xA0B:
- case 0xA0C: case 0xA0D: case 0xA0E:
- case 0xA0F:
- case 0xA10: case 0xA11: case 0xA12: case 0xA13:
- case 0xA14: case 0xA15: case 0xA16: case 0xA17:
- case 0xA18: case 0xA19: case 0xA1A: case 0xA1B:
- case 0xA1C: case 0xA1D: case 0xA1E:
- case 0xA1F:
- case 0xA20: case 0xA21: case 0xA22: case 0xA23:
- case 0xA24: case 0xA25: case 0xA26: case 0xA27:
- case 0xA28: case 0xA29: case 0xA2A: case 0xA2B:
- case 0xA2C: case 0xA2D: case 0xA2E:
- case 0xA2F:
- case 0xA30: case 0xA31: case 0xA32: case 0xA33:
- case 0xA34: case 0xA35: case 0xA36: case 0xA37:
- case 0xA38: case 0xA39: case 0xA3A: case 0xA3B:
- case 0xA3C: case 0xA3D: case 0xA3E:
- case 0xA3F:
- case 0xA40: case 0xA41: case 0xA42: case 0xA43:
- case 0xA44: case 0xA45: case 0xA46: case 0xA47:
- case 0xA48: case 0xA49: case 0xA4A: case 0xA4B:
- case 0xA4C: case 0xA4D: case 0xA4E:
- case 0xA4F:
- case 0xA50: case 0xA51: case 0xA52: case 0xA53:
- case 0xA54: case 0xA55: case 0xA56: case 0xA57:
- case 0xA58: case 0xA59: case 0xA5A: case 0xA5B:
- case 0xA5C: case 0xA5D: case 0xA5E:
- case 0xA5F:
- case 0xA60: case 0xA61: case 0xA62: case 0xA63:
- case 0xA64: case 0xA65: case 0xA66: case 0xA67:
- case 0xA68: case 0xA69: case 0xA6A: case 0xA6B:
- case 0xA6C: case 0xA6D: case 0xA6E:
- case 0xA6F:
- case 0xA70: case 0xA71: case 0xA72: case 0xA73:
- case 0xA74: case 0xA75: case 0xA76: case 0xA77:
- case 0xA78: case 0xA79: case 0xA7A: case 0xA7B:
- case 0xA7C: case 0xA7D: case 0xA7E:
- case 0xA7F:
- case 0xA80: case 0xA81: case 0xA82: case 0xA83:
- case 0xA84: case 0xA85: case 0xA86: case 0xA87:
- case 0xA88: case 0xA89: case 0xA8A: case 0xA8B:
- case 0xA8C: case 0xA8D: case 0xA8E:
- case 0xA8F:
- case 0xA90: case 0xA91: case 0xA92: case 0xA93:
- case 0xA94: case 0xA95: case 0xA96: case 0xA97:
- case 0xA98: case 0xA99: case 0xA9A: case 0xA9B:
- case 0xA9C: case 0xA9D: case 0xA9E:
- case 0xA9F:
- case 0xAA0: case 0xAA1: case 0xAA2: case 0xAA3:
- case 0xAA4: case 0xAA5: case 0xAA6: case 0xAA7:
- case 0xAA8: case 0xAA9: case 0xAAA: case 0xAAB:
- case 0xAAC: case 0xAAD: case 0xAAE:
- case 0xAAF:
- case 0xAB0: case 0xAB1: case 0xAB2: case 0xAB3:
- case 0xAB4: case 0xAB5: case 0xAB6: case 0xAB7:
- case 0xAB8: case 0xAB9: case 0xABA: case 0xABB:
- case 0xABC: case 0xABD: case 0xABE:
- case 0xABF:
- case 0xAC0: case 0xAC1: case 0xAC2: case 0xAC3:
- case 0xAC4: case 0xAC5: case 0xAC6: case 0xAC7:
- case 0xAC8: case 0xAC9: case 0xACA: case 0xACB:
- case 0xACC: case 0xACD: case 0xACE:
- case 0xACF:
- case 0xAD0: case 0xAD1: case 0xAD2: case 0xAD3:
- case 0xAD4: case 0xAD5: case 0xAD6: case 0xAD7:
- case 0xAD8: case 0xAD9: case 0xADA: case 0xADB:
- case 0xADC: case 0xADD: case 0xADE:
- case 0xADF:
- case 0xAE0: case 0xAE1: case 0xAE2: case 0xAE3:
- case 0xAE4: case 0xAE5: case 0xAE6: case 0xAE7:
- case 0xAE8: case 0xAE9: case 0xAEA: case 0xAEB:
- case 0xAEC: case 0xAED: case 0xAEE:
- case 0xAEF:
- case 0xAF0: case 0xAF1: case 0xAF2: case 0xAF3:
- case 0xAF4: case 0xAF5: case 0xAF6: case 0xAF7:
- case 0xAF8: case 0xAF9: case 0xAFA: case 0xAFB:
- case 0xAFC: case 0xAFD: case 0xAFE:
- case 0xAFF:
- consume += isa_arm7_branch_without_link (agb, OP_code);
- break;
- case 0xB00: case 0xB01: case 0xB02: case 0xB03:
- case 0xB04: case 0xB05: case 0xB06: case 0xB07:
- case 0xB08: case 0xB09: case 0xB0A: case 0xB0B:
- case 0xB0C: case 0xB0D: case 0xB0E:
- case 0xB0F:
- case 0xB10: case 0xB11: case 0xB12: case 0xB13:
- case 0xB14: case 0xB15: case 0xB16: case 0xB17:
- case 0xB18: case 0xB19: case 0xB1A: case 0xB1B:
- case 0xB1C: case 0xB1D: case 0xB1E:
- case 0xB1F:
- case 0xB20: case 0xB21: case 0xB22: case 0xB23:
- case 0xB24: case 0xB25: case 0xB26: case 0xB27:
- case 0xB28: case 0xB29: case 0xB2A: case 0xB2B:
- case 0xB2C: case 0xB2D: case 0xB2E:
- case 0xB2F:
- case 0xB30: case 0xB31: case 0xB32: case 0xB33:
- case 0xB34: case 0xB35: case 0xB36: case 0xB37:
- case 0xB38: case 0xB39: case 0xB3A: case 0xB3B:
- case 0xB3C: case 0xB3D: case 0xB3E:
- case 0xB3F:
- case 0xB40: case 0xB41: case 0xB42: case 0xB43:
- case 0xB44: case 0xB45: case 0xB46: case 0xB47:
- case 0xB48: case 0xB49: case 0xB4A: case 0xB4B:
- case 0xB4C: case 0xB4D: case 0xB4E:
- case 0xB4F:
- case 0xB50: case 0xB51: case 0xB52: case 0xB53:
- case 0xB54: case 0xB55: case 0xB56: case 0xB57:
- case 0xB58: case 0xB59: case 0xB5A: case 0xB5B:
- case 0xB5C: case 0xB5D: case 0xB5E:
- case 0xB5F:
- case 0xB60: case 0xB61: case 0xB62: case 0xB63:
- case 0xB64: case 0xB65: case 0xB66: case 0xB67:
- case 0xB68: case 0xB69: case 0xB6A: case 0xB6B:
- case 0xB6C: case 0xB6D: case 0xB6E:
- case 0xB6F:
- case 0xB70: case 0xB71: case 0xB72: case 0xB73:
- case 0xB74: case 0xB75: case 0xB76: case 0xB77:
- case 0xB78: case 0xB79: case 0xB7A: case 0xB7B:
- case 0xB7C: case 0xB7D: case 0xB7E:
- case 0xB7F:
- case 0xB80: case 0xB81: case 0xB82: case 0xB83:
- case 0xB84: case 0xB85: case 0xB86: case 0xB87:
- case 0xB88: case 0xB89: case 0xB8A: case 0xB8B:
- case 0xB8C: case 0xB8D: case 0xB8E:
- case 0xB8F:
- case 0xB90: case 0xB91: case 0xB92: case 0xB93:
- case 0xB94: case 0xB95: case 0xB96: case 0xB97:
- case 0xB98: case 0xB99: case 0xB9A: case 0xB9B:
- case 0xB9C: case 0xB9D: case 0xB9E:
- case 0xB9F:
- case 0xBA0: case 0xBA1: case 0xBA2: case 0xBA3:
- case 0xBA4: case 0xBA5: case 0xBA6: case 0xBA7:
- case 0xBA8: case 0xBA9: case 0xBAA: case 0xBAB:
- case 0xBAC: case 0xBAD: case 0xBAE:
- case 0xBAF:
- case 0xBB0: case 0xBB1: case 0xBB2: case 0xBB3:
- case 0xBB4: case 0xBB5: case 0xBB6: case 0xBB7:
- case 0xBB8: case 0xBB9: case 0xBBA: case 0xBBB:
- case 0xBBC: case 0xBBD: case 0xBBE:
- case 0xBBF:
- case 0xBC0: case 0xBC1: case 0xBC2: case 0xBC3:
- case 0xBC4: case 0xBC5: case 0xBC6: case 0xBC7:
- case 0xBC8: case 0xBC9: case 0xBCA: case 0xBCB:
- case 0xBCC: case 0xBCD: case 0xBCE:
- case 0xBCF:
- case 0xBD0: case 0xBD1: case 0xBD2: case 0xBD3:
- case 0xBD4: case 0xBD5: case 0xBD6: case 0xBD7:
- case 0xBD8: case 0xBD9: case 0xBDA: case 0xBDB:
- case 0xBDC: case 0xBDD: case 0xBDE:
- case 0xBDF:
- case 0xBE0: case 0xBE1: case 0xBE2: case 0xBE3:
- case 0xBE4: case 0xBE5: case 0xBE6: case 0xBE7:
- case 0xBE8: case 0xBE9: case 0xBEA: case 0xBEB:
- case 0xBEC: case 0xBED: case 0xBEE:
- case 0xBEF:
- case 0xBF0: case 0xBF1: case 0xBF2: case 0xBF3:
- case 0xBF4: case 0xBF5: case 0xBF6: case 0xBF7:
- case 0xBF8: case 0xBF9: case 0xBFA: case 0xBFB:
- case 0xBFC: case 0xBFD: case 0xBFE:
- case 0xBFF:
- consume += isa_arm7_branch_with_link (agb, OP_code);
- break;
- #define ALU_BLOCK(throat_alu, alu_cb, write_back, update_flags_cb, sign_bit)\
- case 0x200 | (throat_alu) << 5 | sign_bit << 4 | 0:\
- case 0x200 | (throat_alu) << 5 | sign_bit << 4 | 1:\
- case 0x200 | (throat_alu) << 5 | sign_bit << 4 | 2:\
- case 0x200 | (throat_alu) << 5 | sign_bit << 4 | 3:\
- case 0x200 | (throat_alu) << 5 | sign_bit << 4 | 4:\
- case 0x200 | (throat_alu) << 5 | sign_bit << 4 | 5:\
- case 0x200 | (throat_alu) << 5 | sign_bit << 4 | 6:\
- case 0x200 | (throat_alu) << 5 | sign_bit << 4 | 7:\
- case 0x200 | (throat_alu) << 5 | sign_bit << 4 | 8:\
- case 0x200 | (throat_alu) << 5 | sign_bit << 4 | 9:\
- case 0x200 | (throat_alu) << 5 | sign_bit << 4 |10:\
- case 0x200 | (throat_alu) << 5 | sign_bit << 4 |11:\
- case 0x200 | (throat_alu) << 5 | sign_bit << 4 |12:\
- case 0x200 | (throat_alu) << 5 | sign_bit << 4 |13:\
- case 0x200 | (throat_alu) << 5 | sign_bit << 4 |14:\
- case 0x200 | (throat_alu) << 5 | sign_bit << 4 |15:\
- consume += isa_arm7_alu_rot_imm32 (agb, OP_code, write_back, alu_cb, update_flags_cb, sign_bit); \
- break; \
- case (throat_alu) << 5 | sign_bit << 4 | 0: consume += isa_arm7_alu_shift_imm5 (agb, OP_code, 0, write_back, alu_cb, update_flags_cb, sign_bit); break; \
- case (throat_alu) << 5 | sign_bit << 4 | 2: consume += isa_arm7_alu_shift_imm5 (agb, OP_code, 1, write_back, alu_cb, update_flags_cb, sign_bit); break; \
- case (throat_alu) << 5 | sign_bit << 4 | 4: consume += isa_arm7_alu_shift_imm5 (agb, OP_code, 2, write_back, alu_cb, update_flags_cb, sign_bit); break; \
- case (throat_alu) << 5 | sign_bit << 4 | 6: consume += isa_arm7_alu_shift_imm5 (agb, OP_code, 3, write_back, alu_cb, update_flags_cb, sign_bit); break; \
- case (throat_alu) << 5 | sign_bit << 4 | 8: consume += isa_arm7_alu_shift_imm5 (agb, OP_code, 0, write_back, alu_cb, update_flags_cb, sign_bit); break; \
- case (throat_alu) << 5 | sign_bit << 4 |10:consume += isa_arm7_alu_shift_imm5 (agb, OP_code, 1, write_back, alu_cb, update_flags_cb, sign_bit); break; \
- case (throat_alu) << 5 | sign_bit << 4 |12:consume += isa_arm7_alu_shift_imm5 (agb, OP_code, 2, write_back, alu_cb, update_flags_cb, sign_bit); break; \
- case (throat_alu) << 5 | sign_bit << 4 |14:consume += isa_arm7_alu_shift_imm5 (agb, OP_code, 3, write_back, alu_cb, update_flags_cb, sign_bit); break; \
- case (throat_alu) << 5 | sign_bit << 4 | 1:consume += isa_arm7_alu_shift_rs (agb, OP_code, 0, write_back, alu_cb, update_flags_cb, sign_bit); break; \
- case (throat_alu) << 5 | sign_bit << 4 | 3:consume += isa_arm7_alu_shift_rs (agb, OP_code, 1, write_back, alu_cb, update_flags_cb, sign_bit); break; \
- case (throat_alu) << 5 | sign_bit << 4 | 5:consume += isa_arm7_alu_shift_rs (agb, OP_code, 2, write_back, alu_cb, update_flags_cb, sign_bit); break; \
- case (throat_alu) << 5 | sign_bit << 4 | 7:consume += isa_arm7_alu_shift_rs (agb, OP_code, 3, write_back, alu_cb, update_flags_cb, sign_bit); break; \
- ALU_BLOCK (0, alu_and, 1, update_flags_logic, 0)
- ALU_BLOCK (1, alu_eor, 1, update_flags_logic, 0)
- ALU_BLOCK (2, alu_sub, 1, update_flags_sub, 0)
- ALU_BLOCK (3, alu_rsb, 1, update_flags_sub, 0)
- ALU_BLOCK (4, alu_add, 1, update_flags_add, 0)
- ALU_BLOCK (5, alu_adc, 1, update_flags_add, 0)
- ALU_BLOCK (6, alu_sbc, 1, update_flags_sub, 0)
- ALU_BLOCK (7, alu_rsc, 1, update_flags_sub, 0)
- ALU_BLOCK (12, alu_orr, 1, update_flags_logic, 0)
- ALU_BLOCK (13, alu_mov, 1, update_flags_logic, 0)
- ALU_BLOCK (14, alu_bic, 1, update_flags_logic, 0)
- ALU_BLOCK (15, alu_mvn, 1, update_flags_logic, 0)
- ALU_BLOCK (0, alu_and, 1, update_flags_logic, 1)
- ALU_BLOCK (1, alu_eor, 1, update_flags_logic, 1)
- ALU_BLOCK (2, alu_sub, 1, update_flags_sub, 1)
- ALU_BLOCK (3, alu_rsb, 1, update_flags_sub, 1)
- ALU_BLOCK (4, alu_add, 1, update_flags_add, 1)
- ALU_BLOCK (5, alu_adc, 1, update_flags_add, 1)
- ALU_BLOCK (6, alu_sbc, 1, update_flags_sub, 1)
- ALU_BLOCK (7, alu_rsc, 1, update_flags_sub, 1)
- ALU_BLOCK (8, alu_and, 0, update_flags_logic, 1)
- ALU_BLOCK (9, alu_eor, 0, update_flags_logic, 1)
- ALU_BLOCK (10, alu_sub, 0, update_flags_sub, 1)
- ALU_BLOCK (11, alu_add, 0, update_flags_add, 1)
- ALU_BLOCK (12, alu_orr, 1, update_flags_logic, 1)
- ALU_BLOCK (13, alu_mov, 1, update_flags_logic, 1)
- ALU_BLOCK (14, alu_bic, 1, update_flags_logic, 1)
- ALU_BLOCK (15, alu_mvn, 1, update_flags_logic, 1)
- #define LDR_SBH_BLOCK3(high5Bit)\
- case (high5Bit) << 4 | 11: \
- { const uint32_t throat_cache = (high5Bit) << 4 | 11; \
- const struct arm7_ldr_sbh_throat *const throat = (const struct arm7_ldr_sbh_throat *)& throat_cache;\
- if (throat->x == 0) \
- consume += isa_arm7_memory_access_sbh_reg (agb, OP_code, throat->p, throat->u, throat->w, throat->l, throat->s, throat->h);\
- else \
- consume += isa_arm7_memory_access_sbh_pad_imm8 (agb, OP_code, throat->p, throat->u, throat->w, throat->l, throat->s, throat->h);\
- }\
- break;\
- case (high5Bit) << 4 | 13: \
- { const uint32_t throat_cache = (high5Bit) << 4 | 13; \
- const struct arm7_ldr_sbh_throat *const throat = (const struct arm7_ldr_sbh_throat *)& throat_cache;\
- if (throat->x == 0) \
- consume += isa_arm7_memory_access_sbh_reg (agb, OP_code, throat->p, throat->u, throat->w, throat->l, throat->s, throat->h);\
- else \
- consume += isa_arm7_memory_access_sbh_pad_imm8 (agb, OP_code, throat->p, throat->u, throat->w, throat->l, throat->s, throat->h);\
- }\
- break;\
- case (high5Bit) << 4 | 15: \
- { const uint32_t throat_cache = (high5Bit) << 4 | 15; \
- const struct arm7_ldr_sbh_throat *const throat = (const struct arm7_ldr_sbh_throat *)& throat_cache;\
- if (throat->x == 0) \
- consume += isa_arm7_memory_access_sbh_reg (agb, OP_code, throat->p, throat->u, throat->w, throat->l, throat->s, throat->h);\
- else \
- consume += isa_arm7_memory_access_sbh_pad_imm8 (agb, OP_code, throat->p, throat->u, throat->w, throat->l, throat->s, throat->h);\
- } \
- break;
- LDR_SBH_BLOCK3 (0)
- LDR_SBH_BLOCK3 (1)
- LDR_SBH_BLOCK3 (2)
- LDR_SBH_BLOCK3 (3)
- LDR_SBH_BLOCK3 (4)
- LDR_SBH_BLOCK3 (5)
- LDR_SBH_BLOCK3 (6)
- LDR_SBH_BLOCK3 (7)
- LDR_SBH_BLOCK3 (8)
- LDR_SBH_BLOCK3 (9)
- LDR_SBH_BLOCK3 (10)
- LDR_SBH_BLOCK3 (11)
- LDR_SBH_BLOCK3 (12)
- LDR_SBH_BLOCK3 (13)
- LDR_SBH_BLOCK3 (14)
- LDR_SBH_BLOCK3 (15)
- LDR_SBH_BLOCK3 (16)
- LDR_SBH_BLOCK3 (17)
- LDR_SBH_BLOCK3 (18)
- LDR_SBH_BLOCK3 (19)
- LDR_SBH_BLOCK3 (20)
- LDR_SBH_BLOCK3 (21)
- LDR_SBH_BLOCK3 (22)
- LDR_SBH_BLOCK3 (23)
- LDR_SBH_BLOCK3 (24)
- LDR_SBH_BLOCK3 (25)
- LDR_SBH_BLOCK3 (26)
- LDR_SBH_BLOCK3 (27)
- LDR_SBH_BLOCK3 (28)
- LDR_SBH_BLOCK3 (29)
- LDR_SBH_BLOCK3 (30)
- LDR_SBH_BLOCK3 (31)
- #define LDR_UBW_BLOCK(const_throat, shift)\
- { const uint32_t _throat_t = const_throat;\
- const struct arm7_ldr_ubw_throat *const _throat = (const struct arm7_ldr_ubw_throat *const) & _throat_t;\
- if (_throat->i != 0)\
- consume += isa_arm7_memory_access_ubw_scaled (agb, OP_code, shift, _throat->p, _throat->u, _throat->b, _throat->w, _throat->l);\
- else \
- consume += isa_arm7_memory_access_ubw_imm12 (agb, OP_code, _throat->p, _throat->u, _throat->b, _throat->w, _throat->l);\
- }\
- break;
- #define LDR_UBW_BLOCK16(n)\
- case (0x400 | (n) << 4 | 0): LDR_UBW_BLOCK (n, 0 >> 1 & 3)\
- case (0x400 | (n) << 4 | 1): LDR_UBW_BLOCK (n, 1 >> 1 & 3)\
- case (0x400 | (n) << 4 | 2): LDR_UBW_BLOCK (n, 2 >> 1 & 3)\
- case (0x400 | (n) << 4 | 3): LDR_UBW_BLOCK (n, 3 >> 1 & 3)\
- case (0x400 | (n) << 4 | 4): LDR_UBW_BLOCK (n, 4 >> 1 & 3)\
- case (0x400 | (n) << 4 | 5): LDR_UBW_BLOCK (n, 5 >> 1 & 3)\
- case (0x400 | (n) << 4 | 6): LDR_UBW_BLOCK (n, 6 >> 1 & 3)\
- case (0x400 | (n) << 4 | 7): LDR_UBW_BLOCK (n, 7 >> 1 & 3)\
- case (0x400 | (n) << 4 | 8): LDR_UBW_BLOCK (n, 8 >> 1 & 3)\
- case (0x400 | (n) << 4 | 9): LDR_UBW_BLOCK (n, 9 >> 1 & 3)\
- case (0x400 | (n) << 4 |10): LDR_UBW_BLOCK (n, 10 >> 1 & 3)\
- case (0x400 | (n) << 4 |11): LDR_UBW_BLOCK (n, 11 >> 1 & 3)\
- case (0x400 | (n) << 4 |12): LDR_UBW_BLOCK (n, 12 >> 1 & 3)\
- case (0x400 | (n) << 4 |13): LDR_UBW_BLOCK (n, 13 >> 1 & 3)\
- case (0x400 | (n) << 4 |14): LDR_UBW_BLOCK (n, 14 >> 1 & 3)\
- case (0x400 | (n) << 4 |15): LDR_UBW_BLOCK (n, 15 >> 1 & 3)
- LDR_UBW_BLOCK16 (0)
- LDR_UBW_BLOCK16 (1)
- LDR_UBW_BLOCK16 (2)
- LDR_UBW_BLOCK16 (3)
- LDR_UBW_BLOCK16 (4)
- LDR_UBW_BLOCK16 (5)
- LDR_UBW_BLOCK16 (6)
- LDR_UBW_BLOCK16 (7)
- LDR_UBW_BLOCK16 (8)
- LDR_UBW_BLOCK16 (9)
- LDR_UBW_BLOCK16 (10)
- LDR_UBW_BLOCK16 (11)
- LDR_UBW_BLOCK16 (12)
- LDR_UBW_BLOCK16 (13)
- LDR_UBW_BLOCK16 (14)
- LDR_UBW_BLOCK16 (15)
- LDR_UBW_BLOCK16 (16)
- LDR_UBW_BLOCK16 (17)
- LDR_UBW_BLOCK16 (18)
- LDR_UBW_BLOCK16 (19)
- LDR_UBW_BLOCK16 (20)
- LDR_UBW_BLOCK16 (21)
- LDR_UBW_BLOCK16 (22)
- LDR_UBW_BLOCK16 (23)
- LDR_UBW_BLOCK16 (24)
- LDR_UBW_BLOCK16 (25)
- LDR_UBW_BLOCK16 (26)
- LDR_UBW_BLOCK16 (27)
- LDR_UBW_BLOCK16 (28)
- LDR_UBW_BLOCK16 (29)
- LDR_UBW_BLOCK16 (30)
- LDR_UBW_BLOCK16 (31)
- LDR_UBW_BLOCK16 (32)
- LDR_UBW_BLOCK16 (33)
- LDR_UBW_BLOCK16 (34)
- LDR_UBW_BLOCK16 (35)
- LDR_UBW_BLOCK16 (36)
- LDR_UBW_BLOCK16 (37)
- LDR_UBW_BLOCK16 (38)
- LDR_UBW_BLOCK16 (39)
- LDR_UBW_BLOCK16 (40)
- LDR_UBW_BLOCK16 (41)
- LDR_UBW_BLOCK16 (42)
- LDR_UBW_BLOCK16 (43)
- LDR_UBW_BLOCK16 (44)
- LDR_UBW_BLOCK16 (45)
- LDR_UBW_BLOCK16 (46)
- LDR_UBW_BLOCK16 (47)
- LDR_UBW_BLOCK16 (48)
- LDR_UBW_BLOCK16 (49)
- LDR_UBW_BLOCK16 (50)
- LDR_UBW_BLOCK16 (51)
- LDR_UBW_BLOCK16 (52)
- LDR_UBW_BLOCK16 (53)
- LDR_UBW_BLOCK16 (54)
- LDR_UBW_BLOCK16 (55)
- LDR_UBW_BLOCK16 (56)
- LDR_UBW_BLOCK16 (57)
- LDR_UBW_BLOCK16 (58)
- LDR_UBW_BLOCK16 (59)
- LDR_UBW_BLOCK16 (60)
- LDR_UBW_BLOCK16 (61)
- LDR_UBW_BLOCK16 (62)
- LDR_UBW_BLOCK16 (63)
- #define LDM_BLOCK(const_throat) \
- { const uint32_t _throat_t = const_throat;\
- const struct arm7_ldm_throat *const _throat = (const struct arm7_ldm_throat *const) & _throat_t;\
- if (_throat->l != 0)\
- consume += isa_arm7_list_memory_access_load (agb, OP_code, _throat->p, _throat->u, _throat->s, _throat->w);\
- else \
- consume += isa_arm7_list_memory_access_store (agb, OP_code, _throat->p, _throat->u, _throat->s, _throat->w);\
- }\
- break;
- #define LDM_BLOCK16(n)\
- case (0x800 | (n) << 4 | 0): LDM_BLOCK (n)\
- case (0x800 | (n) << 4 | 1): LDM_BLOCK (n)\
- case (0x800 | (n) << 4 | 2): LDM_BLOCK (n)\
- case (0x800 | (n) << 4 | 3): LDM_BLOCK (n)\
- case (0x800 | (n) << 4 | 4): LDM_BLOCK (n)\
- case (0x800 | (n) << 4 | 5): LDM_BLOCK (n)\
- case (0x800 | (n) << 4 | 6): LDM_BLOCK (n)\
- case (0x800 | (n) << 4 | 7): LDM_BLOCK (n)\
- case (0x800 | (n) << 4 | 8): LDM_BLOCK (n)\
- case (0x800 | (n) << 4 | 9): LDM_BLOCK (n)\
- case (0x800 | (n) << 4 |10): LDM_BLOCK (n)\
- case (0x800 | (n) << 4 |11): LDM_BLOCK (n)\
- case (0x800 | (n) << 4 |12): LDM_BLOCK (n)\
- case (0x800 | (n) << 4 |13): LDM_BLOCK (n)\
- case (0x800 | (n) << 4 |14): LDM_BLOCK (n)\
- case (0x800 | (n) << 4 |15): LDM_BLOCK (n)
- LDM_BLOCK16 (0)
- LDM_BLOCK16 (1)
- LDM_BLOCK16 (2)
- LDM_BLOCK16 (3)
- LDM_BLOCK16 (4)
- LDM_BLOCK16 (5)
- LDM_BLOCK16 (6)
- LDM_BLOCK16 (7)
- LDM_BLOCK16 (8)
- LDM_BLOCK16 (9)
- LDM_BLOCK16 (10)
- LDM_BLOCK16 (11)
- LDM_BLOCK16 (12)
- LDM_BLOCK16 (13)
- LDM_BLOCK16 (14)
- LDM_BLOCK16 (15)
- LDM_BLOCK16 (16)
- LDM_BLOCK16 (17)
- LDM_BLOCK16 (18)
- LDM_BLOCK16 (19)
- LDM_BLOCK16 (20)
- LDM_BLOCK16 (21)
- LDM_BLOCK16 (22)
- LDM_BLOCK16 (23)
- LDM_BLOCK16 (24)
- LDM_BLOCK16 (25)
- LDM_BLOCK16 (26)
- LDM_BLOCK16 (27)
- LDM_BLOCK16 (28)
- LDM_BLOCK16 (29)
- LDM_BLOCK16 (30)
- LDM_BLOCK16 (31)
- default:
- assert (0);
- }
- regs[15] += 4;
- }
- break;
- } while (0);
- return consume;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement