Search
lxdream.org :: lxdream/src/sh4/x86op.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/x86op.h
changeset 361:be3de4ecd954
prev359:c588dce7ebde
next368:36fac4c42322
author nkeynes
date Tue Aug 28 08:46:14 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Translator WIP: fill out and correct another batch of instructions
file annotate diff log raw
1.1 --- a/src/sh4/x86op.h Thu Aug 23 12:33:27 2007 +0000
1.2 +++ b/src/sh4/x86op.h Tue Aug 28 08:46:14 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: x86op.h,v 1.1 2007-08-23 12:33:27 nkeynes Exp $
1.6 + * $Id: x86op.h,v 1.2 2007-08-28 08:46:14 nkeynes Exp $
1.7 *
1.8 * Definitions of x86 opcodes for use by the translator.
1.9 *
1.10 @@ -39,13 +39,16 @@
1.11 #define R_BH 7
1.12
1.13
1.14 -#define OP(x) *xlat_output++ = x
1.15 -#define OP32(x) *((uint32_t *)xlat_output) = x; xlat_output+=2
1.16 +#define OP(x) *xlat_output++ = (x)
1.17 +#define OP32(x) *((uint32_t *)xlat_output) = (x); xlat_output+=4
1.18
1.19 /* Offset of a reg relative to the sh4r structure */
1.20 #define REG_OFFSET(reg) (((char *)&sh4r.reg) - ((char *)&sh4r))
1.21
1.22 #define R_T REG_OFFSET(t)
1.23 +#define R_Q REG_OFFSET(q)
1.24 +#define R_S REG_OFFSET(s)
1.25 +#define R_M REG_OFFSET(m)
1.26 #define R_GBR REG_OFFSET(gbr)
1.27 #define R_SSR REG_OFFSET(ssr)
1.28 #define R_SPC REG_OFFSET(spc)
1.29 @@ -82,6 +85,7 @@
1.30 #define CMC() OP(0xF5)
1.31 #define CMP_r32_r32(r1,r2) OP(0x3B); MODRM_rm32_r32(r1,r2)
1.32 #define CMP_imm8s_r32(imm,r1) OP(0x83); MODRM_rm32_r32(r1,7); OP(imm)
1.33 +#define JMP_rel8(rel) OP(0xEB); OP(rel)
1.34 #define MOV_r32_ebp8(r1,disp) OP(0x89); MODRM_r32_ebp8(r1,disp)
1.35 #define MOV_r32_ebp32(r1,disp) OP(0x89); MODRM_r32_ebp32(r1,disp)
1.36 #define MOV_ebp8_r32(r1,disp) OP(0x8B); MODRM_r32_ebp8(r1,disp)
1.37 @@ -94,6 +98,7 @@
1.38 #define NOT_r32(r1) OP(0xF7); MODRM_rm32_r32(r1,2)
1.39 #define OR_r32_r32(r1,r2) OP(0x0B); MODRM_rm32_r32(r1,r2)
1.40 #define OR_imm32_r32(imm,r1) OP(0x81); MODRM_rm32_r32(r1,1); OP32(imm)
1.41 +#define PUSH_r32(r1) OP(0x50 + r1)
1.42 #define RCL1_r32(r1) OP(0xD1); MODRM_rm32_r32(r1,2)
1.43 #define RCR1_r32(r1) OP(0xD1); MODRM_rm32_r32(r1,3)
1.44 #define RET() OP(0xC3)
1.45 @@ -112,9 +117,18 @@
1.46 #define XOR_r32_r32(r1,r2) OP(0x33); MODRM_rm32_r32(r1,r2)
1.47 #define XOR_imm32_r32(imm,r1) OP(0x81); MODRM_rm32_r32(r1,6); OP32(imm)
1.48
1.49 -#define ADD_imm32_r32(imm32,r1)
1.50 -#define MOV_r32_r32(r1,r2)
1.51 -#define XCHG_r8_r8(r1,r2)
1.52 +#define ADD_imm32_r32(imm32,r1) OP(0x81); MODRM_rm32_r32(r1,0); OP32(imm32)
1.53 +#define AND_imm8_r8(imm8, r1) OP(0x80); MODRM_rm32_r32(r1,4); OP(imm8)
1.54 +#define CMP_imm32_r32(imm32, r1) OP(0x81); MODRM_rm32_r32(r1,7); OP32(imm32)
1.55 +#define MOV_r32_r32(r1,r2) OP(0x89); MODRM_r32_rm32(r1,r2)
1.56 +#define MUL_r32(r1) OP(0xF7); MODRM_rm32_r32(r1,4)
1.57 +#define IMUL_r32(r1) OP(0xF7); MODRM_rm32_r32(r1,5)
1.58 +#define OR_imm8_r8(imm,r1) OP(0x80); MODRM_rm32_r32(r1,1)
1.59 +#define TEST_r8_r8(r1,r2) OP(0x84); MODRM_r32_rm32(r1,r2)
1.60 +#define SAR_r32_CL(r1) OP(0xD3); MODRM_rm32_r32(r1,7)
1.61 +#define SHR_r32_CL(r1) OP(0xD3); MODRM_rm32_r32(r1,5)
1.62 +#define SHL_r32_CL(r1) OP(0xD3); MODRM_rm32_r32(r1,4)
1.63 +#define XCHG_r8_r8(r1,r2) OP(0x86); MODRM_rm32_r32(r1,r2)
1.64
1.65 /* Conditional branches */
1.66 #define JE_rel8(rel) OP(0x74); OP(rel)
.