Search
lxdream.org :: lxdream/src/sh4/sh4core.in :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4core.in
changeset 587:739a3136f269
prev586:2a3ba82cf243
next617:476a717a54f3
author nkeynes
date Wed Jan 16 09:35:30 2008 +0000 (12 years ago)
permissions -rw-r--r--
last change Fix instruction side-effects in presence of exceptions
file annotate diff log raw
1.1 --- a/src/sh4/sh4core.in Tue Jan 15 20:50:23 2008 +0000
1.2 +++ b/src/sh4/sh4core.in Wed Jan 16 09:35:30 2008 +0000
1.3 @@ -377,9 +377,9 @@
1.4 MOV.B Rm, @Rn {: MEM_WRITE_BYTE( sh4r.r[Rn], sh4r.r[Rm] ); :}
1.5 MOV.W Rm, @Rn {: CHECKWALIGN16( sh4r.r[Rn] ); MEM_WRITE_WORD( sh4r.r[Rn], sh4r.r[Rm] ); :}
1.6 MOV.L Rm, @Rn {: CHECKWALIGN32( sh4r.r[Rn] ); MEM_WRITE_LONG( sh4r.r[Rn], sh4r.r[Rm] ); :}
1.7 -MOV.B Rm, @-Rn {: sh4r.r[Rn] --; MEM_WRITE_BYTE( sh4r.r[Rn], sh4r.r[Rm] ); :}
1.8 -MOV.W Rm, @-Rn {: sh4r.r[Rn] -= 2; CHECKWALIGN16( sh4r.r[Rn] ); MEM_WRITE_WORD( sh4r.r[Rn], sh4r.r[Rm] ); :}
1.9 -MOV.L Rm, @-Rn {: sh4r.r[Rn] -= 4; CHECKWALIGN32( sh4r.r[Rn] ); MEM_WRITE_LONG( sh4r.r[Rn], sh4r.r[Rm] ); :}
1.10 + MOV.B Rm, @-Rn {: MEM_WRITE_BYTE( sh4r.r[Rn]-1, sh4r.r[Rm] ); sh4r.r[Rn]--; :}
1.11 + MOV.W Rm, @-Rn {: CHECKWALIGN16( sh4r.r[Rn] ); MEM_WRITE_WORD( sh4r.r[Rn]-2, sh4r.r[Rm] ); sh4r.r[Rn] -= 2; :}
1.12 + MOV.L Rm, @-Rn {: CHECKWALIGN32( sh4r.r[Rn] ); MEM_WRITE_LONG( sh4r.r[Rn]-4, sh4r.r[Rm] ); sh4r.r[Rn] -= 4; :}
1.13 MOV.L @(disp, Rm), Rn {:
1.14 tmp = sh4r.r[Rm] + disp;
1.15 CHECKRALIGN32( tmp );
1.16 @@ -501,14 +501,24 @@
1.17 sh4r.t = ( sh4r.r[Rn] == 0 ? 1 : 0 );
1.18 :}
1.19 MAC.W @Rm+, @Rn+ {:
1.20 - CHECKRALIGN16( sh4r.r[Rn] );
1.21 - CHECKRALIGN16( sh4r.r[Rm] );
1.22 - MEM_READ_WORD(sh4r.r[Rn], tmp);
1.23 - int32_t stmp = SIGNEXT16(tmp);
1.24 - sh4r.r[Rn] += 2;
1.25 - MEM_READ_WORD(sh4r.r[Rm], tmp);
1.26 - stmp = stmp * SIGNEXT16(tmp);
1.27 - sh4r.r[Rm] += 2;
1.28 + int32_t stmp;
1.29 + if( Rm == Rn ) {
1.30 + CHECKRALIGN16(sh4r.r[Rn]);
1.31 + MEM_READ_WORD( sh4r.r[Rn], tmp );
1.32 + stmp = SIGNEXT16(tmp);
1.33 + MEM_READ_WORD( sh4r.r[Rn]+2, tmp );
1.34 + stmp *= SIGNEXT16(tmp);
1.35 + sh4r.r[Rn] += 4;
1.36 + } else {
1.37 + CHECKRALIGN16( sh4r.r[Rn] );
1.38 + CHECKRALIGN16( sh4r.r[Rm] );
1.39 + MEM_READ_WORD(sh4r.r[Rn], tmp);
1.40 + stmp = SIGNEXT16(tmp);
1.41 + MEM_READ_WORD(sh4r.r[Rm], tmp);
1.42 + stmp = stmp * SIGNEXT16(tmp);
1.43 + sh4r.r[Rn] += 2;
1.44 + sh4r.r[Rm] += 2;
1.45 + }
1.46 if( sh4r.s ) {
1.47 int64_t tmpl = (int64_t)((int32_t)sh4r.mac) + (int64_t)stmp;
1.48 if( tmpl > (int64_t)0x000000007FFFFFFFLL ) {
1.49 @@ -524,14 +534,24 @@
1.50 }
1.51 :}
1.52 MAC.L @Rm+, @Rn+ {:
1.53 - CHECKRALIGN32( sh4r.r[Rm] );
1.54 - CHECKRALIGN32( sh4r.r[Rn] );
1.55 - MEM_READ_LONG(sh4r.r[Rn], tmp);
1.56 - int64_t tmpl = SIGNEXT32(tmp);
1.57 - sh4r.r[Rn] += 4;
1.58 - MEM_READ_LONG(sh4r.r[Rm], tmp);
1.59 - tmpl = tmpl * SIGNEXT32(tmp) + sh4r.mac;
1.60 - sh4r.r[Rm] += 4;
1.61 + int64_t tmpl;
1.62 + if( Rm == Rn ) {
1.63 + CHECKRALIGN32( sh4r.r[Rn] );
1.64 + MEM_READ_LONG(sh4r.r[Rn], tmp);
1.65 + tmpl = SIGNEXT32(tmp);
1.66 + MEM_READ_LONG(sh4r.r[Rn]+4, tmp);
1.67 + tmpl = tmpl * SIGNEXT32(tmp) + sh4r.mac;
1.68 + sh4r.r[Rn] += 8;
1.69 + } else {
1.70 + CHECKRALIGN32( sh4r.r[Rm] );
1.71 + CHECKRALIGN32( sh4r.r[Rn] );
1.72 + MEM_READ_LONG(sh4r.r[Rn], tmp);
1.73 + tmpl = SIGNEXT32(tmp);
1.74 + MEM_READ_LONG(sh4r.r[Rm], tmp);
1.75 + tmpl = tmpl * SIGNEXT32(tmp) + sh4r.mac;
1.76 + sh4r.r[Rn] += 4;
1.77 + sh4r.r[Rm] += 4;
1.78 + }
1.79 if( sh4r.s ) {
1.80 /* 48-bit Saturation. Yuch */
1.81 if( tmpl < (int64_t)0xFFFF800000000000LL )
1.82 @@ -692,15 +712,15 @@
1.83 :}
1.84 STS MACH, Rn {: sh4r.r[Rn] = (sh4r.mac>>32); :}
1.85 STS.L MACH, @-Rn {:
1.86 + CHECKWALIGN32( sh4r.r[Rn] );
1.87 + MEM_WRITE_LONG( sh4r.r[Rn]-4, (sh4r.mac>>32) );
1.88 sh4r.r[Rn] -= 4;
1.89 - CHECKWALIGN32( sh4r.r[Rn] );
1.90 - MEM_WRITE_LONG( sh4r.r[Rn], (sh4r.mac>>32) );
1.91 :}
1.92 STC.L SR, @-Rn {:
1.93 CHECKPRIV();
1.94 + CHECKWALIGN32( sh4r.r[Rn] );
1.95 + MEM_WRITE_LONG( sh4r.r[Rn]-4, sh4_read_sr() );
1.96 sh4r.r[Rn] -= 4;
1.97 - CHECKWALIGN32( sh4r.r[Rn] );
1.98 - MEM_WRITE_LONG( sh4r.r[Rn], sh4_read_sr() );
1.99 :}
1.100 LDS.L @Rm+, MACH {:
1.101 CHECKRALIGN32( sh4r.r[Rm] );
1.102 @@ -738,14 +758,14 @@
1.103 :}
1.104 STS MACL, Rn {: sh4r.r[Rn] = (uint32_t)sh4r.mac; :}
1.105 STS.L MACL, @-Rn {:
1.106 + CHECKWALIGN32( sh4r.r[Rn] );
1.107 + MEM_WRITE_LONG( sh4r.r[Rn]-4, (uint32_t)sh4r.mac );
1.108 sh4r.r[Rn] -= 4;
1.109 - CHECKWALIGN32( sh4r.r[Rn] );
1.110 - MEM_WRITE_LONG( sh4r.r[Rn], (uint32_t)sh4r.mac );
1.111 :}
1.112 STC.L GBR, @-Rn {:
1.113 + CHECKWALIGN32( sh4r.r[Rn] );
1.114 + MEM_WRITE_LONG( sh4r.r[Rn]-4, sh4r.gbr );
1.115 sh4r.r[Rn] -= 4;
1.116 - CHECKWALIGN32( sh4r.r[Rn] );
1.117 - MEM_WRITE_LONG( sh4r.r[Rn], sh4r.gbr );
1.118 :}
1.119 LDS.L @Rm+, MACL {:
1.120 CHECKRALIGN32( sh4r.r[Rm] );
1.121 @@ -766,15 +786,15 @@
1.122 LDC Rm, GBR {: sh4r.gbr = sh4r.r[Rm]; :}
1.123 STS PR, Rn {: sh4r.r[Rn] = sh4r.pr; :}
1.124 STS.L PR, @-Rn {:
1.125 + CHECKWALIGN32( sh4r.r[Rn] );
1.126 + MEM_WRITE_LONG( sh4r.r[Rn]-4, sh4r.pr );
1.127 sh4r.r[Rn] -= 4;
1.128 - CHECKWALIGN32( sh4r.r[Rn] );
1.129 - MEM_WRITE_LONG( sh4r.r[Rn], sh4r.pr );
1.130 :}
1.131 STC.L VBR, @-Rn {:
1.132 CHECKPRIV();
1.133 + CHECKWALIGN32( sh4r.r[Rn] );
1.134 + MEM_WRITE_LONG( sh4r.r[Rn]-4, sh4r.vbr );
1.135 sh4r.r[Rn] -= 4;
1.136 - CHECKWALIGN32( sh4r.r[Rn] );
1.137 - MEM_WRITE_LONG( sh4r.r[Rn], sh4r.vbr );
1.138 :}
1.139 LDS.L @Rm+, PR {:
1.140 CHECKRALIGN32( sh4r.r[Rm] );
1.141 @@ -798,15 +818,15 @@
1.142 :}
1.143 STC.L SGR, @-Rn {:
1.144 CHECKPRIV();
1.145 + CHECKWALIGN32( sh4r.r[Rn] );
1.146 + MEM_WRITE_LONG( sh4r.r[Rn]-4, sh4r.sgr );
1.147 sh4r.r[Rn] -= 4;
1.148 - CHECKWALIGN32( sh4r.r[Rn] );
1.149 - MEM_WRITE_LONG( sh4r.r[Rn], sh4r.sgr );
1.150 :}
1.151 STC.L SSR, @-Rn {:
1.152 CHECKPRIV();
1.153 + CHECKWALIGN32( sh4r.r[Rn] );
1.154 + MEM_WRITE_LONG( sh4r.r[Rn]-4, sh4r.ssr );
1.155 sh4r.r[Rn] -= 4;
1.156 - CHECKWALIGN32( sh4r.r[Rn] );
1.157 - MEM_WRITE_LONG( sh4r.r[Rn], sh4r.ssr );
1.158 :}
1.159 LDC.L @Rm+, SSR {:
1.160 CHECKPRIV();
1.161 @@ -820,9 +840,9 @@
1.162 :}
1.163 STC.L SPC, @-Rn {:
1.164 CHECKPRIV();
1.165 + CHECKWALIGN32( sh4r.r[Rn] );
1.166 + MEM_WRITE_LONG( sh4r.r[Rn]-4, sh4r.spc );
1.167 sh4r.r[Rn] -= 4;
1.168 - CHECKWALIGN32( sh4r.r[Rn] );
1.169 - MEM_WRITE_LONG( sh4r.r[Rn], sh4r.spc );
1.170 :}
1.171 LDC.L @Rm+, SPC {:
1.172 CHECKPRIV();
1.173 @@ -836,9 +856,9 @@
1.174 :}
1.175 STS FPUL, Rn {: sh4r.r[Rn] = sh4r.fpul; :}
1.176 STS.L FPUL, @-Rn {:
1.177 + CHECKWALIGN32( sh4r.r[Rn] );
1.178 + MEM_WRITE_LONG( sh4r.r[Rn]-4, sh4r.fpul );
1.179 sh4r.r[Rn] -= 4;
1.180 - CHECKWALIGN32( sh4r.r[Rn] );
1.181 - MEM_WRITE_LONG( sh4r.r[Rn], sh4r.fpul );
1.182 :}
1.183 LDS.L @Rm+, FPUL {:
1.184 CHECKRALIGN32( sh4r.r[Rm] );
1.185 @@ -848,9 +868,9 @@
1.186 LDS Rm, FPUL {: sh4r.fpul = sh4r.r[Rm]; :}
1.187 STS FPSCR, Rn {: sh4r.r[Rn] = sh4r.fpscr; :}
1.188 STS.L FPSCR, @-Rn {:
1.189 + CHECKWALIGN32( sh4r.r[Rn] );
1.190 + MEM_WRITE_LONG( sh4r.r[Rn]-4, sh4r.fpscr );
1.191 sh4r.r[Rn] -= 4;
1.192 - CHECKWALIGN32( sh4r.r[Rn] );
1.193 - MEM_WRITE_LONG( sh4r.r[Rn], sh4r.fpscr );
1.194 :}
1.195 LDS.L @Rm+, FPSCR {:
1.196 CHECKRALIGN32( sh4r.r[Rm] );
1.197 @@ -865,9 +885,9 @@
1.198 STC DBR, Rn {: CHECKPRIV(); sh4r.r[Rn] = sh4r.dbr; :}
1.199 STC.L DBR, @-Rn {:
1.200 CHECKPRIV();
1.201 + CHECKWALIGN32( sh4r.r[Rn] );
1.202 + MEM_WRITE_LONG( sh4r.r[Rn]-4, sh4r.dbr );
1.203 sh4r.r[Rn] -= 4;
1.204 - CHECKWALIGN32( sh4r.r[Rn] );
1.205 - MEM_WRITE_LONG( sh4r.r[Rn], sh4r.dbr );
1.206 :}
1.207 LDC.L @Rm+, DBR {:
1.208 CHECKPRIV();
1.209 @@ -881,9 +901,9 @@
1.210 :}
1.211 STC.L Rm_BANK, @-Rn {:
1.212 CHECKPRIV();
1.213 + CHECKWALIGN32( sh4r.r[Rn] );
1.214 + MEM_WRITE_LONG( sh4r.r[Rn]-4, sh4r.r_bank[Rm_BANK] );
1.215 sh4r.r[Rn] -= 4;
1.216 - CHECKWALIGN32( sh4r.r[Rn] );
1.217 - MEM_WRITE_LONG( sh4r.r[Rn], sh4r.r_bank[Rm_BANK] );
1.218 :}
1.219 LDC.L @Rm+, Rn_BANK {:
1.220 CHECKPRIV();
1.221 @@ -978,7 +998,7 @@
1.222 FMOV @Rm, FRn {: MEM_FP_READ( sh4r.r[Rm], FRn ); :}
1.223 FMOV @Rm+, FRn {: MEM_FP_READ( sh4r.r[Rm], FRn ); sh4r.r[Rm] += FP_WIDTH; :}
1.224 FMOV FRm, @Rn {: MEM_FP_WRITE( sh4r.r[Rn], FRm ); :}
1.225 -FMOV FRm, @-Rn {: sh4r.r[Rn] -= FP_WIDTH; MEM_FP_WRITE( sh4r.r[Rn], FRm ); :}
1.226 + FMOV FRm, @-Rn {: MEM_FP_WRITE( sh4r.r[Rn] - FP_WIDTH, FRm ); sh4r.r[Rn] -= FP_WIDTH; :}
1.227 FMOV FRm, FRn {:
1.228 if( IS_FPU_DOUBLESIZE() )
1.229 DR(FRn) = DR(FRm);
.