mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
32x: drc: more wip, ARM untested
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@828 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
3863edbd9d
commit
ed8cf79be8
3 changed files with 240 additions and 57 deletions
|
@ -40,6 +40,8 @@
|
|||
#define A_COND_LT 0xb
|
||||
#define A_COND_GT 0xc
|
||||
#define A_COND_LE 0xd
|
||||
#define A_COND_CS A_COND_HS
|
||||
#define A_COND_CC A_COND_LO
|
||||
|
||||
/* unified conditions */
|
||||
#define DCOND_EQ A_COND_EQ
|
||||
|
@ -56,8 +58,6 @@
|
|||
#define DCOND_LE A_COND_LE
|
||||
#define DCOND_VS A_COND_VS
|
||||
#define DCOND_VC A_COND_VC
|
||||
#define DCOND_CS A_COND_HS
|
||||
#define DCOND_CC A_COND_LO
|
||||
|
||||
/* addressing mode 1 */
|
||||
#define A_AM1_LSL 0
|
||||
|
@ -225,8 +225,6 @@ static void emith_op_imm(int cond, int s, int op, int r, unsigned int imm)
|
|||
|
||||
if (op == A_OP_MOV)
|
||||
rn = 0;
|
||||
else if (op == A_OP_TST || op == A_OP_TEQ)
|
||||
rd = 0;
|
||||
else if (imm == 0)
|
||||
return;
|
||||
|
||||
|
@ -244,6 +242,14 @@ static void emith_op_imm(int cond, int s, int op, int r, unsigned int imm)
|
|||
}
|
||||
}
|
||||
|
||||
// test op
|
||||
#define emith_top_imm(cond, op, r, imm) { \
|
||||
u32 ror2, v; \
|
||||
for (ror2 = 0, v = imm; v && !(v & 3); v >>= 2) \
|
||||
ror2--; \
|
||||
EOP_C_DOP_IMM(cond, op, 1, r, 0, ror2 & 0x0f, v & 0xff); \
|
||||
}
|
||||
|
||||
#define is_offset_24(val) \
|
||||
((val) >= (int)0xff000000 && (val) <= 0x00ffffff)
|
||||
|
||||
|
@ -350,9 +356,12 @@ static int emith_xbranch(int cond, void *target, int is_call)
|
|||
#define emith_or_r_imm(r, imm) \
|
||||
emith_op_imm(A_COND_AL, 0, A_OP_ORR, r, imm)
|
||||
|
||||
// note: use 8bit imm only
|
||||
// note: only use 8bit imm for these
|
||||
#define emith_tst_r_imm(r, imm) \
|
||||
emith_op_imm(A_COND_AL, 1, A_OP_TST, r, imm)
|
||||
emith_top_imm(A_COND_AL, A_OP_TST, r, imm)
|
||||
|
||||
#define emith_cmp_r_imm(r, imm) \
|
||||
emith_top_imm(A_COND_AL, A_OP_CMP, r, imm)
|
||||
|
||||
#define emith_subf_r_imm(r, imm) \
|
||||
emith_op_imm(A_COND_AL, 1, A_OP_SUB, r, imm)
|
||||
|
@ -375,12 +384,34 @@ static int emith_xbranch(int cond, void *target, int is_call)
|
|||
#define emith_lsr(d, s, cnt) \
|
||||
EOP_MOV_REG(A_COND_AL,0,d,s,A_AM1_LSR,cnt)
|
||||
|
||||
#define emith_ror(d, s, cnt) \
|
||||
EOP_MOV_REG(A_COND_AL,0,d,s,A_AM1_ROR,cnt)
|
||||
|
||||
#define emith_lslf(d, s, cnt) \
|
||||
EOP_MOV_REG(A_COND_AL,1,d,s,A_AM1_LSL,cnt)
|
||||
|
||||
#define emith_lsrf(d, s, cnt) \
|
||||
EOP_MOV_REG(A_COND_AL,1,d,s,A_AM1_LSR,cnt)
|
||||
|
||||
#define emith_asrf(d, s, cnt) \
|
||||
EOP_MOV_REG(A_COND_AL,1,d,s,A_AM1_ASR,cnt)
|
||||
|
||||
// note: only C flag updated correctly
|
||||
#define emith_rolf(d, s, cnt) { \
|
||||
EOP_MOV_REG(A_COND_AL,1,d,s,A_AM1_ROR,32-(cnt)); \
|
||||
/* we don't have ROL so we shift to get the right carry */ \
|
||||
EOP_TST_REG(A_COND_AL,d,d,A_AM1_LSR,1); \
|
||||
}
|
||||
|
||||
#define emith_rorf(d, s, cnt) \
|
||||
EOP_MOV_REG(A_COND_AL,1,d,s,A_AM1_ROR,cnt)
|
||||
|
||||
#define emith_rolcf(d) \
|
||||
emith_adcf_r_r(d, d)
|
||||
|
||||
#define emith_rorcf(d) \
|
||||
EOP_MOV_REG(A_COND_AL,1,d,d,A_AM1_ROR,0) /* ROR #0 -> RRX */
|
||||
|
||||
#define emith_mul(d, s1, s2) { \
|
||||
if ((d) != (s1)) /* rd != rm limitation */ \
|
||||
EOP_MUL(d, s1, s2); \
|
||||
|
@ -483,3 +514,19 @@ static int emith_xbranch(int cond, void *target, int is_call)
|
|||
rcache_free_tmp(tmp); \
|
||||
}
|
||||
|
||||
#define emith_write_sr(srcr) { \
|
||||
int srr = rcache_get_reg(SHR_SR, RC_GR_RMW); \
|
||||
emith_lsr(srr, srr, 12); \
|
||||
emith_or_r_r_r_lsl(srr, srr, srcr, 20); \
|
||||
emith_ror(srr, srr, 20); \
|
||||
}
|
||||
|
||||
#define emith_carry_to_t(srr, is_sub) { \
|
||||
if (is_sub) { /* has inverted C on ARM */ \
|
||||
emith_or_r_imm_c(A_COND_CC, srr, 1); \
|
||||
emith_bic_r_imm_c(A_COND_CS, srr, 1); \
|
||||
} else { \
|
||||
emith_or_r_imm_c(A_COND_CS, srr, 1); \
|
||||
emith_bic_r_imm_c(A_COND_CC, srr, 1); \
|
||||
} \
|
||||
}
|
||||
|
|
|
@ -39,8 +39,6 @@ enum { xAX = 0, xCX, xDX, xBX, xSP, xBP, xSI, xDI };
|
|||
#define DCOND_LT IOP_JL // less (signed)
|
||||
#define DCOND_VS IOP_JO // oVerflow Set
|
||||
#define DCOND_VC IOP_JNO // oVerflow Clear
|
||||
#define DCOND_CS IOP_JB // Carry Set
|
||||
#define DCOND_CC IOP_JAE // Carry Clear
|
||||
|
||||
#define EMIT_PTR(ptr, val, type) \
|
||||
*(type *)(ptr) = val
|
||||
|
@ -141,7 +139,7 @@ enum { xAX = 0, xCX, xDX, xBX, xSP, xBP, xSI, xDI };
|
|||
EMIT(imm, u32); \
|
||||
}
|
||||
|
||||
// 2 - adc, 3 - sbb, 6 - xor, 7 - cmp
|
||||
// 2 - adc, 3 - sbb, 6 - xor
|
||||
#define emith_add_r_imm(r, imm) \
|
||||
emith_arith_r_imm(0, r, imm)
|
||||
|
||||
|
@ -154,6 +152,9 @@ enum { xAX = 0, xCX, xDX, xBX, xSP, xBP, xSI, xDI };
|
|||
#define emith_sub_r_imm(r, imm) \
|
||||
emith_arith_r_imm(5, r, imm)
|
||||
|
||||
#define emith_cmp_r_imm(r, imm) \
|
||||
emith_arith_r_imm(7, r, imm)
|
||||
|
||||
#define emith_tst_r_imm(r, imm) { \
|
||||
EMIT_OP_MODRM(0xf7, 3, 0, r); \
|
||||
EMIT(imm, u32); \
|
||||
|
@ -201,6 +202,18 @@ enum { xAX = 0, xCX, xDX, xBX, xSP, xBP, xSI, xDI };
|
|||
#define emith_asr(d, s, cnt) \
|
||||
emith_shift(7, d, s, cnt)
|
||||
|
||||
#define emith_rol(d, s, cnt) \
|
||||
emith_shift(0, d, s, cnt)
|
||||
|
||||
#define emith_ror(d, s, cnt) \
|
||||
emith_shift(1, d, s, cnt)
|
||||
|
||||
#define emith_rolc(r) \
|
||||
EMIT_OP_MODRM(0xd1, 3, 2, r)
|
||||
|
||||
#define emith_rorc(r) \
|
||||
EMIT_OP_MODRM(0xd1, 3, 3, r)
|
||||
|
||||
// misc
|
||||
#define emith_push(r) \
|
||||
EMIT_OP(0x50 + (r))
|
||||
|
@ -280,9 +293,13 @@ enum { xAX = 0, xCX, xDX, xBX, xSP, xBP, xSI, xDI };
|
|||
#define emith_adcf_r_r emith_adc_r_r
|
||||
#define emith_sbcf_r_r emith_sbc_r_r
|
||||
|
||||
#define emith_lslf emith_lsl
|
||||
#define emith_lsrf emith_lsr
|
||||
#define emith_asrf emith_asr
|
||||
#define emith_lslf emith_lsl
|
||||
#define emith_lsrf emith_lsr
|
||||
#define emith_asrf emith_asr
|
||||
#define emith_rolf emith_rol
|
||||
#define emith_rorf emith_ror
|
||||
#define emith_rolcf emith_rolc
|
||||
#define emith_rorcf emith_rorc
|
||||
|
||||
// XXX: offs is 8bit only
|
||||
#define emith_ctx_read(r, offs) { \
|
||||
|
@ -368,3 +385,22 @@ enum { xAX = 0, xCX, xDX, xBX, xSP, xBP, xSI, xDI };
|
|||
rcache_free_tmp(tmp); \
|
||||
}
|
||||
|
||||
#define emith_write_sr(srcr) { \
|
||||
int tmp = rcache_get_tmp(); \
|
||||
int srr = rcache_get_reg(SHR_SR, RC_GR_RMW); \
|
||||
emith_clear_msb(tmp, srcr, 20); \
|
||||
emith_bic_r_imm(srr, 0xfff); \
|
||||
emith_or_r_r(srr, tmp); \
|
||||
rcache_free_tmp(tmp); \
|
||||
}
|
||||
|
||||
#define emith_carry_to_t(srr, is_sub) { \
|
||||
int tmp = rcache_get_tmp(); \
|
||||
EMIT_OP(0x0f); \
|
||||
EMIT(0x92, u8); \
|
||||
EMIT_MODRM(3, 0, tmp); /* SETC */ \
|
||||
emith_bic_r_imm(srr, 1); \
|
||||
EMIT_OP_MODRM(0x08, 3, tmp, srr); /* OR srrl, tmpl */ \
|
||||
rcache_free_tmp(tmp); \
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue