Search
lxdream.org :: lxdream/src/sh4/x86op.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/x86op.h
changeset 380:2e8166bf6832
prev377:fa18743f6905
next386:6fb10951326a
author nkeynes
date Wed Sep 12 11:31:16 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Fix load_spreg/store_spreg
Fix PREF
Add jump target debug checking
file annotate diff log raw
1.1 --- a/src/sh4/x86op.h Wed Sep 12 09:17:52 2007 +0000
1.2 +++ b/src/sh4/x86op.h Wed Sep 12 11:31:16 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: x86op.h,v 1.6 2007-09-12 09:17:24 nkeynes Exp $
1.6 + * $Id: x86op.h,v 1.7 2007-09-12 11:31:16 nkeynes Exp $
1.7 *
1.8 * Definitions of x86 opcodes for use by the translator.
1.9 *
1.10 @@ -38,6 +38,17 @@
1.11 #define R_DH 6
1.12 #define R_BH 7
1.13
1.14 +#ifdef DEBUG_JUMPS
1.15 +#define MARK_JMP(n,x) uint8_t *_mark_jmp_##x = xlat_output + n
1.16 +#define JMP_TARGET(x) assert( _mark_jmp_##x == xlat_output )
1.17 +#else
1.18 +#define MARK_JMP(n, x)
1.19 +#define JMP_TARGET(x)
1.20 +#endif
1.21 +
1.22 +
1.23 +
1.24 +
1.25
1.26 #define OP(x) *xlat_output++ = (x)
1.27 #define OP32(x) *((uint32_t *)xlat_output) = (x); xlat_output+=4
1.28 @@ -100,7 +111,7 @@
1.29 #define DEC_r32(r1) OP(0x48+r1)
1.30 #define IMUL_r32(r1) OP(0xF7); MODRM_rm32_r32(r1,5)
1.31 #define INC_r32(r1) OP(0x40+r1)
1.32 -#define JMP_rel8(rel) OP(0xEB); OP(rel)
1.33 +#define JMP_rel8(rel, label) OP(0xEB); OP(rel); MARK_JMP(rel,label)
1.34 #define MOV_r32_r32(r1,r2) OP(0x89); MODRM_r32_rm32(r1,r2)
1.35 #define MOV_r32_sh4r(r1,disp) OP(0x89); MODRM_r32_sh4r(r1,disp)
1.36 #define MOV_moff32_EAX(off) OP(0xA1); OP32(off)
1.37 @@ -163,20 +174,20 @@
1.38 #define FSQRT_st0() OP(0xD9); OP(0xFA)
1.39
1.40 /* Conditional branches */
1.41 -#define JE_rel8(rel) OP(0x74); OP(rel)
1.42 -#define JA_rel8(rel) OP(0x77); OP(rel)
1.43 -#define JAE_rel8(rel) OP(0x73); OP(rel)
1.44 -#define JG_rel8(rel) OP(0x7F); OP(rel)
1.45 -#define JGE_rel8(rel) OP(0x7D); OP(rel)
1.46 -#define JC_rel8(rel) OP(0x72); OP(rel)
1.47 -#define JO_rel8(rel) OP(0x70); OP(rel)
1.48 -#define JNE_rel8(rel) OP(0x75); OP(rel)
1.49 -#define JNA_rel8(rel) OP(0x76); OP(rel)
1.50 -#define JNAE_rel8(rel) OP(0x72); OP(rel)
1.51 -#define JNG_rel8(rel) OP(0x7E); OP(rel)
1.52 -#define JNGE_rel8(rel) OP(0x7C); OP(rel)
1.53 -#define JNC_rel8(rel) OP(0x73); OP(rel)
1.54 -#define JNO_rel8(rel) OP(0x71); OP(rel)
1.55 +#define JE_rel8(rel,label) OP(0x74); OP(rel); MARK_JMP(rel,label)
1.56 +#define JA_rel8(rel,label) OP(0x77); OP(rel); MARK_JMP(rel,label)
1.57 +#define JAE_rel8(rel,label) OP(0x73); OP(rel); MARK_JMP(rel,label)
1.58 +#define JG_rel8(rel,label) OP(0x7F); OP(rel); MARK_JMP(rel,label)
1.59 +#define JGE_rel8(rel,label) OP(0x7D); OP(rel); MARK_JMP(rel,label)
1.60 +#define JC_rel8(rel,label) OP(0x72); OP(rel); MARK_JMP(rel,label)
1.61 +#define JO_rel8(rel,label) OP(0x70); OP(rel); MARK_JMP(rel,label)
1.62 +#define JNE_rel8(rel,label) OP(0x75); OP(rel); MARK_JMP(rel,label)
1.63 +#define JNA_rel8(rel,label) OP(0x76); OP(rel); MARK_JMP(rel,label)
1.64 +#define JNAE_rel8(rel,label) OP(0x72); OP(rel); MARK_JMP(rel,label)
1.65 +#define JNG_rel8(rel,label) OP(0x7E); OP(rel); MARK_JMP(rel,label)
1.66 +#define JNGE_rel8(rel,label) OP(0x7C); OP(rel); MARK_JMP(rel,label)
1.67 +#define JNC_rel8(rel,label) OP(0x73); OP(rel); MARK_JMP(rel,label)
1.68 +#define JNO_rel8(rel,label) OP(0x71); OP(rel); MARK_JMP(rel,label)
1.69
1.70 /* 32-bit long forms w/ backpatching to an exit routine */
1.71 #define JE_exit(rel) OP(0x0F); OP(0x84); sh4_x86_add_backpatch(xlat_output); OP32(rel)
.