Search
lxdream.org :: lxdream/src/sh4/ia32abi.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/ia32abi.h
changeset 930:07e5b11419db
prev929:fd8cb0c82f5f
next939:6f2302afeb89
author nkeynes
date Mon Dec 22 09:51:11 2008 +0000 (11 years ago)
branchlxdream-mem
permissions -rw-r--r--
last change Remove pointer cache and add full address-space map. Much better
file annotate diff log raw
1.1 --- a/src/sh4/ia32abi.h Sat Dec 20 03:01:40 2008 +0000
1.2 +++ b/src/sh4/ia32abi.h Mon Dec 22 09:51:11 2008 +0000
1.3 @@ -24,6 +24,13 @@
1.4
1.5 #define load_ptr( reg, ptr ) load_imm32( reg, (uint32_t)ptr );
1.6
1.7 +static inline decode_address( int addr_reg )
1.8 +{
1.9 + MOV_r32_r32( addr_reg, R_ECX );
1.10 + SHR_imm8_r32( 12, R_ECX );
1.11 + MOV_r32disp32x4_r32( R_ECX, (uintptr_t)sh4_address_space, R_ECX );
1.12 +}
1.13 +
1.14 /**
1.15 * Note: clobbers EAX to make the indirect call - this isn't usually
1.16 * a problem since the callee will usually clobber it anyway.
1.17 @@ -50,12 +57,12 @@
1.18 CALL_r32(addr_reg);
1.19 }
1.20
1.21 -static inline void call_func1_r32ind( int preg, uint32_t disp32, int arg1 )
1.22 +static inline void call_func1_r32disp8( int preg, uint32_t disp8, int arg1 )
1.23 {
1.24 if( arg1 != R_EAX ) {
1.25 MOV_r32_r32( arg1, R_EAX );
1.26 }
1.27 - CALL_r32ind(preg, disp32);
1.28 + CALL_r32disp8(preg, disp8);
1.29 }
1.30
1.31 static inline void call_func2( void *ptr, int arg1, int arg2 )
1.32 @@ -80,7 +87,7 @@
1.33 CALL_r32(addr_reg);
1.34 }
1.35
1.36 -static inline void call_func2_r32ind( int preg, uint32_t disp32, int arg1, int arg2 )
1.37 +static inline void call_func2_r32disp8( int preg, uint32_t disp8, int arg1, int arg2 )
1.38 {
1.39 if( arg2 != R_EDX ) {
1.40 MOV_r32_r32( arg2, R_EDX );
1.41 @@ -88,7 +95,7 @@
1.42 if( arg1 != R_EAX ) {
1.43 MOV_r32_r32( arg1, R_EAX );
1.44 }
1.45 - CALL_r32ind(preg, disp32);
1.46 + CALL_r32disp8(preg, disp8);
1.47 }
1.48
1.49
1.50 @@ -122,11 +129,11 @@
1.51 {
1.52 MOV_r32_esp8(addr, 0);
1.53 MOV_r32_esp8(arg2b, 4);
1.54 - call_func2(sh4_write_long, addr, arg2a);
1.55 + MEM_WRITE_LONG(addr, arg2a);
1.56 MOV_esp8_r32(0, R_EAX);
1.57 MOV_esp8_r32(4, R_EDX);
1.58 ADD_imm8s_r32(4, R_EAX);
1.59 - call_func0(sh4_write_long);
1.60 + MEM_WRITE_LONG(R_EAX, R_EDX);
1.61 }
1.62
1.63 /**
1.64 @@ -136,14 +143,11 @@
1.65 static inline void MEM_READ_DOUBLE( int addr, int arg2a, int arg2b )
1.66 {
1.67 MOV_r32_esp8(addr, 0);
1.68 - call_func1(sh4_read_long, addr);
1.69 + MEM_READ_LONG(addr, R_EAX);
1.70 MOV_r32_esp8(R_EAX, 4);
1.71 MOV_esp8_r32(0, R_EAX);
1.72 ADD_imm8s_r32(4, R_EAX);
1.73 - call_func0(sh4_read_long);
1.74 - if( arg2b != R_EAX ) {
1.75 - MOV_r32_r32(R_EAX, arg2b);
1.76 - }
1.77 + MEM_READ_LONG(R_EAX, arg2b );
1.78 MOV_esp8_r32(4, arg2a);
1.79 }
1.80 #else
1.81 @@ -214,14 +218,12 @@
1.82 {
1.83 PUSH_r32(R_EBP);
1.84 load_ptr( R_EBP, ((uint8_t *)&sh4r) + 128 );
1.85 - PUSH_r32(R_EBX);
1.86 - SUB_imm8s_r32( 4, R_ESP );
1.87 + SUB_imm8s_r32( 8, R_ESP );
1.88 }
1.89
1.90 static inline void exit_block( )
1.91 {
1.92 - ADD_imm8s_r32( 4, R_ESP );
1.93 - POP_r32(R_EBX);
1.94 + ADD_imm8s_r32( 8, R_ESP );
1.95 POP_r32(R_EBP);
1.96 RET();
1.97 }
.