Search
lxdream.org :: lxdream/src/sh4/x86op.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/x86op.h
changeset 669:ab344e42bca9
prev601:d8d1af0d133c
next675:b97020f9af1c
author nkeynes
date Mon May 12 10:00:13 2008 +0000 (12 years ago)
permissions -rw-r--r--
last change Cleanup most of the -Wall warnings (getting a bit sloppy...)
Convert FP code to use fixed banks rather than indirect pointer
(3-4% faster this way now)
file annotate diff log raw
1.1 --- a/src/sh4/x86op.h Tue Jan 22 10:11:45 2008 +0000
1.2 +++ b/src/sh4/x86op.h Mon May 12 10:00:13 2008 +0000
1.3 @@ -38,17 +38,9 @@
1.4 #define R_DH 6
1.5 #define R_BH 7
1.6
1.7 -#ifdef DEBUG_JUMPS
1.8 -#define MARK_JMP(n,x) uint8_t *_mark_jmp_##x = xlat_output + n
1.9 -#define JMP_TARGET(x) assert( _mark_jmp_##x == xlat_output )
1.10 -#else
1.11 -#define MARK_JMP(n, x)
1.12 -#define JMP_TARGET(x)
1.13 -#endif
1.14 -
1.15 -
1.16 -
1.17 -
1.18 +#define MARK_JMP8(x) uint8_t *_mark_jmp_##x = xlat_output
1.19 +#define MARK_JMP32(x) uint32_t *_mark_jmp_##x = (uint32_t *)xlat_output
1.20 +#define JMP_TARGET(x) *_mark_jmp_##x += (xlat_output - _mark_jmp_##x)
1.21
1.22 #define OP(x) *xlat_output++ = (x)
1.23 #define OP32(x) *((uint32_t *)xlat_output) = (x); xlat_output+=4
1.24 @@ -90,7 +82,7 @@
1.25
1.26
1.27 /* Offset of a reg relative to the sh4r structure */
1.28 -#define REG_OFFSET(reg) (((char *)&sh4r.reg) - ((char *)&sh4r))
1.29 +#define REG_OFFSET(reg) (((char *)&sh4r.reg) - ((char *)&sh4r) - 128)
1.30
1.31 #define R_T REG_OFFSET(t)
1.32 #define R_Q REG_OFFSET(q)
1.33 @@ -155,7 +147,8 @@
1.34 #define DEC_r32(r1) OP(0x48+r1)
1.35 #define IMUL_r32(r1) OP(0xF7); MODRM_rm32_r32(r1,5)
1.36 #define INC_r32(r1) OP(0x40+r1)
1.37 -#define JMP_rel8(rel, label) OP(0xEB); OP(rel); MARK_JMP(rel,label)
1.38 +#define JMP_rel8(label) OP(0xEB); MARK_JMP8(label); OP(-1);
1.39 +#define LEA_sh4r_r32(disp,r1) OP(0x8D); MODRM_r32_sh4r(r1,disp)
1.40 #define MOV_r32_r32(r1,r2) OP(0x89); MODRM_r32_rm32(r1,r2)
1.41 #define MOV_r32_sh4r(r1,disp) OP(0x89); MODRM_r32_sh4r(r1,disp)
1.42 #define MOV_moff32_EAX(off) OP(0xA1); OPPTR(off)
1.43 @@ -209,35 +202,44 @@
1.44 #define FCHS_st0() OP(0xD9); OP(0xE0)
1.45 #define FCOMIP_st(st) OP(0xDF); OP(0xF0+st)
1.46 #define FDIVP_st(st) OP(0xDE); OP(0xF8+st)
1.47 -#define FILD_sh4r(disp) OP(0xDB); MODRM_r32_sh4r(0, disp)
1.48 #define FILD_r32ind(r32) OP(0xDB); OP(0x00+r32)
1.49 -#define FISTP_sh4r(disp) OP(0xDB); MODRM_r32_sh4r(3, disp)
1.50 #define FLD0_st0() OP(0xD9); OP(0xEE);
1.51 #define FLD1_st0() OP(0xD9); OP(0xE8);
1.52 +#define FLDf_sh4r(disp) OP(0xD9); MODRM_r32_sh4r(0, disp)
1.53 +#define FLDd_sh4r(disp) OP(0xDD); MODRM_r32_sh4r(0, disp)
1.54 #define FLDCW_r32ind(r32) OP(0xD9); OP(0x28+r32)
1.55 #define FMULP_st(st) OP(0xDE); OP(0xC8+st)
1.56 #define FNSTCW_r32ind(r32) OP(0xD9); OP(0x38+r32)
1.57 #define FPOP_st() OP(0xDD); OP(0xC0); OP(0xD9); OP(0xF7)
1.58 +#define FSTPf_sh4r(disp) OP(0xD9); MODRM_r32_sh4r(3, disp)
1.59 +#define FSTPd_sh4r(disp) OP(0xDD); MODRM_r32_sh4r(3, disp)
1.60 #define FSUBP_st(st) OP(0xDE); OP(0xE8+st)
1.61 #define FSQRT_st0() OP(0xD9); OP(0xFA)
1.62
1.63 +#define FILD_sh4r(disp) OP(0xDB); MODRM_r32_sh4r(0, disp)
1.64 +#define FLDF_sh4r(disp) OP(0xD9); MODRM_r32_sh4r(0, disp)
1.65 +#define FLDD_sh4r(disp) OP(0xDD); MODRM_r32_sh4r(0, disp)
1.66 +#define FISTP_sh4r(disp) OP(0xDB); MODRM_r32_sh4r(3, disp)
1.67 +#define FSTPF_sh4r(disp) OP(0xD9); MODRM_r32_sh4r(3,disp)
1.68 +#define FSTPD_sh4r(disp) OP(0xDD); MODRM_r32_sh4r(3,disp)
1.69 +
1.70 /* Conditional branches */
1.71 -#define JE_rel8(rel,label) OP(0x74); OP(rel); MARK_JMP(rel,label)
1.72 -#define JA_rel8(rel,label) OP(0x77); OP(rel); MARK_JMP(rel,label)
1.73 -#define JAE_rel8(rel,label) OP(0x73); OP(rel); MARK_JMP(rel,label)
1.74 -#define JG_rel8(rel,label) OP(0x7F); OP(rel); MARK_JMP(rel,label)
1.75 -#define JGE_rel8(rel,label) OP(0x7D); OP(rel); MARK_JMP(rel,label)
1.76 -#define JC_rel8(rel,label) OP(0x72); OP(rel); MARK_JMP(rel,label)
1.77 -#define JO_rel8(rel,label) OP(0x70); OP(rel); MARK_JMP(rel,label)
1.78 -#define JNE_rel8(rel,label) OP(0x75); OP(rel); MARK_JMP(rel,label)
1.79 -#define JNA_rel8(rel,label) OP(0x76); OP(rel); MARK_JMP(rel,label)
1.80 -#define JNAE_rel8(rel,label) OP(0x72); OP(rel); MARK_JMP(rel,label)
1.81 -#define JNG_rel8(rel,label) OP(0x7E); OP(rel); MARK_JMP(rel,label)
1.82 -#define JNGE_rel8(rel,label) OP(0x7C); OP(rel); MARK_JMP(rel,label)
1.83 -#define JNC_rel8(rel,label) OP(0x73); OP(rel); MARK_JMP(rel,label)
1.84 -#define JNO_rel8(rel,label) OP(0x71); OP(rel); MARK_JMP(rel,label)
1.85 -#define JNS_rel8(rel,label) OP(0x79); OP(rel); MARK_JMP(rel,label)
1.86 -#define JS_rel8(rel,label) OP(0x78); OP(rel); MARK_JMP(rel,label)
1.87 +#define JE_rel8(label) OP(0x74); MARK_JMP8(label); OP(-1)
1.88 +#define JA_rel8(label) OP(0x77); MARK_JMP8(label); OP(-1)
1.89 +#define JAE_rel8(label) OP(0x73); MARK_JMP8(label); OP(-1)
1.90 +#define JG_rel8(label) OP(0x7F); MARK_JMP8(label); OP(-1)
1.91 +#define JGE_rel8(label) OP(0x7D); MARK_JMP8(label); OP(-1)
1.92 +#define JC_rel8(label) OP(0x72); MARK_JMP8(label); OP(-1)
1.93 +#define JO_rel8(label) OP(0x70); MARK_JMP8(label); OP(-1)
1.94 +#define JNE_rel8(label) OP(0x75); MARK_JMP8(label); OP(-1)
1.95 +#define JNA_rel8(label) OP(0x76); MARK_JMP8(label); OP(-1)
1.96 +#define JNAE_rel8(label) OP(0x72); MARK_JMP8(label); OP(-1)
1.97 +#define JNG_rel8(label) OP(0x7E); MARK_JMP8(label); OP(-1)
1.98 +#define JNGE_rel8(label) OP(0x7C); MARK_JMP8(label); OP(-1)
1.99 +#define JNC_rel8(label) OP(0x73); MARK_JMP8(label); OP(-1)
1.100 +#define JNO_rel8(label) OP(0x71); MARK_JMP8(label); OP(-1)
1.101 +#define JNS_rel8(label) OP(0x79); MARK_JMP8(label); OP(-1)
1.102 +#define JS_rel8(label) OP(0x78); MARK_JMP8(label); OP(-1)
1.103
1.104 /** JMP relative 8 or 32 depending on size of rel. rel offset
1.105 * from the start of the instruction (not end)
.