Search
lxdream.org :: lxdream/src/sh4/sh4core.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4core.c
changeset 490:1e0f9940e064
prev430:467519b050f4
next550:a27e31340147
author nkeynes
date Sun Nov 04 08:49:18 2007 +0000 (12 years ago)
permissions -rw-r--r--
last change Fix pointer=>int conversions to use intptr_t types
file annotate diff log raw
nkeynes@23
     1
/**
nkeynes@490
     2
 * $Id: sh4core.c,v 1.50 2007-11-04 08:49:18 nkeynes Exp $
nkeynes@23
     3
 * 
nkeynes@23
     4
 * SH4 emulation core, and parent module for all the SH4 peripheral
nkeynes@23
     5
 * modules.
nkeynes@23
     6
 *
nkeynes@23
     7
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@23
     8
 *
nkeynes@23
     9
 * This program is free software; you can redistribute it and/or modify
nkeynes@23
    10
 * it under the terms of the GNU General Public License as published by
nkeynes@23
    11
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@23
    12
 * (at your option) any later version.
nkeynes@23
    13
 *
nkeynes@23
    14
 * This program is distributed in the hope that it will be useful,
nkeynes@23
    15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@23
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@23
    17
 * GNU General Public License for more details.
nkeynes@23
    18
 */
nkeynes@23
    19
nkeynes@35
    20
#define MODULE sh4_module
nkeynes@1
    21
#include <math.h>
nkeynes@1
    22
#include "dream.h"
nkeynes@430
    23
#include "dreamcast.h"
nkeynes@430
    24
#include "eventq.h"
nkeynes@430
    25
#include "mem.h"
nkeynes@430
    26
#include "clock.h"
nkeynes@430
    27
#include "syscall.h"
nkeynes@84
    28
#include "sh4/sh4core.h"
nkeynes@84
    29
#include "sh4/sh4mmio.h"
nkeynes@84
    30
#include "sh4/intc.h"
nkeynes@1
    31
nkeynes@157
    32
#define SH4_CALLTRACE 1
nkeynes@157
    33
nkeynes@123
    34
#define MAX_INT 0x7FFFFFFF
nkeynes@123
    35
#define MIN_INT 0x80000000
nkeynes@123
    36
#define MAX_INTF 2147483647.0
nkeynes@123
    37
#define MIN_INTF -2147483648.0
nkeynes@123
    38
nkeynes@23
    39
/********************** SH4 Module Definition ****************************/
nkeynes@23
    40
nkeynes@391
    41
uint16_t *sh4_icache = NULL;
nkeynes@391
    42
uint32_t sh4_icache_addr = 0;
nkeynes@43
    43
nkeynes@30
    44
uint32_t sh4_run_slice( uint32_t nanosecs ) 
nkeynes@1
    45
{
nkeynes@23
    46
    int i;
nkeynes@265
    47
    sh4r.slice_cycle = 0;
nkeynes@23
    48
nkeynes@27
    49
    if( sh4r.sh4_state != SH4_STATE_RUNNING ) {
nkeynes@265
    50
	if( sh4r.event_pending < nanosecs ) {
nkeynes@265
    51
	    sh4r.sh4_state = SH4_STATE_RUNNING;
nkeynes@265
    52
	    sh4r.slice_cycle = sh4r.event_pending;
nkeynes@265
    53
	}
nkeynes@23
    54
    }
nkeynes@27
    55
nkeynes@235
    56
    if( sh4_breakpoint_count == 0 ) {
nkeynes@265
    57
	for( ; sh4r.slice_cycle < nanosecs; sh4r.slice_cycle += sh4_cpu_period ) {
nkeynes@265
    58
	    if( SH4_EVENT_PENDING() ) {
nkeynes@265
    59
		if( sh4r.event_types & PENDING_EVENT ) {
nkeynes@265
    60
		    event_execute();
nkeynes@265
    61
		}
nkeynes@265
    62
		/* Eventq execute may (quite likely) deliver an immediate IRQ */
nkeynes@265
    63
		if( sh4r.event_types & PENDING_IRQ ) {
nkeynes@265
    64
		    sh4_accept_interrupt();
nkeynes@265
    65
		}
nkeynes@265
    66
	    }
nkeynes@235
    67
	    if( !sh4_execute_instruction() ) {
nkeynes@43
    68
		break;
nkeynes@43
    69
	    }
nkeynes@43
    70
	}
nkeynes@235
    71
    } else {
nkeynes@265
    72
	for( ;sh4r.slice_cycle < nanosecs; sh4r.slice_cycle += sh4_cpu_period ) {
nkeynes@265
    73
	    if( SH4_EVENT_PENDING() ) {
nkeynes@265
    74
		if( sh4r.event_types & PENDING_EVENT ) {
nkeynes@265
    75
		    event_execute();
nkeynes@265
    76
		}
nkeynes@265
    77
		/* Eventq execute may (quite likely) deliver an immediate IRQ */
nkeynes@265
    78
		if( sh4r.event_types & PENDING_IRQ ) {
nkeynes@265
    79
		    sh4_accept_interrupt();
nkeynes@265
    80
		}
nkeynes@265
    81
	    }
nkeynes@265
    82
                 
nkeynes@235
    83
	    if( !sh4_execute_instruction() )
nkeynes@235
    84
		break;
nkeynes@235
    85
#ifdef ENABLE_DEBUG_MODE
nkeynes@235
    86
	    for( i=0; i<sh4_breakpoint_count; i++ ) {
nkeynes@235
    87
		if( sh4_breakpoints[i].address == sh4r.pc ) {
nkeynes@235
    88
		    break;
nkeynes@235
    89
		}
nkeynes@235
    90
	    }
nkeynes@235
    91
	    if( i != sh4_breakpoint_count ) {
nkeynes@235
    92
		dreamcast_stop();
nkeynes@235
    93
		if( sh4_breakpoints[i].type == BREAK_ONESHOT )
nkeynes@235
    94
		    sh4_clear_breakpoint( sh4r.pc, BREAK_ONESHOT );
nkeynes@235
    95
		break;
nkeynes@235
    96
	    }
nkeynes@235
    97
#endif	
nkeynes@43
    98
	}
nkeynes@27
    99
    }
nkeynes@30
   100
nkeynes@30
   101
    /* If we aborted early, but the cpu is still technically running,
nkeynes@30
   102
     * we're doing a hard abort - cut the timeslice back to what we
nkeynes@30
   103
     * actually executed
nkeynes@30
   104
     */
nkeynes@53
   105
    if( sh4r.slice_cycle != nanosecs && sh4r.sh4_state == SH4_STATE_RUNNING ) {
nkeynes@53
   106
	nanosecs = sh4r.slice_cycle;
nkeynes@27
   107
    }
nkeynes@27
   108
    if( sh4r.sh4_state != SH4_STATE_STANDBY ) {
nkeynes@30
   109
	TMU_run_slice( nanosecs );
nkeynes@30
   110
	SCIF_run_slice( nanosecs );
nkeynes@27
   111
    }
nkeynes@30
   112
    return nanosecs;
nkeynes@1
   113
}
nkeynes@1
   114
nkeynes@23
   115
/********************** SH4 emulation core  ****************************/
nkeynes@23
   116
nkeynes@246
   117
#define UNDEF(ir) return sh4_raise_slot_exception(EXC_ILLEGAL, EXC_SLOT_ILLEGAL)
nkeynes@27
   118
#define UNIMP(ir) do{ ERROR( "Halted on unimplemented instruction at %08x, opcode = %04x", sh4r.pc, ir ); dreamcast_stop(); return FALSE; }while(0)
nkeynes@1
   119
nkeynes@157
   120
#if(SH4_CALLTRACE == 1)
nkeynes@157
   121
#define MAX_CALLSTACK 32
nkeynes@157
   122
static struct call_stack {
nkeynes@157
   123
    sh4addr_t call_addr;
nkeynes@157
   124
    sh4addr_t target_addr;
nkeynes@157
   125
    sh4addr_t stack_pointer;
nkeynes@157
   126
} call_stack[MAX_CALLSTACK];
nkeynes@157
   127
nkeynes@157
   128
static int call_stack_depth = 0;
nkeynes@157
   129
int sh4_call_trace_on = 0;
nkeynes@157
   130
nkeynes@430
   131
static inline void trace_call( sh4addr_t source, sh4addr_t dest ) 
nkeynes@157
   132
{
nkeynes@157
   133
    if( call_stack_depth < MAX_CALLSTACK ) {
nkeynes@157
   134
	call_stack[call_stack_depth].call_addr = source;
nkeynes@157
   135
	call_stack[call_stack_depth].target_addr = dest;
nkeynes@157
   136
	call_stack[call_stack_depth].stack_pointer = sh4r.r[15];
nkeynes@157
   137
    }
nkeynes@157
   138
    call_stack_depth++;
nkeynes@157
   139
}
nkeynes@157
   140
nkeynes@430
   141
static inline void trace_return( sh4addr_t source, sh4addr_t dest )
nkeynes@157
   142
{
nkeynes@157
   143
    if( call_stack_depth > 0 ) {
nkeynes@157
   144
	call_stack_depth--;
nkeynes@157
   145
    }
nkeynes@157
   146
}
nkeynes@157
   147
nkeynes@157
   148
void fprint_stack_trace( FILE *f )
nkeynes@157
   149
{
nkeynes@157
   150
    int i = call_stack_depth -1;
nkeynes@157
   151
    if( i >= MAX_CALLSTACK )
nkeynes@157
   152
	i = MAX_CALLSTACK - 1;
nkeynes@157
   153
    for( ; i >= 0; i-- ) {
nkeynes@157
   154
	fprintf( f, "%d. Call from %08X => %08X, SP=%08X\n", 
nkeynes@157
   155
		 (call_stack_depth - i), call_stack[i].call_addr,
nkeynes@157
   156
		 call_stack[i].target_addr, call_stack[i].stack_pointer );
nkeynes@157
   157
    }
nkeynes@157
   158
}
nkeynes@157
   159
nkeynes@157
   160
#define TRACE_CALL( source, dest ) trace_call(source, dest)
nkeynes@157
   161
#define TRACE_RETURN( source, dest ) trace_return(source, dest)
nkeynes@157
   162
#else
nkeynes@157
   163
#define TRACE_CALL( dest, rts ) 
nkeynes@157
   164
#define TRACE_RETURN( source, dest )
nkeynes@157
   165
#endif
nkeynes@157
   166
nkeynes@10
   167
#define MEM_READ_BYTE( addr ) sh4_read_byte(addr)
nkeynes@10
   168
#define MEM_READ_WORD( addr ) sh4_read_word(addr)
nkeynes@10
   169
#define MEM_READ_LONG( addr ) sh4_read_long(addr)
nkeynes@10
   170
#define MEM_WRITE_BYTE( addr, val ) sh4_write_byte(addr, val)
nkeynes@10
   171
#define MEM_WRITE_WORD( addr, val ) sh4_write_word(addr, val)
nkeynes@10
   172
#define MEM_WRITE_LONG( addr, val ) sh4_write_long(addr, val)
nkeynes@1
   173
nkeynes@1
   174
#define FP_WIDTH (IS_FPU_DOUBLESIZE() ? 8 : 4)
nkeynes@1
   175
nkeynes@124
   176
#define MEM_FP_READ( addr, reg ) sh4_read_float( addr, reg );
nkeynes@124
   177
#define MEM_FP_WRITE( addr, reg ) sh4_write_float( addr, reg );
nkeynes@84
   178
nkeynes@246
   179
#define CHECKPRIV() if( !IS_SH4_PRIVMODE() ) return sh4_raise_slot_exception( EXC_ILLEGAL, EXC_SLOT_ILLEGAL )
nkeynes@367
   180
#define CHECKRALIGN16(addr) if( (addr)&0x01 ) return sh4_raise_exception( EXC_DATA_ADDR_READ )
nkeynes@367
   181
#define CHECKRALIGN32(addr) if( (addr)&0x03 ) return sh4_raise_exception( EXC_DATA_ADDR_READ )
nkeynes@367
   182
#define CHECKWALIGN16(addr) if( (addr)&0x01 ) return sh4_raise_exception( EXC_DATA_ADDR_WRITE )
nkeynes@367
   183
#define CHECKWALIGN32(addr) if( (addr)&0x03 ) return sh4_raise_exception( EXC_DATA_ADDR_WRITE )
nkeynes@208
   184
nkeynes@367
   185
#define CHECKFPUEN() if( !IS_FPU_ENABLED() ) { if( ir == 0xFFFD ) { UNDEF(ir); } else { return sh4_raise_slot_exception( EXC_FPU_DISABLED, EXC_SLOT_FPU_DISABLED ); } }
nkeynes@84
   186
#define CHECKDEST(p) if( (p) == 0 ) { ERROR( "%08X: Branch/jump to NULL, CPU halted", sh4r.pc ); dreamcast_stop(); return FALSE; }
nkeynes@246
   187
#define CHECKSLOTILLEGAL() if(sh4r.in_delay_slot) return sh4_raise_exception(EXC_SLOT_ILLEGAL)
nkeynes@1
   188
nkeynes@124
   189
static void sh4_write_float( uint32_t addr, int reg )
nkeynes@124
   190
{
nkeynes@124
   191
    if( IS_FPU_DOUBLESIZE() ) {
nkeynes@124
   192
	if( reg & 1 ) {
nkeynes@124
   193
	    sh4_write_long( addr, *((uint32_t *)&XF((reg)&0x0E)) );
nkeynes@124
   194
	    sh4_write_long( addr+4, *((uint32_t *)&XF(reg)) );
nkeynes@124
   195
	} else {
nkeynes@124
   196
	    sh4_write_long( addr, *((uint32_t *)&FR(reg)) ); 
nkeynes@124
   197
	    sh4_write_long( addr+4, *((uint32_t *)&FR((reg)|0x01)) );
nkeynes@124
   198
	}
nkeynes@124
   199
    } else {
nkeynes@124
   200
	sh4_write_long( addr, *((uint32_t *)&FR((reg))) );
nkeynes@124
   201
    }
nkeynes@124
   202
}
nkeynes@124
   203
nkeynes@124
   204
static void sh4_read_float( uint32_t addr, int reg )
nkeynes@124
   205
{
nkeynes@124
   206
    if( IS_FPU_DOUBLESIZE() ) {
nkeynes@124
   207
	if( reg & 1 ) {
nkeynes@124
   208
	    *((uint32_t *)&XF((reg) & 0x0E)) = sh4_read_long(addr);
nkeynes@124
   209
	    *((uint32_t *)&XF(reg)) = sh4_read_long(addr+4);
nkeynes@124
   210
	} else {
nkeynes@124
   211
	    *((uint32_t *)&FR(reg)) = sh4_read_long(addr);
nkeynes@124
   212
	    *((uint32_t *)&FR((reg) | 0x01)) = sh4_read_long(addr+4);
nkeynes@124
   213
	}
nkeynes@124
   214
    } else {
nkeynes@124
   215
	*((uint32_t *)&FR(reg)) = sh4_read_long(addr);
nkeynes@124
   216
    }
nkeynes@124
   217
}
nkeynes@124
   218
nkeynes@27
   219
gboolean sh4_execute_instruction( void )
nkeynes@1
   220
{
nkeynes@84
   221
    uint32_t pc;
nkeynes@2
   222
    unsigned short ir;
nkeynes@1
   223
    uint32_t tmp;
nkeynes@123
   224
    float ftmp;
nkeynes@123
   225
    double dtmp;
nkeynes@1
   226
    
nkeynes@1
   227
#define R0 sh4r.r[0]
nkeynes@2
   228
    pc = sh4r.pc;
nkeynes@84
   229
    if( pc > 0xFFFFFF00 ) {
nkeynes@84
   230
	/* SYSCALL Magic */
nkeynes@102
   231
	syscall_invoke( pc );
nkeynes@104
   232
	sh4r.in_delay_slot = 0;
nkeynes@84
   233
	pc = sh4r.pc = sh4r.pr;
nkeynes@84
   234
	sh4r.new_pc = sh4r.pc + 2;
nkeynes@84
   235
    }
nkeynes@208
   236
    CHECKRALIGN16(pc);
nkeynes@235
   237
nkeynes@235
   238
    /* Read instruction */
nkeynes@235
   239
    uint32_t pageaddr = pc >> 12;
nkeynes@235
   240
    if( sh4_icache != NULL && pageaddr == sh4_icache_addr ) {
nkeynes@235
   241
	ir = sh4_icache[(pc&0xFFF)>>1];
nkeynes@235
   242
    } else {
nkeynes@235
   243
	sh4_icache = (uint16_t *)mem_get_page(pc);
nkeynes@490
   244
	if( ((uintptr_t)sh4_icache) < MAX_IO_REGIONS ) {
nkeynes@235
   245
	    /* If someone's actually been so daft as to try to execute out of an IO
nkeynes@235
   246
	     * region, fallback on the full-blown memory read
nkeynes@235
   247
	     */
nkeynes@235
   248
	    sh4_icache = NULL;
nkeynes@235
   249
	    ir = MEM_READ_WORD(pc);
nkeynes@235
   250
	} else {
nkeynes@235
   251
	    sh4_icache_addr = pageaddr;
nkeynes@235
   252
	    ir = sh4_icache[(pc&0xFFF)>>1];
nkeynes@235
   253
	}
nkeynes@235
   254
    }
nkeynes@359
   255
        switch( (ir&0xF000) >> 12 ) {
nkeynes@359
   256
            case 0x0:
nkeynes@359
   257
                switch( ir&0xF ) {
nkeynes@359
   258
                    case 0x2:
nkeynes@359
   259
                        switch( (ir&0x80) >> 7 ) {
nkeynes@359
   260
                            case 0x0:
nkeynes@359
   261
                                switch( (ir&0x70) >> 4 ) {
nkeynes@359
   262
                                    case 0x0:
nkeynes@359
   263
                                        { /* STC SR, Rn */
nkeynes@359
   264
                                        uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   265
                                        CHECKPRIV();
nkeynes@359
   266
                                        sh4r.r[Rn] = sh4_read_sr();
nkeynes@359
   267
                                        }
nkeynes@359
   268
                                        break;
nkeynes@359
   269
                                    case 0x1:
nkeynes@359
   270
                                        { /* STC GBR, Rn */
nkeynes@359
   271
                                        uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   272
                                        CHECKPRIV();
nkeynes@359
   273
                                        sh4r.r[Rn] = sh4r.gbr;
nkeynes@359
   274
                                        }
nkeynes@359
   275
                                        break;
nkeynes@359
   276
                                    case 0x2:
nkeynes@359
   277
                                        { /* STC VBR, Rn */
nkeynes@359
   278
                                        uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   279
                                        CHECKPRIV();
nkeynes@359
   280
                                        sh4r.r[Rn] = sh4r.vbr;
nkeynes@359
   281
                                        }
nkeynes@359
   282
                                        break;
nkeynes@359
   283
                                    case 0x3:
nkeynes@359
   284
                                        { /* STC SSR, Rn */
nkeynes@359
   285
                                        uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   286
                                        CHECKPRIV();
nkeynes@359
   287
                                        sh4r.r[Rn] = sh4r.ssr;
nkeynes@359
   288
                                        }
nkeynes@359
   289
                                        break;
nkeynes@359
   290
                                    case 0x4:
nkeynes@359
   291
                                        { /* STC SPC, Rn */
nkeynes@359
   292
                                        uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   293
                                        CHECKPRIV();
nkeynes@359
   294
                                        sh4r.r[Rn] = sh4r.spc;
nkeynes@359
   295
                                        }
nkeynes@359
   296
                                        break;
nkeynes@359
   297
                                    default:
nkeynes@359
   298
                                        UNDEF();
nkeynes@359
   299
                                        break;
nkeynes@359
   300
                                }
nkeynes@359
   301
                                break;
nkeynes@359
   302
                            case 0x1:
nkeynes@359
   303
                                { /* STC Rm_BANK, Rn */
nkeynes@359
   304
                                uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm_BANK = ((ir>>4)&0x7); 
nkeynes@359
   305
                                CHECKPRIV();
nkeynes@359
   306
                                sh4r.r[Rn] = sh4r.r_bank[Rm_BANK];
nkeynes@359
   307
                                }
nkeynes@359
   308
                                break;
nkeynes@359
   309
                        }
nkeynes@359
   310
                        break;
nkeynes@359
   311
                    case 0x3:
nkeynes@359
   312
                        switch( (ir&0xF0) >> 4 ) {
nkeynes@359
   313
                            case 0x0:
nkeynes@359
   314
                                { /* BSRF Rn */
nkeynes@359
   315
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   316
                                CHECKSLOTILLEGAL();
nkeynes@359
   317
                                CHECKDEST( pc + 4 + sh4r.r[Rn] );
nkeynes@359
   318
                                sh4r.in_delay_slot = 1;
nkeynes@359
   319
                                sh4r.pr = sh4r.pc + 4;
nkeynes@359
   320
                                sh4r.pc = sh4r.new_pc;
nkeynes@359
   321
                                sh4r.new_pc = pc + 4 + sh4r.r[Rn];
nkeynes@359
   322
                                TRACE_CALL( pc, sh4r.new_pc );
nkeynes@359
   323
                                return TRUE;
nkeynes@359
   324
                                }
nkeynes@359
   325
                                break;
nkeynes@359
   326
                            case 0x2:
nkeynes@359
   327
                                { /* BRAF Rn */
nkeynes@359
   328
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   329
                                CHECKSLOTILLEGAL();
nkeynes@359
   330
                                CHECKDEST( pc + 4 + sh4r.r[Rn] );
nkeynes@359
   331
                                sh4r.in_delay_slot = 1;
nkeynes@359
   332
                                sh4r.pc = sh4r.new_pc;
nkeynes@359
   333
                                sh4r.new_pc = pc + 4 + sh4r.r[Rn];
nkeynes@359
   334
                                return TRUE;
nkeynes@359
   335
                                }
nkeynes@359
   336
                                break;
nkeynes@359
   337
                            case 0x8:
nkeynes@359
   338
                                { /* PREF @Rn */
nkeynes@359
   339
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   340
                                tmp = sh4r.r[Rn];
nkeynes@359
   341
                                if( (tmp & 0xFC000000) == 0xE0000000 ) {
nkeynes@369
   342
                           	 sh4_flush_store_queue(tmp);
nkeynes@359
   343
                                }
nkeynes@359
   344
                                }
nkeynes@359
   345
                                break;
nkeynes@359
   346
                            case 0x9:
nkeynes@359
   347
                                { /* OCBI @Rn */
nkeynes@359
   348
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   349
                                }
nkeynes@359
   350
                                break;
nkeynes@359
   351
                            case 0xA:
nkeynes@359
   352
                                { /* OCBP @Rn */
nkeynes@359
   353
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   354
                                }
nkeynes@359
   355
                                break;
nkeynes@359
   356
                            case 0xB:
nkeynes@359
   357
                                { /* OCBWB @Rn */
nkeynes@359
   358
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   359
                                }
nkeynes@359
   360
                                break;
nkeynes@359
   361
                            case 0xC:
nkeynes@359
   362
                                { /* MOVCA.L R0, @Rn */
nkeynes@359
   363
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   364
                                tmp = sh4r.r[Rn];
nkeynes@359
   365
                                CHECKWALIGN32(tmp);
nkeynes@359
   366
                                MEM_WRITE_LONG( tmp, R0 );
nkeynes@359
   367
                                }
nkeynes@359
   368
                                break;
nkeynes@359
   369
                            default:
nkeynes@359
   370
                                UNDEF();
nkeynes@359
   371
                                break;
nkeynes@359
   372
                        }
nkeynes@359
   373
                        break;
nkeynes@359
   374
                    case 0x4:
nkeynes@359
   375
                        { /* MOV.B Rm, @(R0, Rn) */
nkeynes@359
   376
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   377
                        MEM_WRITE_BYTE( R0 + sh4r.r[Rn], sh4r.r[Rm] );
nkeynes@359
   378
                        }
nkeynes@359
   379
                        break;
nkeynes@359
   380
                    case 0x5:
nkeynes@359
   381
                        { /* MOV.W Rm, @(R0, Rn) */
nkeynes@359
   382
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   383
                        CHECKWALIGN16( R0 + sh4r.r[Rn] );
nkeynes@359
   384
                        MEM_WRITE_WORD( R0 + sh4r.r[Rn], sh4r.r[Rm] );
nkeynes@359
   385
                        }
nkeynes@359
   386
                        break;
nkeynes@359
   387
                    case 0x6:
nkeynes@359
   388
                        { /* MOV.L Rm, @(R0, Rn) */
nkeynes@359
   389
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   390
                        CHECKWALIGN32( R0 + sh4r.r[Rn] );
nkeynes@359
   391
                        MEM_WRITE_LONG( R0 + sh4r.r[Rn], sh4r.r[Rm] );
nkeynes@359
   392
                        }
nkeynes@359
   393
                        break;
nkeynes@359
   394
                    case 0x7:
nkeynes@359
   395
                        { /* MUL.L Rm, Rn */
nkeynes@359
   396
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   397
                        sh4r.mac = (sh4r.mac&0xFFFFFFFF00000000LL) |
nkeynes@359
   398
                                               (sh4r.r[Rm] * sh4r.r[Rn]);
nkeynes@359
   399
                        }
nkeynes@359
   400
                        break;
nkeynes@359
   401
                    case 0x8:
nkeynes@359
   402
                        switch( (ir&0xFF0) >> 4 ) {
nkeynes@359
   403
                            case 0x0:
nkeynes@359
   404
                                { /* CLRT */
nkeynes@359
   405
                                sh4r.t = 0;
nkeynes@359
   406
                                }
nkeynes@359
   407
                                break;
nkeynes@359
   408
                            case 0x1:
nkeynes@359
   409
                                { /* SETT */
nkeynes@359
   410
                                sh4r.t = 1;
nkeynes@359
   411
                                }
nkeynes@359
   412
                                break;
nkeynes@359
   413
                            case 0x2:
nkeynes@359
   414
                                { /* CLRMAC */
nkeynes@359
   415
                                sh4r.mac = 0;
nkeynes@359
   416
                                }
nkeynes@359
   417
                                break;
nkeynes@359
   418
                            case 0x3:
nkeynes@359
   419
                                { /* LDTLB */
nkeynes@359
   420
                                /* TODO */
nkeynes@359
   421
                                }
nkeynes@359
   422
                                break;
nkeynes@359
   423
                            case 0x4:
nkeynes@359
   424
                                { /* CLRS */
nkeynes@359
   425
                                sh4r.s = 0;
nkeynes@359
   426
                                }
nkeynes@359
   427
                                break;
nkeynes@359
   428
                            case 0x5:
nkeynes@359
   429
                                { /* SETS */
nkeynes@359
   430
                                sh4r.s = 1;
nkeynes@359
   431
                                }
nkeynes@359
   432
                                break;
nkeynes@359
   433
                            default:
nkeynes@359
   434
                                UNDEF();
nkeynes@359
   435
                                break;
nkeynes@359
   436
                        }
nkeynes@359
   437
                        break;
nkeynes@359
   438
                    case 0x9:
nkeynes@359
   439
                        switch( (ir&0xF0) >> 4 ) {
nkeynes@359
   440
                            case 0x0:
nkeynes@359
   441
                                { /* NOP */
nkeynes@359
   442
                                /* NOP */
nkeynes@359
   443
                                }
nkeynes@359
   444
                                break;
nkeynes@359
   445
                            case 0x1:
nkeynes@359
   446
                                { /* DIV0U */
nkeynes@359
   447
                                sh4r.m = sh4r.q = sh4r.t = 0;
nkeynes@359
   448
                                }
nkeynes@359
   449
                                break;
nkeynes@359
   450
                            case 0x2:
nkeynes@359
   451
                                { /* MOVT Rn */
nkeynes@359
   452
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   453
                                sh4r.r[Rn] = sh4r.t;
nkeynes@359
   454
                                }
nkeynes@359
   455
                                break;
nkeynes@359
   456
                            default:
nkeynes@359
   457
                                UNDEF();
nkeynes@359
   458
                                break;
nkeynes@359
   459
                        }
nkeynes@359
   460
                        break;
nkeynes@359
   461
                    case 0xA:
nkeynes@359
   462
                        switch( (ir&0xF0) >> 4 ) {
nkeynes@359
   463
                            case 0x0:
nkeynes@359
   464
                                { /* STS MACH, Rn */
nkeynes@359
   465
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   466
                                sh4r.r[Rn] = (sh4r.mac>>32);
nkeynes@359
   467
                                }
nkeynes@359
   468
                                break;
nkeynes@359
   469
                            case 0x1:
nkeynes@359
   470
                                { /* STS MACL, Rn */
nkeynes@359
   471
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   472
                                sh4r.r[Rn] = (uint32_t)sh4r.mac;
nkeynes@359
   473
                                }
nkeynes@359
   474
                                break;
nkeynes@359
   475
                            case 0x2:
nkeynes@359
   476
                                { /* STS PR, Rn */
nkeynes@359
   477
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   478
                                sh4r.r[Rn] = sh4r.pr;
nkeynes@359
   479
                                }
nkeynes@359
   480
                                break;
nkeynes@359
   481
                            case 0x3:
nkeynes@359
   482
                                { /* STC SGR, Rn */
nkeynes@359
   483
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   484
                                CHECKPRIV();
nkeynes@359
   485
                                sh4r.r[Rn] = sh4r.sgr;
nkeynes@359
   486
                                }
nkeynes@359
   487
                                break;
nkeynes@359
   488
                            case 0x5:
nkeynes@359
   489
                                { /* STS FPUL, Rn */
nkeynes@359
   490
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   491
                                sh4r.r[Rn] = sh4r.fpul;
nkeynes@359
   492
                                }
nkeynes@359
   493
                                break;
nkeynes@359
   494
                            case 0x6:
nkeynes@359
   495
                                { /* STS FPSCR, Rn */
nkeynes@359
   496
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   497
                                sh4r.r[Rn] = sh4r.fpscr;
nkeynes@359
   498
                                }
nkeynes@359
   499
                                break;
nkeynes@359
   500
                            case 0xF:
nkeynes@359
   501
                                { /* STC DBR, Rn */
nkeynes@359
   502
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   503
                                CHECKPRIV(); sh4r.r[Rn] = sh4r.dbr;
nkeynes@359
   504
                                }
nkeynes@359
   505
                                break;
nkeynes@359
   506
                            default:
nkeynes@359
   507
                                UNDEF();
nkeynes@359
   508
                                break;
nkeynes@359
   509
                        }
nkeynes@359
   510
                        break;
nkeynes@359
   511
                    case 0xB:
nkeynes@359
   512
                        switch( (ir&0xFF0) >> 4 ) {
nkeynes@359
   513
                            case 0x0:
nkeynes@359
   514
                                { /* RTS */
nkeynes@359
   515
                                CHECKSLOTILLEGAL();
nkeynes@359
   516
                                CHECKDEST( sh4r.pr );
nkeynes@359
   517
                                sh4r.in_delay_slot = 1;
nkeynes@359
   518
                                sh4r.pc = sh4r.new_pc;
nkeynes@359
   519
                                sh4r.new_pc = sh4r.pr;
nkeynes@359
   520
                                TRACE_RETURN( pc, sh4r.new_pc );
nkeynes@359
   521
                                return TRUE;
nkeynes@359
   522
                                }
nkeynes@359
   523
                                break;
nkeynes@359
   524
                            case 0x1:
nkeynes@359
   525
                                { /* SLEEP */
nkeynes@359
   526
                                if( MMIO_READ( CPG, STBCR ) & 0x80 ) {
nkeynes@359
   527
                            	sh4r.sh4_state = SH4_STATE_STANDBY;
nkeynes@359
   528
                                } else {
nkeynes@359
   529
                            	sh4r.sh4_state = SH4_STATE_SLEEP;
nkeynes@359
   530
                                }
nkeynes@359
   531
                                return FALSE; /* Halt CPU */
nkeynes@359
   532
                                }
nkeynes@359
   533
                                break;
nkeynes@359
   534
                            case 0x2:
nkeynes@359
   535
                                { /* RTE */
nkeynes@359
   536
                                CHECKPRIV();
nkeynes@359
   537
                                CHECKDEST( sh4r.spc );
nkeynes@359
   538
                                CHECKSLOTILLEGAL();
nkeynes@359
   539
                                sh4r.in_delay_slot = 1;
nkeynes@359
   540
                                sh4r.pc = sh4r.new_pc;
nkeynes@359
   541
                                sh4r.new_pc = sh4r.spc;
nkeynes@374
   542
                                sh4_write_sr( sh4r.ssr );
nkeynes@359
   543
                                return TRUE;
nkeynes@359
   544
                                }
nkeynes@359
   545
                                break;
nkeynes@359
   546
                            default:
nkeynes@359
   547
                                UNDEF();
nkeynes@359
   548
                                break;
nkeynes@359
   549
                        }
nkeynes@359
   550
                        break;
nkeynes@359
   551
                    case 0xC:
nkeynes@359
   552
                        { /* MOV.B @(R0, Rm), Rn */
nkeynes@359
   553
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   554
                        sh4r.r[Rn] = MEM_READ_BYTE( R0 + sh4r.r[Rm] );
nkeynes@359
   555
                        }
nkeynes@359
   556
                        break;
nkeynes@359
   557
                    case 0xD:
nkeynes@359
   558
                        { /* MOV.W @(R0, Rm), Rn */
nkeynes@359
   559
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   560
                        CHECKRALIGN16( R0 + sh4r.r[Rm] );
nkeynes@359
   561
                                           sh4r.r[Rn] = MEM_READ_WORD( R0 + sh4r.r[Rm] );
nkeynes@359
   562
                        }
nkeynes@359
   563
                        break;
nkeynes@359
   564
                    case 0xE:
nkeynes@359
   565
                        { /* MOV.L @(R0, Rm), Rn */
nkeynes@359
   566
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   567
                        CHECKRALIGN32( R0 + sh4r.r[Rm] );
nkeynes@359
   568
                                           sh4r.r[Rn] = MEM_READ_LONG( R0 + sh4r.r[Rm] );
nkeynes@359
   569
                        }
nkeynes@359
   570
                        break;
nkeynes@359
   571
                    case 0xF:
nkeynes@359
   572
                        { /* MAC.L @Rm+, @Rn+ */
nkeynes@359
   573
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   574
                        CHECKRALIGN32( sh4r.r[Rm] );
nkeynes@359
   575
                        CHECKRALIGN32( sh4r.r[Rn] );
nkeynes@359
   576
                        int64_t tmpl = SIGNEXT32(MEM_READ_LONG(sh4r.r[Rn]));
nkeynes@359
   577
                        sh4r.r[Rn] += 4;
nkeynes@359
   578
                        tmpl = tmpl * SIGNEXT32(MEM_READ_LONG(sh4r.r[Rm])) + sh4r.mac;
nkeynes@359
   579
                        sh4r.r[Rm] += 4;
nkeynes@359
   580
                        if( sh4r.s ) {
nkeynes@359
   581
                            /* 48-bit Saturation. Yuch */
nkeynes@359
   582
                            if( tmpl < (int64_t)0xFFFF800000000000LL )
nkeynes@359
   583
                                tmpl = 0xFFFF800000000000LL;
nkeynes@359
   584
                            else if( tmpl > (int64_t)0x00007FFFFFFFFFFFLL )
nkeynes@359
   585
                                tmpl = 0x00007FFFFFFFFFFFLL;
nkeynes@359
   586
                        }
nkeynes@359
   587
                        sh4r.mac = tmpl;
nkeynes@359
   588
                        }
nkeynes@359
   589
                        break;
nkeynes@359
   590
                    default:
nkeynes@359
   591
                        UNDEF();
nkeynes@359
   592
                        break;
nkeynes@359
   593
                }
nkeynes@359
   594
                break;
nkeynes@359
   595
            case 0x1:
nkeynes@359
   596
                { /* MOV.L Rm, @(disp, Rn) */
nkeynes@359
   597
                uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); uint32_t disp = (ir&0xF)<<2; 
nkeynes@359
   598
                tmp = sh4r.r[Rn] + disp;
nkeynes@359
   599
                CHECKWALIGN32( tmp );
nkeynes@359
   600
                MEM_WRITE_LONG( tmp, sh4r.r[Rm] );
nkeynes@359
   601
                }
nkeynes@359
   602
                break;
nkeynes@359
   603
            case 0x2:
nkeynes@359
   604
                switch( ir&0xF ) {
nkeynes@359
   605
                    case 0x0:
nkeynes@359
   606
                        { /* MOV.B Rm, @Rn */
nkeynes@359
   607
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   608
                        MEM_WRITE_BYTE( sh4r.r[Rn], sh4r.r[Rm] );
nkeynes@359
   609
                        }
nkeynes@359
   610
                        break;
nkeynes@359
   611
                    case 0x1:
nkeynes@359
   612
                        { /* MOV.W Rm, @Rn */
nkeynes@359
   613
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   614
                        CHECKWALIGN16( sh4r.r[Rn] ); MEM_WRITE_WORD( sh4r.r[Rn], sh4r.r[Rm] );
nkeynes@359
   615
                        }
nkeynes@359
   616
                        break;
nkeynes@359
   617
                    case 0x2:
nkeynes@359
   618
                        { /* MOV.L Rm, @Rn */
nkeynes@359
   619
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   620
                        CHECKWALIGN32( sh4r.r[Rn] ); MEM_WRITE_LONG( sh4r.r[Rn], sh4r.r[Rm] );
nkeynes@359
   621
                        }
nkeynes@359
   622
                        break;
nkeynes@359
   623
                    case 0x4:
nkeynes@359
   624
                        { /* MOV.B Rm, @-Rn */
nkeynes@359
   625
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   626
                        sh4r.r[Rn] --; MEM_WRITE_BYTE( sh4r.r[Rn], sh4r.r[Rm] );
nkeynes@359
   627
                        }
nkeynes@359
   628
                        break;
nkeynes@359
   629
                    case 0x5:
nkeynes@359
   630
                        { /* MOV.W Rm, @-Rn */
nkeynes@359
   631
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   632
                        sh4r.r[Rn] -= 2; CHECKWALIGN16( sh4r.r[Rn] ); MEM_WRITE_WORD( sh4r.r[Rn], sh4r.r[Rm] );
nkeynes@359
   633
                        }
nkeynes@359
   634
                        break;
nkeynes@359
   635
                    case 0x6:
nkeynes@359
   636
                        { /* MOV.L Rm, @-Rn */
nkeynes@359
   637
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   638
                        sh4r.r[Rn] -= 4; CHECKWALIGN32( sh4r.r[Rn] ); MEM_WRITE_LONG( sh4r.r[Rn], sh4r.r[Rm] );
nkeynes@359
   639
                        }
nkeynes@359
   640
                        break;
nkeynes@359
   641
                    case 0x7:
nkeynes@359
   642
                        { /* DIV0S Rm, Rn */
nkeynes@359
   643
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   644
                        sh4r.q = sh4r.r[Rn]>>31;
nkeynes@359
   645
                        sh4r.m = sh4r.r[Rm]>>31;
nkeynes@359
   646
                        sh4r.t = sh4r.q ^ sh4r.m;
nkeynes@359
   647
                        }
nkeynes@359
   648
                        break;
nkeynes@359
   649
                    case 0x8:
nkeynes@359
   650
                        { /* TST Rm, Rn */
nkeynes@359
   651
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   652
                        sh4r.t = (sh4r.r[Rn]&sh4r.r[Rm] ? 0 : 1);
nkeynes@359
   653
                        }
nkeynes@359
   654
                        break;
nkeynes@359
   655
                    case 0x9:
nkeynes@359
   656
                        { /* AND Rm, Rn */
nkeynes@359
   657
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   658
                        sh4r.r[Rn] &= sh4r.r[Rm];
nkeynes@359
   659
                        }
nkeynes@359
   660
                        break;
nkeynes@359
   661
                    case 0xA:
nkeynes@359
   662
                        { /* XOR Rm, Rn */
nkeynes@359
   663
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   664
                        sh4r.r[Rn] ^= sh4r.r[Rm];
nkeynes@359
   665
                        }
nkeynes@359
   666
                        break;
nkeynes@359
   667
                    case 0xB:
nkeynes@359
   668
                        { /* OR Rm, Rn */
nkeynes@359
   669
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   670
                        sh4r.r[Rn] |= sh4r.r[Rm];
nkeynes@359
   671
                        }
nkeynes@359
   672
                        break;
nkeynes@359
   673
                    case 0xC:
nkeynes@359
   674
                        { /* CMP/STR Rm, Rn */
nkeynes@359
   675
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   676
                        /* set T = 1 if any byte in RM & RN is the same */
nkeynes@359
   677
                        tmp = sh4r.r[Rm] ^ sh4r.r[Rn];
nkeynes@359
   678
                        sh4r.t = ((tmp&0x000000FF)==0 || (tmp&0x0000FF00)==0 ||
nkeynes@359
   679
                                 (tmp&0x00FF0000)==0 || (tmp&0xFF000000)==0)?1:0;
nkeynes@359
   680
                        }
nkeynes@359
   681
                        break;
nkeynes@359
   682
                    case 0xD:
nkeynes@359
   683
                        { /* XTRCT Rm, Rn */
nkeynes@359
   684
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   685
                        sh4r.r[Rn] = (sh4r.r[Rn]>>16) | (sh4r.r[Rm]<<16);
nkeynes@359
   686
                        }
nkeynes@359
   687
                        break;
nkeynes@359
   688
                    case 0xE:
nkeynes@359
   689
                        { /* MULU.W Rm, Rn */
nkeynes@359
   690
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   691
                        sh4r.mac = (sh4r.mac&0xFFFFFFFF00000000LL) |
nkeynes@359
   692
                                   (uint32_t)((sh4r.r[Rm]&0xFFFF) * (sh4r.r[Rn]&0xFFFF));
nkeynes@359
   693
                        }
nkeynes@359
   694
                        break;
nkeynes@359
   695
                    case 0xF:
nkeynes@359
   696
                        { /* MULS.W Rm, Rn */
nkeynes@359
   697
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   698
                        sh4r.mac = (sh4r.mac&0xFFFFFFFF00000000LL) |
nkeynes@359
   699
                                   (uint32_t)(SIGNEXT32(sh4r.r[Rm]&0xFFFF) * SIGNEXT32(sh4r.r[Rn]&0xFFFF));
nkeynes@359
   700
                        }
nkeynes@359
   701
                        break;
nkeynes@359
   702
                    default:
nkeynes@359
   703
                        UNDEF();
nkeynes@359
   704
                        break;
nkeynes@359
   705
                }
nkeynes@359
   706
                break;
nkeynes@359
   707
            case 0x3:
nkeynes@359
   708
                switch( ir&0xF ) {
nkeynes@359
   709
                    case 0x0:
nkeynes@359
   710
                        { /* CMP/EQ Rm, Rn */
nkeynes@359
   711
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   712
                        sh4r.t = ( sh4r.r[Rm] == sh4r.r[Rn] ? 1 : 0 );
nkeynes@359
   713
                        }
nkeynes@359
   714
                        break;
nkeynes@359
   715
                    case 0x2:
nkeynes@359
   716
                        { /* CMP/HS Rm, Rn */
nkeynes@359
   717
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   718
                        sh4r.t = ( sh4r.r[Rn] >= sh4r.r[Rm] ? 1 : 0 );
nkeynes@359
   719
                        }
nkeynes@359
   720
                        break;
nkeynes@359
   721
                    case 0x3:
nkeynes@359
   722
                        { /* CMP/GE Rm, Rn */
nkeynes@359
   723
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   724
                        sh4r.t = ( ((int32_t)sh4r.r[Rn]) >= ((int32_t)sh4r.r[Rm]) ? 1 : 0 );
nkeynes@359
   725
                        }
nkeynes@359
   726
                        break;
nkeynes@359
   727
                    case 0x4:
nkeynes@359
   728
                        { /* DIV1 Rm, Rn */
nkeynes@359
   729
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@384
   730
                        /* This is derived from the sh4 manual with some simplifications */
nkeynes@359
   731
                        uint32_t tmp0, tmp1, tmp2, dir;
nkeynes@359
   732
                    
nkeynes@359
   733
                        dir = sh4r.q ^ sh4r.m;
nkeynes@359
   734
                        sh4r.q = (sh4r.r[Rn] >> 31);
nkeynes@359
   735
                        tmp2 = sh4r.r[Rm];
nkeynes@359
   736
                        sh4r.r[Rn] = (sh4r.r[Rn] << 1) | sh4r.t;
nkeynes@359
   737
                        tmp0 = sh4r.r[Rn];
nkeynes@359
   738
                        if( dir ) {
nkeynes@359
   739
                             sh4r.r[Rn] += tmp2;
nkeynes@359
   740
                             tmp1 = (sh4r.r[Rn]<tmp0 ? 1 : 0 );
nkeynes@359
   741
                        } else {
nkeynes@359
   742
                             sh4r.r[Rn] -= tmp2;
nkeynes@359
   743
                             tmp1 = (sh4r.r[Rn]>tmp0 ? 1 : 0 );
nkeynes@359
   744
                        }
nkeynes@359
   745
                        sh4r.q ^= sh4r.m ^ tmp1;
nkeynes@359
   746
                        sh4r.t = ( sh4r.q == sh4r.m ? 1 : 0 );
nkeynes@359
   747
                        }
nkeynes@359
   748
                        break;
nkeynes@359
   749
                    case 0x5:
nkeynes@359
   750
                        { /* DMULU.L Rm, Rn */
nkeynes@359
   751
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   752
                        sh4r.mac = ((uint64_t)sh4r.r[Rm]) * ((uint64_t)sh4r.r[Rn]);
nkeynes@359
   753
                        }
nkeynes@359
   754
                        break;
nkeynes@359
   755
                    case 0x6:
nkeynes@359
   756
                        { /* CMP/HI Rm, Rn */
nkeynes@359
   757
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   758
                        sh4r.t = ( sh4r.r[Rn] > sh4r.r[Rm] ? 1 : 0 );
nkeynes@359
   759
                        }
nkeynes@359
   760
                        break;
nkeynes@359
   761
                    case 0x7:
nkeynes@359
   762
                        { /* CMP/GT Rm, Rn */
nkeynes@359
   763
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   764
                        sh4r.t = ( ((int32_t)sh4r.r[Rn]) > ((int32_t)sh4r.r[Rm]) ? 1 : 0 );
nkeynes@359
   765
                        }
nkeynes@359
   766
                        break;
nkeynes@359
   767
                    case 0x8:
nkeynes@359
   768
                        { /* SUB Rm, Rn */
nkeynes@359
   769
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   770
                        sh4r.r[Rn] -= sh4r.r[Rm];
nkeynes@359
   771
                        }
nkeynes@359
   772
                        break;
nkeynes@359
   773
                    case 0xA:
nkeynes@359
   774
                        { /* SUBC Rm, Rn */
nkeynes@359
   775
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   776
                        tmp = sh4r.r[Rn];
nkeynes@359
   777
                        sh4r.r[Rn] = sh4r.r[Rn] - sh4r.r[Rm] - sh4r.t;
nkeynes@359
   778
                        sh4r.t = (sh4r.r[Rn] > tmp || (sh4r.r[Rn] == tmp && sh4r.t == 1));
nkeynes@359
   779
                        }
nkeynes@359
   780
                        break;
nkeynes@359
   781
                    case 0xB:
nkeynes@359
   782
                        UNIMP(ir); /* SUBV Rm, Rn */
nkeynes@359
   783
                        break;
nkeynes@359
   784
                    case 0xC:
nkeynes@359
   785
                        { /* ADD Rm, Rn */
nkeynes@359
   786
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   787
                        sh4r.r[Rn] += sh4r.r[Rm];
nkeynes@359
   788
                        }
nkeynes@359
   789
                        break;
nkeynes@359
   790
                    case 0xD:
nkeynes@359
   791
                        { /* DMULS.L Rm, Rn */
nkeynes@359
   792
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   793
                        sh4r.mac = SIGNEXT32(sh4r.r[Rm]) * SIGNEXT32(sh4r.r[Rn]);
nkeynes@359
   794
                        }
nkeynes@359
   795
                        break;
nkeynes@359
   796
                    case 0xE:
nkeynes@359
   797
                        { /* ADDC Rm, Rn */
nkeynes@359
   798
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   799
                        tmp = sh4r.r[Rn];
nkeynes@359
   800
                        sh4r.r[Rn] += sh4r.r[Rm] + sh4r.t;
nkeynes@359
   801
                        sh4r.t = ( sh4r.r[Rn] < tmp || (sh4r.r[Rn] == tmp && sh4r.t != 0) ? 1 : 0 );
nkeynes@359
   802
                        }
nkeynes@359
   803
                        break;
nkeynes@359
   804
                    case 0xF:
nkeynes@359
   805
                        { /* ADDV Rm, Rn */
nkeynes@359
   806
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
   807
                        tmp = sh4r.r[Rn] + sh4r.r[Rm];
nkeynes@359
   808
                        sh4r.t = ( (sh4r.r[Rn]>>31) == (sh4r.r[Rm]>>31) && ((sh4r.r[Rn]>>31) != (tmp>>31)) );
nkeynes@359
   809
                        sh4r.r[Rn] = tmp;
nkeynes@359
   810
                        }
nkeynes@359
   811
                        break;
nkeynes@359
   812
                    default:
nkeynes@359
   813
                        UNDEF();
nkeynes@359
   814
                        break;
nkeynes@359
   815
                }
nkeynes@359
   816
                break;
nkeynes@359
   817
            case 0x4:
nkeynes@359
   818
                switch( ir&0xF ) {
nkeynes@359
   819
                    case 0x0:
nkeynes@359
   820
                        switch( (ir&0xF0) >> 4 ) {
nkeynes@359
   821
                            case 0x0:
nkeynes@359
   822
                                { /* SHLL Rn */
nkeynes@359
   823
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   824
                                sh4r.t = sh4r.r[Rn] >> 31; sh4r.r[Rn] <<= 1;
nkeynes@359
   825
                                }
nkeynes@359
   826
                                break;
nkeynes@359
   827
                            case 0x1:
nkeynes@359
   828
                                { /* DT Rn */
nkeynes@359
   829
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   830
                                sh4r.r[Rn] --;
nkeynes@359
   831
                                sh4r.t = ( sh4r.r[Rn] == 0 ? 1 : 0 );
nkeynes@359
   832
                                }
nkeynes@359
   833
                                break;
nkeynes@359
   834
                            case 0x2:
nkeynes@359
   835
                                { /* SHAL Rn */
nkeynes@359
   836
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   837
                                sh4r.t = sh4r.r[Rn] >> 31;
nkeynes@359
   838
                                sh4r.r[Rn] <<= 1;
nkeynes@359
   839
                                }
nkeynes@359
   840
                                break;
nkeynes@359
   841
                            default:
nkeynes@359
   842
                                UNDEF();
nkeynes@359
   843
                                break;
nkeynes@359
   844
                        }
nkeynes@359
   845
                        break;
nkeynes@359
   846
                    case 0x1:
nkeynes@359
   847
                        switch( (ir&0xF0) >> 4 ) {
nkeynes@359
   848
                            case 0x0:
nkeynes@359
   849
                                { /* SHLR Rn */
nkeynes@359
   850
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   851
                                sh4r.t = sh4r.r[Rn] & 0x00000001; sh4r.r[Rn] >>= 1;
nkeynes@359
   852
                                }
nkeynes@359
   853
                                break;
nkeynes@359
   854
                            case 0x1:
nkeynes@359
   855
                                { /* CMP/PZ Rn */
nkeynes@359
   856
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   857
                                sh4r.t = ( ((int32_t)sh4r.r[Rn]) >= 0 ? 1 : 0 );
nkeynes@359
   858
                                }
nkeynes@359
   859
                                break;
nkeynes@359
   860
                            case 0x2:
nkeynes@359
   861
                                { /* SHAR Rn */
nkeynes@359
   862
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   863
                                sh4r.t = sh4r.r[Rn] & 0x00000001;
nkeynes@359
   864
                                sh4r.r[Rn] = ((int32_t)sh4r.r[Rn]) >> 1;
nkeynes@359
   865
                                }
nkeynes@359
   866
                                break;
nkeynes@359
   867
                            default:
nkeynes@359
   868
                                UNDEF();
nkeynes@359
   869
                                break;
nkeynes@359
   870
                        }
nkeynes@359
   871
                        break;
nkeynes@359
   872
                    case 0x2:
nkeynes@359
   873
                        switch( (ir&0xF0) >> 4 ) {
nkeynes@359
   874
                            case 0x0:
nkeynes@359
   875
                                { /* STS.L MACH, @-Rn */
nkeynes@359
   876
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   877
                                sh4r.r[Rn] -= 4;
nkeynes@359
   878
                                CHECKWALIGN32( sh4r.r[Rn] );
nkeynes@359
   879
                                MEM_WRITE_LONG( sh4r.r[Rn], (sh4r.mac>>32) );
nkeynes@359
   880
                                }
nkeynes@359
   881
                                break;
nkeynes@359
   882
                            case 0x1:
nkeynes@359
   883
                                { /* STS.L MACL, @-Rn */
nkeynes@359
   884
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   885
                                sh4r.r[Rn] -= 4;
nkeynes@359
   886
                                CHECKWALIGN32( sh4r.r[Rn] );
nkeynes@359
   887
                                MEM_WRITE_LONG( sh4r.r[Rn], (uint32_t)sh4r.mac );
nkeynes@359
   888
                                }
nkeynes@359
   889
                                break;
nkeynes@359
   890
                            case 0x2:
nkeynes@359
   891
                                { /* STS.L PR, @-Rn */
nkeynes@359
   892
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   893
                                sh4r.r[Rn] -= 4;
nkeynes@359
   894
                                CHECKWALIGN32( sh4r.r[Rn] );
nkeynes@359
   895
                                MEM_WRITE_LONG( sh4r.r[Rn], sh4r.pr );
nkeynes@359
   896
                                }
nkeynes@359
   897
                                break;
nkeynes@359
   898
                            case 0x3:
nkeynes@359
   899
                                { /* STC.L SGR, @-Rn */
nkeynes@359
   900
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   901
                                CHECKPRIV();
nkeynes@359
   902
                                sh4r.r[Rn] -= 4;
nkeynes@359
   903
                                CHECKWALIGN32( sh4r.r[Rn] );
nkeynes@359
   904
                                MEM_WRITE_LONG( sh4r.r[Rn], sh4r.sgr );
nkeynes@359
   905
                                }
nkeynes@359
   906
                                break;
nkeynes@359
   907
                            case 0x5:
nkeynes@359
   908
                                { /* STS.L FPUL, @-Rn */
nkeynes@359
   909
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   910
                                sh4r.r[Rn] -= 4;
nkeynes@359
   911
                                CHECKWALIGN32( sh4r.r[Rn] );
nkeynes@359
   912
                                MEM_WRITE_LONG( sh4r.r[Rn], sh4r.fpul );
nkeynes@359
   913
                                }
nkeynes@359
   914
                                break;
nkeynes@359
   915
                            case 0x6:
nkeynes@359
   916
                                { /* STS.L FPSCR, @-Rn */
nkeynes@359
   917
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   918
                                sh4r.r[Rn] -= 4;
nkeynes@359
   919
                                CHECKWALIGN32( sh4r.r[Rn] );
nkeynes@359
   920
                                MEM_WRITE_LONG( sh4r.r[Rn], sh4r.fpscr );
nkeynes@359
   921
                                }
nkeynes@359
   922
                                break;
nkeynes@359
   923
                            case 0xF:
nkeynes@359
   924
                                { /* STC.L DBR, @-Rn */
nkeynes@359
   925
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   926
                                CHECKPRIV();
nkeynes@359
   927
                                sh4r.r[Rn] -= 4;
nkeynes@359
   928
                                CHECKWALIGN32( sh4r.r[Rn] );
nkeynes@359
   929
                                MEM_WRITE_LONG( sh4r.r[Rn], sh4r.dbr );
nkeynes@359
   930
                                }
nkeynes@359
   931
                                break;
nkeynes@359
   932
                            default:
nkeynes@359
   933
                                UNDEF();
nkeynes@359
   934
                                break;
nkeynes@359
   935
                        }
nkeynes@359
   936
                        break;
nkeynes@359
   937
                    case 0x3:
nkeynes@359
   938
                        switch( (ir&0x80) >> 7 ) {
nkeynes@359
   939
                            case 0x0:
nkeynes@359
   940
                                switch( (ir&0x70) >> 4 ) {
nkeynes@359
   941
                                    case 0x0:
nkeynes@359
   942
                                        { /* STC.L SR, @-Rn */
nkeynes@359
   943
                                        uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   944
                                        CHECKPRIV();
nkeynes@359
   945
                                        sh4r.r[Rn] -= 4;
nkeynes@359
   946
                                        CHECKWALIGN32( sh4r.r[Rn] );
nkeynes@359
   947
                                        MEM_WRITE_LONG( sh4r.r[Rn], sh4_read_sr() );
nkeynes@359
   948
                                        }
nkeynes@359
   949
                                        break;
nkeynes@359
   950
                                    case 0x1:
nkeynes@359
   951
                                        { /* STC.L GBR, @-Rn */
nkeynes@359
   952
                                        uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   953
                                        sh4r.r[Rn] -= 4;
nkeynes@359
   954
                                        CHECKWALIGN32( sh4r.r[Rn] );
nkeynes@359
   955
                                        MEM_WRITE_LONG( sh4r.r[Rn], sh4r.gbr );
nkeynes@359
   956
                                        }
nkeynes@359
   957
                                        break;
nkeynes@359
   958
                                    case 0x2:
nkeynes@359
   959
                                        { /* STC.L VBR, @-Rn */
nkeynes@359
   960
                                        uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   961
                                        CHECKPRIV();
nkeynes@359
   962
                                        sh4r.r[Rn] -= 4;
nkeynes@359
   963
                                        CHECKWALIGN32( sh4r.r[Rn] );
nkeynes@359
   964
                                        MEM_WRITE_LONG( sh4r.r[Rn], sh4r.vbr );
nkeynes@359
   965
                                        }
nkeynes@359
   966
                                        break;
nkeynes@359
   967
                                    case 0x3:
nkeynes@359
   968
                                        { /* STC.L SSR, @-Rn */
nkeynes@359
   969
                                        uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   970
                                        CHECKPRIV();
nkeynes@359
   971
                                        sh4r.r[Rn] -= 4;
nkeynes@359
   972
                                        CHECKWALIGN32( sh4r.r[Rn] );
nkeynes@359
   973
                                        MEM_WRITE_LONG( sh4r.r[Rn], sh4r.ssr );
nkeynes@359
   974
                                        }
nkeynes@359
   975
                                        break;
nkeynes@359
   976
                                    case 0x4:
nkeynes@359
   977
                                        { /* STC.L SPC, @-Rn */
nkeynes@359
   978
                                        uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
   979
                                        CHECKPRIV();
nkeynes@359
   980
                                        sh4r.r[Rn] -= 4;
nkeynes@359
   981
                                        CHECKWALIGN32( sh4r.r[Rn] );
nkeynes@359
   982
                                        MEM_WRITE_LONG( sh4r.r[Rn], sh4r.spc );
nkeynes@359
   983
                                        }
nkeynes@359
   984
                                        break;
nkeynes@359
   985
                                    default:
nkeynes@359
   986
                                        UNDEF();
nkeynes@359
   987
                                        break;
nkeynes@359
   988
                                }
nkeynes@359
   989
                                break;
nkeynes@359
   990
                            case 0x1:
nkeynes@359
   991
                                { /* STC.L Rm_BANK, @-Rn */
nkeynes@359
   992
                                uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm_BANK = ((ir>>4)&0x7); 
nkeynes@359
   993
                                CHECKPRIV();
nkeynes@359
   994
                                sh4r.r[Rn] -= 4;
nkeynes@359
   995
                                CHECKWALIGN32( sh4r.r[Rn] );
nkeynes@359
   996
                                MEM_WRITE_LONG( sh4r.r[Rn], sh4r.r_bank[Rm_BANK] );
nkeynes@359
   997
                                }
nkeynes@359
   998
                                break;
nkeynes@359
   999
                        }
nkeynes@359
  1000
                        break;
nkeynes@359
  1001
                    case 0x4:
nkeynes@359
  1002
                        switch( (ir&0xF0) >> 4 ) {
nkeynes@359
  1003
                            case 0x0:
nkeynes@359
  1004
                                { /* ROTL Rn */
nkeynes@359
  1005
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
  1006
                                sh4r.t = sh4r.r[Rn] >> 31;
nkeynes@359
  1007
                                sh4r.r[Rn] <<= 1;
nkeynes@359
  1008
                                sh4r.r[Rn] |= sh4r.t;
nkeynes@359
  1009
                                }
nkeynes@359
  1010
                                break;
nkeynes@359
  1011
                            case 0x2:
nkeynes@359
  1012
                                { /* ROTCL Rn */
nkeynes@359
  1013
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
  1014
                                tmp = sh4r.r[Rn] >> 31;
nkeynes@359
  1015
                                sh4r.r[Rn] <<= 1;
nkeynes@359
  1016
                                sh4r.r[Rn] |= sh4r.t;
nkeynes@359
  1017
                                sh4r.t = tmp;
nkeynes@359
  1018
                                }
nkeynes@359
  1019
                                break;
nkeynes@359
  1020
                            default:
nkeynes@359
  1021
                                UNDEF();
nkeynes@359
  1022
                                break;
nkeynes@359
  1023
                        }
nkeynes@359
  1024
                        break;
nkeynes@359
  1025
                    case 0x5:
nkeynes@359
  1026
                        switch( (ir&0xF0) >> 4 ) {
nkeynes@359
  1027
                            case 0x0:
nkeynes@359
  1028
                                { /* ROTR Rn */
nkeynes@359
  1029
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
  1030
                                sh4r.t = sh4r.r[Rn] & 0x00000001;
nkeynes@359
  1031
                                sh4r.r[Rn] >>= 1;
nkeynes@359
  1032
                                sh4r.r[Rn] |= (sh4r.t << 31);
nkeynes@359
  1033
                                }
nkeynes@359
  1034
                                break;
nkeynes@359
  1035
                            case 0x1:
nkeynes@359
  1036
                                { /* CMP/PL Rn */
nkeynes@359
  1037
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
  1038
                                sh4r.t = ( ((int32_t)sh4r.r[Rn]) > 0 ? 1 : 0 );
nkeynes@359
  1039
                                }
nkeynes@359
  1040
                                break;
nkeynes@359
  1041
                            case 0x2:
nkeynes@359
  1042
                                { /* ROTCR Rn */
nkeynes@359
  1043
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
  1044
                                tmp = sh4r.r[Rn] & 0x00000001;
nkeynes@359
  1045
                                sh4r.r[Rn] >>= 1;
nkeynes@359
  1046
                                sh4r.r[Rn] |= (sh4r.t << 31 );
nkeynes@359
  1047
                                sh4r.t = tmp;
nkeynes@359
  1048
                                }
nkeynes@359
  1049
                                break;
nkeynes@359
  1050
                            default:
nkeynes@359
  1051
                                UNDEF();
nkeynes@359
  1052
                                break;
nkeynes@359
  1053
                        }
nkeynes@359
  1054
                        break;
nkeynes@359
  1055
                    case 0x6:
nkeynes@359
  1056
                        switch( (ir&0xF0) >> 4 ) {
nkeynes@359
  1057
                            case 0x0:
nkeynes@359
  1058
                                { /* LDS.L @Rm+, MACH */
nkeynes@359
  1059
                                uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1060
                                CHECKRALIGN32( sh4r.r[Rm] );
nkeynes@359
  1061
                                sh4r.mac = (sh4r.mac & 0x00000000FFFFFFFF) |
nkeynes@359
  1062
                                           (((uint64_t)MEM_READ_LONG(sh4r.r[Rm]))<<32);
nkeynes@359
  1063
                                sh4r.r[Rm] += 4;
nkeynes@359
  1064
                                }
nkeynes@359
  1065
                                break;
nkeynes@359
  1066
                            case 0x1:
nkeynes@359
  1067
                                { /* LDS.L @Rm+, MACL */
nkeynes@359
  1068
                                uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1069
                                CHECKRALIGN32( sh4r.r[Rm] );
nkeynes@359
  1070
                                sh4r.mac = (sh4r.mac & 0xFFFFFFFF00000000LL) |
nkeynes@359
  1071
                                           (uint64_t)((uint32_t)MEM_READ_LONG(sh4r.r[Rm]));
nkeynes@359
  1072
                                sh4r.r[Rm] += 4;
nkeynes@359
  1073
                                }
nkeynes@359
  1074
                                break;
nkeynes@359
  1075
                            case 0x2:
nkeynes@359
  1076
                                { /* LDS.L @Rm+, PR */
nkeynes@359
  1077
                                uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1078
                                CHECKRALIGN32( sh4r.r[Rm] );
nkeynes@359
  1079
                                sh4r.pr = MEM_READ_LONG( sh4r.r[Rm] );
nkeynes@359
  1080
                                sh4r.r[Rm] += 4;
nkeynes@359
  1081
                                }
nkeynes@359
  1082
                                break;
nkeynes@359
  1083
                            case 0x3:
nkeynes@359
  1084
                                { /* LDC.L @Rm+, SGR */
nkeynes@359
  1085
                                uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1086
                                CHECKPRIV();
nkeynes@359
  1087
                                CHECKRALIGN32( sh4r.r[Rm] );
nkeynes@359
  1088
                                sh4r.sgr = MEM_READ_LONG(sh4r.r[Rm]);
nkeynes@359
  1089
                                sh4r.r[Rm] +=4;
nkeynes@359
  1090
                                }
nkeynes@359
  1091
                                break;
nkeynes@359
  1092
                            case 0x5:
nkeynes@359
  1093
                                { /* LDS.L @Rm+, FPUL */
nkeynes@359
  1094
                                uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1095
                                CHECKRALIGN32( sh4r.r[Rm] );
nkeynes@359
  1096
                                sh4r.fpul = MEM_READ_LONG(sh4r.r[Rm]);
nkeynes@359
  1097
                                sh4r.r[Rm] +=4;
nkeynes@359
  1098
                                }
nkeynes@359
  1099
                                break;
nkeynes@359
  1100
                            case 0x6:
nkeynes@359
  1101
                                { /* LDS.L @Rm+, FPSCR */
nkeynes@359
  1102
                                uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1103
                                CHECKRALIGN32( sh4r.r[Rm] );
nkeynes@359
  1104
                                sh4r.fpscr = MEM_READ_LONG(sh4r.r[Rm]);
nkeynes@359
  1105
                                sh4r.r[Rm] +=4;
nkeynes@374
  1106
                                sh4r.fr_bank = &sh4r.fr[(sh4r.fpscr&FPSCR_FR)>>21][0];
nkeynes@359
  1107
                                }
nkeynes@359
  1108
                                break;
nkeynes@359
  1109
                            case 0xF:
nkeynes@359
  1110
                                { /* LDC.L @Rm+, DBR */
nkeynes@359
  1111
                                uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1112
                                CHECKPRIV();
nkeynes@359
  1113
                                CHECKRALIGN32( sh4r.r[Rm] );
nkeynes@359
  1114
                                sh4r.dbr = MEM_READ_LONG(sh4r.r[Rm]);
nkeynes@359
  1115
                                sh4r.r[Rm] +=4;
nkeynes@359
  1116
                                }
nkeynes@359
  1117
                                break;
nkeynes@359
  1118
                            default:
nkeynes@359
  1119
                                UNDEF();
nkeynes@359
  1120
                                break;
nkeynes@359
  1121
                        }
nkeynes@359
  1122
                        break;
nkeynes@359
  1123
                    case 0x7:
nkeynes@359
  1124
                        switch( (ir&0x80) >> 7 ) {
nkeynes@359
  1125
                            case 0x0:
nkeynes@359
  1126
                                switch( (ir&0x70) >> 4 ) {
nkeynes@359
  1127
                                    case 0x0:
nkeynes@359
  1128
                                        { /* LDC.L @Rm+, SR */
nkeynes@359
  1129
                                        uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1130
                                        CHECKSLOTILLEGAL();
nkeynes@359
  1131
                                        CHECKPRIV();
nkeynes@359
  1132
                                        CHECKWALIGN32( sh4r.r[Rm] );
nkeynes@374
  1133
                                        sh4_write_sr( MEM_READ_LONG(sh4r.r[Rm]) );
nkeynes@359
  1134
                                        sh4r.r[Rm] +=4;
nkeynes@359
  1135
                                        }
nkeynes@359
  1136
                                        break;
nkeynes@359
  1137
                                    case 0x1:
nkeynes@359
  1138
                                        { /* LDC.L @Rm+, GBR */
nkeynes@359
  1139
                                        uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1140
                                        CHECKRALIGN32( sh4r.r[Rm] );
nkeynes@359
  1141
                                        sh4r.gbr = MEM_READ_LONG(sh4r.r[Rm]);
nkeynes@359
  1142
                                        sh4r.r[Rm] +=4;
nkeynes@359
  1143
                                        }
nkeynes@359
  1144
                                        break;
nkeynes@359
  1145
                                    case 0x2:
nkeynes@359
  1146
                                        { /* LDC.L @Rm+, VBR */
nkeynes@359
  1147
                                        uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1148
                                        CHECKPRIV();
nkeynes@359
  1149
                                        CHECKRALIGN32( sh4r.r[Rm] );
nkeynes@359
  1150
                                        sh4r.vbr = MEM_READ_LONG(sh4r.r[Rm]);
nkeynes@359
  1151
                                        sh4r.r[Rm] +=4;
nkeynes@359
  1152
                                        }
nkeynes@359
  1153
                                        break;
nkeynes@359
  1154
                                    case 0x3:
nkeynes@359
  1155
                                        { /* LDC.L @Rm+, SSR */
nkeynes@359
  1156
                                        uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1157
                                        CHECKPRIV();
nkeynes@359
  1158
                                        CHECKRALIGN32( sh4r.r[Rm] );
nkeynes@359
  1159
                                        sh4r.ssr = MEM_READ_LONG(sh4r.r[Rm]);
nkeynes@359
  1160
                                        sh4r.r[Rm] +=4;
nkeynes@359
  1161
                                        }
nkeynes@359
  1162
                                        break;
nkeynes@359
  1163
                                    case 0x4:
nkeynes@359
  1164
                                        { /* LDC.L @Rm+, SPC */
nkeynes@359
  1165
                                        uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1166
                                        CHECKPRIV();
nkeynes@359
  1167
                                        CHECKRALIGN32( sh4r.r[Rm] );
nkeynes@359
  1168
                                        sh4r.spc = MEM_READ_LONG(sh4r.r[Rm]);
nkeynes@359
  1169
                                        sh4r.r[Rm] +=4;
nkeynes@359
  1170
                                        }
nkeynes@359
  1171
                                        break;
nkeynes@359
  1172
                                    default:
nkeynes@359
  1173
                                        UNDEF();
nkeynes@359
  1174
                                        break;
nkeynes@359
  1175
                                }
nkeynes@359
  1176
                                break;
nkeynes@359
  1177
                            case 0x1:
nkeynes@359
  1178
                                { /* LDC.L @Rm+, Rn_BANK */
nkeynes@359
  1179
                                uint32_t Rm = ((ir>>8)&0xF); uint32_t Rn_BANK = ((ir>>4)&0x7); 
nkeynes@359
  1180
                                CHECKPRIV();
nkeynes@359
  1181
                                CHECKRALIGN32( sh4r.r[Rm] );
nkeynes@359
  1182
                                sh4r.r_bank[Rn_BANK] = MEM_READ_LONG( sh4r.r[Rm] );
nkeynes@359
  1183
                                sh4r.r[Rm] += 4;
nkeynes@359
  1184
                                }
nkeynes@359
  1185
                                break;
nkeynes@359
  1186
                        }
nkeynes@359
  1187
                        break;
nkeynes@359
  1188
                    case 0x8:
nkeynes@359
  1189
                        switch( (ir&0xF0) >> 4 ) {
nkeynes@359
  1190
                            case 0x0:
nkeynes@359
  1191
                                { /* SHLL2 Rn */
nkeynes@359
  1192
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
  1193
                                sh4r.r[Rn] <<= 2;
nkeynes@359
  1194
                                }
nkeynes@359
  1195
                                break;
nkeynes@359
  1196
                            case 0x1:
nkeynes@359
  1197
                                { /* SHLL8 Rn */
nkeynes@359
  1198
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
  1199
                                sh4r.r[Rn] <<= 8;
nkeynes@359
  1200
                                }
nkeynes@359
  1201
                                break;
nkeynes@359
  1202
                            case 0x2:
nkeynes@359
  1203
                                { /* SHLL16 Rn */
nkeynes@359
  1204
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
  1205
                                sh4r.r[Rn] <<= 16;
nkeynes@359
  1206
                                }
nkeynes@359
  1207
                                break;
nkeynes@359
  1208
                            default:
nkeynes@359
  1209
                                UNDEF();
nkeynes@359
  1210
                                break;
nkeynes@359
  1211
                        }
nkeynes@359
  1212
                        break;
nkeynes@359
  1213
                    case 0x9:
nkeynes@359
  1214
                        switch( (ir&0xF0) >> 4 ) {
nkeynes@359
  1215
                            case 0x0:
nkeynes@359
  1216
                                { /* SHLR2 Rn */
nkeynes@359
  1217
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
  1218
                                sh4r.r[Rn] >>= 2;
nkeynes@359
  1219
                                }
nkeynes@359
  1220
                                break;
nkeynes@359
  1221
                            case 0x1:
nkeynes@359
  1222
                                { /* SHLR8 Rn */
nkeynes@359
  1223
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
  1224
                                sh4r.r[Rn] >>= 8;
nkeynes@359
  1225
                                }
nkeynes@359
  1226
                                break;
nkeynes@359
  1227
                            case 0x2:
nkeynes@359
  1228
                                { /* SHLR16 Rn */
nkeynes@359
  1229
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
  1230
                                sh4r.r[Rn] >>= 16;
nkeynes@359
  1231
                                }
nkeynes@359
  1232
                                break;
nkeynes@359
  1233
                            default:
nkeynes@359
  1234
                                UNDEF();
nkeynes@359
  1235
                                break;
nkeynes@359
  1236
                        }
nkeynes@359
  1237
                        break;
nkeynes@359
  1238
                    case 0xA:
nkeynes@359
  1239
                        switch( (ir&0xF0) >> 4 ) {
nkeynes@359
  1240
                            case 0x0:
nkeynes@359
  1241
                                { /* LDS Rm, MACH */
nkeynes@359
  1242
                                uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1243
                                sh4r.mac = (sh4r.mac & 0x00000000FFFFFFFF) |
nkeynes@359
  1244
                                           (((uint64_t)sh4r.r[Rm])<<32);
nkeynes@359
  1245
                                }
nkeynes@359
  1246
                                break;
nkeynes@359
  1247
                            case 0x1:
nkeynes@359
  1248
                                { /* LDS Rm, MACL */
nkeynes@359
  1249
                                uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1250
                                sh4r.mac = (sh4r.mac & 0xFFFFFFFF00000000LL) |
nkeynes@359
  1251
                                           (uint64_t)((uint32_t)(sh4r.r[Rm]));
nkeynes@359
  1252
                                }
nkeynes@359
  1253
                                break;
nkeynes@359
  1254
                            case 0x2:
nkeynes@359
  1255
                                { /* LDS Rm, PR */
nkeynes@359
  1256
                                uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1257
                                sh4r.pr = sh4r.r[Rm];
nkeynes@359
  1258
                                }
nkeynes@359
  1259
                                break;
nkeynes@359
  1260
                            case 0x3:
nkeynes@359
  1261
                                { /* LDC Rm, SGR */
nkeynes@359
  1262
                                uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1263
                                CHECKPRIV();
nkeynes@359
  1264
                                sh4r.sgr = sh4r.r[Rm];
nkeynes@359
  1265
                                }
nkeynes@359
  1266
                                break;
nkeynes@359
  1267
                            case 0x5:
nkeynes@359
  1268
                                { /* LDS Rm, FPUL */
nkeynes@359
  1269
                                uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1270
                                sh4r.fpul = sh4r.r[Rm];
nkeynes@359
  1271
                                }
nkeynes@359
  1272
                                break;
nkeynes@359
  1273
                            case 0x6:
nkeynes@359
  1274
                                { /* LDS Rm, FPSCR */
nkeynes@359
  1275
                                uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@374
  1276
                                sh4r.fpscr = sh4r.r[Rm]; 
nkeynes@374
  1277
                                sh4r.fr_bank = &sh4r.fr[(sh4r.fpscr&FPSCR_FR)>>21][0];
nkeynes@359
  1278
                                }
nkeynes@359
  1279
                                break;
nkeynes@359
  1280
                            case 0xF:
nkeynes@359
  1281
                                { /* LDC Rm, DBR */
nkeynes@359
  1282
                                uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1283
                                CHECKPRIV();
nkeynes@359
  1284
                                sh4r.dbr = sh4r.r[Rm];
nkeynes@359
  1285
                                }
nkeynes@359
  1286
                                break;
nkeynes@359
  1287
                            default:
nkeynes@359
  1288
                                UNDEF();
nkeynes@359
  1289
                                break;
nkeynes@359
  1290
                        }
nkeynes@359
  1291
                        break;
nkeynes@359
  1292
                    case 0xB:
nkeynes@359
  1293
                        switch( (ir&0xF0) >> 4 ) {
nkeynes@359
  1294
                            case 0x0:
nkeynes@359
  1295
                                { /* JSR @Rn */
nkeynes@359
  1296
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
  1297
                                CHECKDEST( sh4r.r[Rn] );
nkeynes@359
  1298
                                CHECKSLOTILLEGAL();
nkeynes@359
  1299
                                sh4r.in_delay_slot = 1;
nkeynes@359
  1300
                                sh4r.pc = sh4r.new_pc;
nkeynes@359
  1301
                                sh4r.new_pc = sh4r.r[Rn];
nkeynes@359
  1302
                                sh4r.pr = pc + 4;
nkeynes@359
  1303
                                TRACE_CALL( pc, sh4r.new_pc );
nkeynes@359
  1304
                                return TRUE;
nkeynes@359
  1305
                                }
nkeynes@359
  1306
                                break;
nkeynes@359
  1307
                            case 0x1:
nkeynes@359
  1308
                                { /* TAS.B @Rn */
nkeynes@359
  1309
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
  1310
                                tmp = MEM_READ_BYTE( sh4r.r[Rn] );
nkeynes@359
  1311
                                sh4r.t = ( tmp == 0 ? 1 : 0 );
nkeynes@359
  1312
                                MEM_WRITE_BYTE( sh4r.r[Rn], tmp | 0x80 );
nkeynes@359
  1313
                                }
nkeynes@359
  1314
                                break;
nkeynes@359
  1315
                            case 0x2:
nkeynes@359
  1316
                                { /* JMP @Rn */
nkeynes@359
  1317
                                uint32_t Rn = ((ir>>8)&0xF); 
nkeynes@359
  1318
                                CHECKDEST( sh4r.r[Rn] );
nkeynes@359
  1319
                                CHECKSLOTILLEGAL();
nkeynes@359
  1320
                                sh4r.in_delay_slot = 1;
nkeynes@359
  1321
                                sh4r.pc = sh4r.new_pc;
nkeynes@359
  1322
                                sh4r.new_pc = sh4r.r[Rn];
nkeynes@359
  1323
                                return TRUE;
nkeynes@359
  1324
                                }
nkeynes@359
  1325
                                break;
nkeynes@359
  1326
                            default:
nkeynes@359
  1327
                                UNDEF();
nkeynes@359
  1328
                                break;
nkeynes@359
  1329
                        }
nkeynes@359
  1330
                        break;
nkeynes@359
  1331
                    case 0xC:
nkeynes@359
  1332
                        { /* SHAD Rm, Rn */
nkeynes@359
  1333
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1334
                        tmp = sh4r.r[Rm];
nkeynes@359
  1335
                        if( (tmp & 0x80000000) == 0 ) sh4r.r[Rn] <<= (tmp&0x1f);
nkeynes@359
  1336
                        else if( (tmp & 0x1F) == 0 )  
nkeynes@359
  1337
                            sh4r.r[Rn] = ((int32_t)sh4r.r[Rn]) >> 31;
nkeynes@359
  1338
                        else 
nkeynes@359
  1339
                    	sh4r.r[Rn] = ((int32_t)sh4r.r[Rn]) >> (((~sh4r.r[Rm]) & 0x1F)+1);
nkeynes@359
  1340
                        }
nkeynes@359
  1341
                        break;
nkeynes@359
  1342
                    case 0xD:
nkeynes@359
  1343
                        { /* SHLD Rm, Rn */
nkeynes@359
  1344
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1345
                        tmp = sh4r.r[Rm];
nkeynes@359
  1346
                        if( (tmp & 0x80000000) == 0 ) sh4r.r[Rn] <<= (tmp&0x1f);
nkeynes@359
  1347
                        else if( (tmp & 0x1F) == 0 ) sh4r.r[Rn] = 0;
nkeynes@359
  1348
                        else sh4r.r[Rn] >>= (((~tmp) & 0x1F)+1);
nkeynes@359
  1349
                        }
nkeynes@359
  1350
                        break;
nkeynes@359
  1351
                    case 0xE:
nkeynes@359
  1352
                        switch( (ir&0x80) >> 7 ) {
nkeynes@359
  1353
                            case 0x0:
nkeynes@359
  1354
                                switch( (ir&0x70) >> 4 ) {
nkeynes@359
  1355
                                    case 0x0:
nkeynes@359
  1356
                                        { /* LDC Rm, SR */
nkeynes@359
  1357
                                        uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1358
                                        CHECKSLOTILLEGAL();
nkeynes@359
  1359
                                        CHECKPRIV();
nkeynes@374
  1360
                                        sh4_write_sr( sh4r.r[Rm] );
nkeynes@359
  1361
                                        }
nkeynes@359
  1362
                                        break;
nkeynes@359
  1363
                                    case 0x1:
nkeynes@359
  1364
                                        { /* LDC Rm, GBR */
nkeynes@359
  1365
                                        uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1366
                                        sh4r.gbr = sh4r.r[Rm];
nkeynes@359
  1367
                                        }
nkeynes@359
  1368
                                        break;
nkeynes@359
  1369
                                    case 0x2:
nkeynes@359
  1370
                                        { /* LDC Rm, VBR */
nkeynes@359
  1371
                                        uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1372
                                        CHECKPRIV();
nkeynes@359
  1373
                                        sh4r.vbr = sh4r.r[Rm];
nkeynes@359
  1374
                                        }
nkeynes@359
  1375
                                        break;
nkeynes@359
  1376
                                    case 0x3:
nkeynes@359
  1377
                                        { /* LDC Rm, SSR */
nkeynes@359
  1378
                                        uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1379
                                        CHECKPRIV();
nkeynes@359
  1380
                                        sh4r.ssr = sh4r.r[Rm];
nkeynes@359
  1381
                                        }
nkeynes@359
  1382
                                        break;
nkeynes@359
  1383
                                    case 0x4:
nkeynes@359
  1384
                                        { /* LDC Rm, SPC */
nkeynes@359
  1385
                                        uint32_t Rm = ((ir>>8)&0xF); 
nkeynes@359
  1386
                                        CHECKPRIV();
nkeynes@359
  1387
                                        sh4r.spc = sh4r.r[Rm];
nkeynes@359
  1388
                                        }
nkeynes@359
  1389
                                        break;
nkeynes@359
  1390
                                    default:
nkeynes@359
  1391
                                        UNDEF();
nkeynes@359
  1392
                                        break;
nkeynes@359
  1393
                                }
nkeynes@359
  1394
                                break;
nkeynes@359
  1395
                            case 0x1:
nkeynes@359
  1396
                                { /* LDC Rm, Rn_BANK */
nkeynes@359
  1397
                                uint32_t Rm = ((ir>>8)&0xF); uint32_t Rn_BANK = ((ir>>4)&0x7); 
nkeynes@359
  1398
                                CHECKPRIV();
nkeynes@359
  1399
                                sh4r.r_bank[Rn_BANK] = sh4r.r[Rm];
nkeynes@359
  1400
                                }
nkeynes@359
  1401
                                break;
nkeynes@359
  1402
                        }
nkeynes@359
  1403
                        break;
nkeynes@359
  1404
                    case 0xF:
nkeynes@359
  1405
                        { /* MAC.W @Rm+, @Rn+ */
nkeynes@359
  1406
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1407
                        CHECKRALIGN16( sh4r.r[Rn] );
nkeynes@359
  1408
                        CHECKRALIGN16( sh4r.r[Rm] );
nkeynes@359
  1409
                        int32_t stmp = SIGNEXT16(MEM_READ_WORD(sh4r.r[Rn]));
nkeynes@359
  1410
                        sh4r.r[Rn] += 2;
nkeynes@359
  1411
                        stmp = stmp * SIGNEXT16(MEM_READ_WORD(sh4r.r[Rm]));
nkeynes@359
  1412
                        sh4r.r[Rm] += 2;
nkeynes@359
  1413
                        if( sh4r.s ) {
nkeynes@359
  1414
                    	int64_t tmpl = (int64_t)((int32_t)sh4r.mac) + (int64_t)stmp;
nkeynes@359
  1415
                    	if( tmpl > (int64_t)0x000000007FFFFFFFLL ) {
nkeynes@359
  1416
                    	    sh4r.mac = 0x000000017FFFFFFFLL;
nkeynes@359
  1417
                    	} else if( tmpl < (int64_t)0xFFFFFFFF80000000LL ) {
nkeynes@359
  1418
                    	    sh4r.mac = 0x0000000180000000LL;
nkeynes@359
  1419
                    	} else {
nkeynes@359
  1420
                    	    sh4r.mac = (sh4r.mac & 0xFFFFFFFF00000000LL) |
nkeynes@359
  1421
                    		((uint32_t)(sh4r.mac + stmp));
nkeynes@359
  1422
                    	}
nkeynes@359
  1423
                        } else {
nkeynes@359
  1424
                    	sh4r.mac += SIGNEXT32(stmp);
nkeynes@359
  1425
                        }
nkeynes@359
  1426
                        }
nkeynes@359
  1427
                        break;
nkeynes@359
  1428
                }
nkeynes@359
  1429
                break;
nkeynes@359
  1430
            case 0x5:
nkeynes@359
  1431
                { /* MOV.L @(disp, Rm), Rn */
nkeynes@359
  1432
                uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); uint32_t disp = (ir&0xF)<<2; 
nkeynes@359
  1433
                tmp = sh4r.r[Rm] + disp;
nkeynes@359
  1434
                CHECKRALIGN32( tmp );
nkeynes@359
  1435
                sh4r.r[Rn] = MEM_READ_LONG( tmp );
nkeynes@359
  1436
                }
nkeynes@359
  1437
                break;
nkeynes@359
  1438
            case 0x6:
nkeynes@359
  1439
                switch( ir&0xF ) {
nkeynes@359
  1440
                    case 0x0:
nkeynes@359
  1441
                        { /* MOV.B @Rm, Rn */
nkeynes@359
  1442
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1443
                        sh4r.r[Rn] = MEM_READ_BYTE( sh4r.r[Rm] );
nkeynes@359
  1444
                        }
nkeynes@359
  1445
                        break;
nkeynes@359
  1446
                    case 0x1:
nkeynes@359
  1447
                        { /* MOV.W @Rm, Rn */
nkeynes@359
  1448
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1449
                        CHECKRALIGN16( sh4r.r[Rm] ); sh4r.r[Rn] = MEM_READ_WORD( sh4r.r[Rm] );
nkeynes@359
  1450
                        }
nkeynes@359
  1451
                        break;
nkeynes@359
  1452
                    case 0x2:
nkeynes@359
  1453
                        { /* MOV.L @Rm, Rn */
nkeynes@359
  1454
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1455
                        CHECKRALIGN32( sh4r.r[Rm] ); sh4r.r[Rn] = MEM_READ_LONG( sh4r.r[Rm] );
nkeynes@359
  1456
                        }
nkeynes@359
  1457
                        break;
nkeynes@359
  1458
                    case 0x3:
nkeynes@359
  1459
                        { /* MOV Rm, Rn */
nkeynes@359
  1460
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1461
                        sh4r.r[Rn] = sh4r.r[Rm];
nkeynes@359
  1462
                        }
nkeynes@359
  1463
                        break;
nkeynes@359
  1464
                    case 0x4:
nkeynes@359
  1465
                        { /* MOV.B @Rm+, Rn */
nkeynes@359
  1466
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1467
                        sh4r.r[Rn] = MEM_READ_BYTE( sh4r.r[Rm] ); sh4r.r[Rm] ++;
nkeynes@359
  1468
                        }
nkeynes@359
  1469
                        break;
nkeynes@359
  1470
                    case 0x5:
nkeynes@359
  1471
                        { /* MOV.W @Rm+, Rn */
nkeynes@359
  1472
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1473
                        CHECKRALIGN16( sh4r.r[Rm] ); sh4r.r[Rn] = MEM_READ_WORD( sh4r.r[Rm] ); sh4r.r[Rm] += 2;
nkeynes@359
  1474
                        }
nkeynes@359
  1475
                        break;
nkeynes@359
  1476
                    case 0x6:
nkeynes@359
  1477
                        { /* MOV.L @Rm+, Rn */
nkeynes@359
  1478
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1479
                        CHECKRALIGN32( sh4r.r[Rm] ); sh4r.r[Rn] = MEM_READ_LONG( sh4r.r[Rm] ); sh4r.r[Rm] += 4;
nkeynes@359
  1480
                        }
nkeynes@359
  1481
                        break;
nkeynes@359
  1482
                    case 0x7:
nkeynes@359
  1483
                        { /* NOT Rm, Rn */
nkeynes@359
  1484
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1485
                        sh4r.r[Rn] = ~sh4r.r[Rm];
nkeynes@359
  1486
                        }
nkeynes@359
  1487
                        break;
nkeynes@359
  1488
                    case 0x8:
nkeynes@359
  1489
                        { /* SWAP.B Rm, Rn */
nkeynes@359
  1490
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1491
                        sh4r.r[Rn] = (sh4r.r[Rm]&0xFFFF0000) | ((sh4r.r[Rm]&0x0000FF00)>>8) | ((sh4r.r[Rm]&0x000000FF)<<8);
nkeynes@359
  1492
                        }
nkeynes@359
  1493
                        break;
nkeynes@359
  1494
                    case 0x9:
nkeynes@359
  1495
                        { /* SWAP.W Rm, Rn */
nkeynes@359
  1496
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1497
                        sh4r.r[Rn] = (sh4r.r[Rm]>>16) | (sh4r.r[Rm]<<16);
nkeynes@359
  1498
                        }
nkeynes@359
  1499
                        break;
nkeynes@359
  1500
                    case 0xA:
nkeynes@359
  1501
                        { /* NEGC Rm, Rn */
nkeynes@359
  1502
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1503
                        tmp = 0 - sh4r.r[Rm];
nkeynes@359
  1504
                        sh4r.r[Rn] = tmp - sh4r.t;
nkeynes@359
  1505
                        sh4r.t = ( 0<tmp || tmp<sh4r.r[Rn] ? 1 : 0 );
nkeynes@359
  1506
                        }
nkeynes@359
  1507
                        break;
nkeynes@359
  1508
                    case 0xB:
nkeynes@359
  1509
                        { /* NEG Rm, Rn */
nkeynes@359
  1510
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1511
                        sh4r.r[Rn] = 0 - sh4r.r[Rm];
nkeynes@359
  1512
                        }
nkeynes@359
  1513
                        break;
nkeynes@359
  1514
                    case 0xC:
nkeynes@359
  1515
                        { /* EXTU.B Rm, Rn */
nkeynes@359
  1516
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1517
                        sh4r.r[Rn] = sh4r.r[Rm]&0x000000FF;
nkeynes@359
  1518
                        }
nkeynes@359
  1519
                        break;
nkeynes@359
  1520
                    case 0xD:
nkeynes@359
  1521
                        { /* EXTU.W Rm, Rn */
nkeynes@359
  1522
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1523
                        sh4r.r[Rn] = sh4r.r[Rm]&0x0000FFFF;
nkeynes@359
  1524
                        }
nkeynes@359
  1525
                        break;
nkeynes@359
  1526
                    case 0xE:
nkeynes@359
  1527
                        { /* EXTS.B Rm, Rn */
nkeynes@359
  1528
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1529
                        sh4r.r[Rn] = SIGNEXT8( sh4r.r[Rm]&0x000000FF );
nkeynes@359
  1530
                        }
nkeynes@359
  1531
                        break;
nkeynes@359
  1532
                    case 0xF:
nkeynes@359
  1533
                        { /* EXTS.W Rm, Rn */
nkeynes@359
  1534
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1535
                        sh4r.r[Rn] = SIGNEXT16( sh4r.r[Rm]&0x0000FFFF );
nkeynes@359
  1536
                        }
nkeynes@359
  1537
                        break;
nkeynes@359
  1538
                }
nkeynes@359
  1539
                break;
nkeynes@359
  1540
            case 0x7:
nkeynes@359
  1541
                { /* ADD #imm, Rn */
nkeynes@359
  1542
                uint32_t Rn = ((ir>>8)&0xF); int32_t imm = SIGNEXT8(ir&0xFF); 
nkeynes@359
  1543
                sh4r.r[Rn] += imm;
nkeynes@359
  1544
                }
nkeynes@359
  1545
                break;
nkeynes@359
  1546
            case 0x8:
nkeynes@359
  1547
                switch( (ir&0xF00) >> 8 ) {
nkeynes@359
  1548
                    case 0x0:
nkeynes@359
  1549
                        { /* MOV.B R0, @(disp, Rn) */
nkeynes@359
  1550
                        uint32_t Rn = ((ir>>4)&0xF); uint32_t disp = (ir&0xF); 
nkeynes@359
  1551
                        MEM_WRITE_BYTE( sh4r.r[Rn] + disp, R0 );
nkeynes@359
  1552
                        }
nkeynes@359
  1553
                        break;
nkeynes@359
  1554
                    case 0x1:
nkeynes@359
  1555
                        { /* MOV.W R0, @(disp, Rn) */
nkeynes@359
  1556
                        uint32_t Rn = ((ir>>4)&0xF); uint32_t disp = (ir&0xF)<<1; 
nkeynes@359
  1557
                        tmp = sh4r.r[Rn] + disp;
nkeynes@359
  1558
                        CHECKWALIGN16( tmp );
nkeynes@359
  1559
                        MEM_WRITE_WORD( tmp, R0 );
nkeynes@359
  1560
                        }
nkeynes@359
  1561
                        break;
nkeynes@359
  1562
                    case 0x4:
nkeynes@359
  1563
                        { /* MOV.B @(disp, Rm), R0 */
nkeynes@359
  1564
                        uint32_t Rm = ((ir>>4)&0xF); uint32_t disp = (ir&0xF); 
nkeynes@359
  1565
                        R0 = MEM_READ_BYTE( sh4r.r[Rm] + disp );
nkeynes@359
  1566
                        }
nkeynes@359
  1567
                        break;
nkeynes@359
  1568
                    case 0x5:
nkeynes@359
  1569
                        { /* MOV.W @(disp, Rm), R0 */
nkeynes@359
  1570
                        uint32_t Rm = ((ir>>4)&0xF); uint32_t disp = (ir&0xF)<<1; 
nkeynes@359
  1571
                        tmp = sh4r.r[Rm] + disp;
nkeynes@359
  1572
                        CHECKRALIGN16( tmp );
nkeynes@359
  1573
                        R0 = MEM_READ_WORD( tmp );
nkeynes@359
  1574
                        }
nkeynes@359
  1575
                        break;
nkeynes@359
  1576
                    case 0x8:
nkeynes@359
  1577
                        { /* CMP/EQ #imm, R0 */
nkeynes@359
  1578
                        int32_t imm = SIGNEXT8(ir&0xFF); 
nkeynes@359
  1579
                        sh4r.t = ( R0 == imm ? 1 : 0 );
nkeynes@359
  1580
                        }
nkeynes@359
  1581
                        break;
nkeynes@359
  1582
                    case 0x9:
nkeynes@359
  1583
                        { /* BT disp */
nkeynes@359
  1584
                        int32_t disp = SIGNEXT8(ir&0xFF)<<1; 
nkeynes@359
  1585
                        CHECKSLOTILLEGAL();
nkeynes@359
  1586
                        if( sh4r.t ) {
nkeynes@359
  1587
                            CHECKDEST( sh4r.pc + disp + 4 )
nkeynes@359
  1588
                            sh4r.pc += disp + 4;
nkeynes@359
  1589
                            sh4r.new_pc = sh4r.pc + 2;
nkeynes@27
  1590
                            return TRUE;
nkeynes@359
  1591
                        }
nkeynes@359
  1592
                        }
nkeynes@359
  1593
                        break;
nkeynes@359
  1594
                    case 0xB:
nkeynes@359
  1595
                        { /* BF disp */
nkeynes@359
  1596
                        int32_t disp = SIGNEXT8(ir&0xFF)<<1; 
nkeynes@359
  1597
                        CHECKSLOTILLEGAL();
nkeynes@359
  1598
                        if( !sh4r.t ) {
nkeynes@359
  1599
                            CHECKDEST( sh4r.pc + disp + 4 )
nkeynes@359
  1600
                            sh4r.pc += disp + 4;
nkeynes@359
  1601
                            sh4r.new_pc = sh4r.pc + 2;
nkeynes@359
  1602
                            return TRUE;
nkeynes@359
  1603
                        }
nkeynes@359
  1604
                        }
nkeynes@359
  1605
                        break;
nkeynes@359
  1606
                    case 0xD:
nkeynes@359
  1607
                        { /* BT/S disp */
nkeynes@359
  1608
                        int32_t disp = SIGNEXT8(ir&0xFF)<<1; 
nkeynes@359
  1609
                        CHECKSLOTILLEGAL();
nkeynes@359
  1610
                        if( sh4r.t ) {
nkeynes@359
  1611
                            CHECKDEST( sh4r.pc + disp + 4 )
nkeynes@2
  1612
                            sh4r.in_delay_slot = 1;
nkeynes@1
  1613
                            sh4r.pc = sh4r.new_pc;
nkeynes@359
  1614
                            sh4r.new_pc = pc + disp + 4;
nkeynes@359
  1615
                            sh4r.in_delay_slot = 1;
nkeynes@27
  1616
                            return TRUE;
nkeynes@359
  1617
                        }
nkeynes@359
  1618
                        }
nkeynes@359
  1619
                        break;
nkeynes@359
  1620
                    case 0xF:
nkeynes@359
  1621
                        { /* BF/S disp */
nkeynes@359
  1622
                        int32_t disp = SIGNEXT8(ir&0xFF)<<1; 
nkeynes@359
  1623
                        CHECKSLOTILLEGAL();
nkeynes@359
  1624
                        if( !sh4r.t ) {
nkeynes@359
  1625
                            CHECKDEST( sh4r.pc + disp + 4 )
nkeynes@2
  1626
                            sh4r.in_delay_slot = 1;
nkeynes@1
  1627
                            sh4r.pc = sh4r.new_pc;
nkeynes@359
  1628
                            sh4r.new_pc = pc + disp + 4;
nkeynes@27
  1629
                            return TRUE;
nkeynes@359
  1630
                        }
nkeynes@359
  1631
                        }
nkeynes@359
  1632
                        break;
nkeynes@359
  1633
                    default:
nkeynes@359
  1634
                        UNDEF();
nkeynes@359
  1635
                        break;
nkeynes@359
  1636
                }
nkeynes@359
  1637
                break;
nkeynes@359
  1638
            case 0x9:
nkeynes@359
  1639
                { /* MOV.W @(disp, PC), Rn */
nkeynes@359
  1640
                uint32_t Rn = ((ir>>8)&0xF); uint32_t disp = (ir&0xFF)<<1; 
nkeynes@359
  1641
                CHECKSLOTILLEGAL();
nkeynes@359
  1642
                tmp = pc + 4 + disp;
nkeynes@359
  1643
                sh4r.r[Rn] = MEM_READ_WORD( tmp );
nkeynes@359
  1644
                }
nkeynes@359
  1645
                break;
nkeynes@359
  1646
            case 0xA:
nkeynes@359
  1647
                { /* BRA disp */
nkeynes@359
  1648
                int32_t disp = SIGNEXT12(ir&0xFFF)<<1; 
nkeynes@359
  1649
                CHECKSLOTILLEGAL();
nkeynes@359
  1650
                CHECKDEST( sh4r.pc + disp + 4 );
nkeynes@359
  1651
                sh4r.in_delay_slot = 1;
nkeynes@359
  1652
                sh4r.pc = sh4r.new_pc;
nkeynes@359
  1653
                sh4r.new_pc = pc + 4 + disp;
nkeynes@359
  1654
                return TRUE;
nkeynes@359
  1655
                }
nkeynes@359
  1656
                break;
nkeynes@359
  1657
            case 0xB:
nkeynes@359
  1658
                { /* BSR disp */
nkeynes@359
  1659
                int32_t disp = SIGNEXT12(ir&0xFFF)<<1; 
nkeynes@359
  1660
                CHECKDEST( sh4r.pc + disp + 4 );
nkeynes@359
  1661
                CHECKSLOTILLEGAL();
nkeynes@359
  1662
                sh4r.in_delay_slot = 1;
nkeynes@359
  1663
                sh4r.pr = pc + 4;
nkeynes@359
  1664
                sh4r.pc = sh4r.new_pc;
nkeynes@359
  1665
                sh4r.new_pc = pc + 4 + disp;
nkeynes@359
  1666
                TRACE_CALL( pc, sh4r.new_pc );
nkeynes@359
  1667
                return TRUE;
nkeynes@359
  1668
                }
nkeynes@359
  1669
                break;
nkeynes@359
  1670
            case 0xC:
nkeynes@359
  1671
                switch( (ir&0xF00) >> 8 ) {
nkeynes@359
  1672
                    case 0x0:
nkeynes@359
  1673
                        { /* MOV.B R0, @(disp, GBR) */
nkeynes@359
  1674
                        uint32_t disp = (ir&0xFF); 
nkeynes@359
  1675
                        MEM_WRITE_BYTE( sh4r.gbr + disp, R0 );
nkeynes@359
  1676
                        }
nkeynes@359
  1677
                        break;
nkeynes@359
  1678
                    case 0x1:
nkeynes@359
  1679
                        { /* MOV.W R0, @(disp, GBR) */
nkeynes@359
  1680
                        uint32_t disp = (ir&0xFF)<<1; 
nkeynes@359
  1681
                        tmp = sh4r.gbr + disp;
nkeynes@359
  1682
                        CHECKWALIGN16( tmp );
nkeynes@359
  1683
                        MEM_WRITE_WORD( tmp, R0 );
nkeynes@359
  1684
                        }
nkeynes@359
  1685
                        break;
nkeynes@359
  1686
                    case 0x2:
nkeynes@359
  1687
                        { /* MOV.L R0, @(disp, GBR) */
nkeynes@359
  1688
                        uint32_t disp = (ir&0xFF)<<2; 
nkeynes@359
  1689
                        tmp = sh4r.gbr + disp;
nkeynes@359
  1690
                        CHECKWALIGN32( tmp );
nkeynes@359
  1691
                        MEM_WRITE_LONG( tmp, R0 );
nkeynes@359
  1692
                        }
nkeynes@359
  1693
                        break;
nkeynes@359
  1694
                    case 0x3:
nkeynes@359
  1695
                        { /* TRAPA #imm */
nkeynes@359
  1696
                        uint32_t imm = (ir&0xFF); 
nkeynes@359
  1697
                        CHECKSLOTILLEGAL();
nkeynes@359
  1698
                        MMIO_WRITE( MMU, TRA, imm<<2 );
nkeynes@359
  1699
                        sh4r.pc += 2;
nkeynes@359
  1700
                        sh4_raise_exception( EXC_TRAP );
nkeynes@359
  1701
                        }
nkeynes@359
  1702
                        break;
nkeynes@359
  1703
                    case 0x4:
nkeynes@359
  1704
                        { /* MOV.B @(disp, GBR), R0 */
nkeynes@359
  1705
                        uint32_t disp = (ir&0xFF); 
nkeynes@359
  1706
                        R0 = MEM_READ_BYTE( sh4r.gbr + disp );
nkeynes@359
  1707
                        }
nkeynes@359
  1708
                        break;
nkeynes@359
  1709
                    case 0x5:
nkeynes@359
  1710
                        { /* MOV.W @(disp, GBR), R0 */
nkeynes@359
  1711
                        uint32_t disp = (ir&0xFF)<<1; 
nkeynes@359
  1712
                        tmp = sh4r.gbr + disp;
nkeynes@359
  1713
                        CHECKRALIGN16( tmp );
nkeynes@359
  1714
                        R0 = MEM_READ_WORD( tmp );
nkeynes@359
  1715
                        }
nkeynes@359
  1716
                        break;
nkeynes@359
  1717
                    case 0x6:
nkeynes@359
  1718
                        { /* MOV.L @(disp, GBR), R0 */
nkeynes@359
  1719
                        uint32_t disp = (ir&0xFF)<<2; 
nkeynes@359
  1720
                        tmp = sh4r.gbr + disp;
nkeynes@359
  1721
                        CHECKRALIGN32( tmp );
nkeynes@359
  1722
                        R0 = MEM_READ_LONG( tmp );
nkeynes@359
  1723
                        }
nkeynes@359
  1724
                        break;
nkeynes@359
  1725
                    case 0x7:
nkeynes@359
  1726
                        { /* MOVA @(disp, PC), R0 */
nkeynes@359
  1727
                        uint32_t disp = (ir&0xFF)<<2; 
nkeynes@359
  1728
                        CHECKSLOTILLEGAL();
nkeynes@359
  1729
                        R0 = (pc&0xFFFFFFFC) + disp + 4;
nkeynes@359
  1730
                        }
nkeynes@359
  1731
                        break;
nkeynes@359
  1732
                    case 0x8:
nkeynes@359
  1733
                        { /* TST #imm, R0 */
nkeynes@359
  1734
                        uint32_t imm = (ir&0xFF); 
nkeynes@359
  1735
                        sh4r.t = (R0 & imm ? 0 : 1);
nkeynes@359
  1736
                        }
nkeynes@359
  1737
                        break;
nkeynes@359
  1738
                    case 0x9:
nkeynes@359
  1739
                        { /* AND #imm, R0 */
nkeynes@359
  1740
                        uint32_t imm = (ir&0xFF); 
nkeynes@359
  1741
                        R0 &= imm;
nkeynes@359
  1742
                        }
nkeynes@359
  1743
                        break;
nkeynes@359
  1744
                    case 0xA:
nkeynes@359
  1745
                        { /* XOR #imm, R0 */
nkeynes@359
  1746
                        uint32_t imm = (ir&0xFF); 
nkeynes@359
  1747
                        R0 ^= imm;
nkeynes@359
  1748
                        }
nkeynes@359
  1749
                        break;
nkeynes@359
  1750
                    case 0xB:
nkeynes@359
  1751
                        { /* OR #imm, R0 */
nkeynes@359
  1752
                        uint32_t imm = (ir&0xFF); 
nkeynes@359
  1753
                        R0 |= imm;
nkeynes@359
  1754
                        }
nkeynes@359
  1755
                        break;
nkeynes@359
  1756
                    case 0xC:
nkeynes@359
  1757
                        { /* TST.B #imm, @(R0, GBR) */
nkeynes@359
  1758
                        uint32_t imm = (ir&0xFF); 
nkeynes@359
  1759
                        sh4r.t = ( MEM_READ_BYTE(R0 + sh4r.gbr) & imm ? 0 : 1 );
nkeynes@359
  1760
                        }
nkeynes@359
  1761
                        break;
nkeynes@359
  1762
                    case 0xD:
nkeynes@359
  1763
                        { /* AND.B #imm, @(R0, GBR) */
nkeynes@359
  1764
                        uint32_t imm = (ir&0xFF); 
nkeynes@359
  1765
                        MEM_WRITE_BYTE( R0 + sh4r.gbr, imm & MEM_READ_BYTE(R0 + sh4r.gbr) );
nkeynes@359
  1766
                        }
nkeynes@359
  1767
                        break;
nkeynes@359
  1768
                    case 0xE:
nkeynes@359
  1769
                        { /* XOR.B #imm, @(R0, GBR) */
nkeynes@359
  1770
                        uint32_t imm = (ir&0xFF); 
nkeynes@359
  1771
                        MEM_WRITE_BYTE( R0 + sh4r.gbr, imm ^ MEM_READ_BYTE(R0 + sh4r.gbr) );
nkeynes@359
  1772
                        }
nkeynes@359
  1773
                        break;
nkeynes@359
  1774
                    case 0xF:
nkeynes@359
  1775
                        { /* OR.B #imm, @(R0, GBR) */
nkeynes@359
  1776
                        uint32_t imm = (ir&0xFF); 
nkeynes@359
  1777
                        MEM_WRITE_BYTE( R0 + sh4r.gbr, imm | MEM_READ_BYTE(R0 + sh4r.gbr) );
nkeynes@359
  1778
                        }
nkeynes@359
  1779
                        break;
nkeynes@359
  1780
                }
nkeynes@359
  1781
                break;
nkeynes@359
  1782
            case 0xD:
nkeynes@359
  1783
                { /* MOV.L @(disp, PC), Rn */
nkeynes@359
  1784
                uint32_t Rn = ((ir>>8)&0xF); uint32_t disp = (ir&0xFF)<<2; 
nkeynes@359
  1785
                CHECKSLOTILLEGAL();
nkeynes@359
  1786
                tmp = (pc&0xFFFFFFFC) + disp + 4;
nkeynes@359
  1787
                sh4r.r[Rn] = MEM_READ_LONG( tmp );
nkeynes@359
  1788
                }
nkeynes@359
  1789
                break;
nkeynes@359
  1790
            case 0xE:
nkeynes@359
  1791
                { /* MOV #imm, Rn */
nkeynes@359
  1792
                uint32_t Rn = ((ir>>8)&0xF); int32_t imm = SIGNEXT8(ir&0xFF); 
nkeynes@359
  1793
                sh4r.r[Rn] = imm;
nkeynes@359
  1794
                }
nkeynes@359
  1795
                break;
nkeynes@359
  1796
            case 0xF:
nkeynes@359
  1797
                switch( ir&0xF ) {
nkeynes@359
  1798
                    case 0x0:
nkeynes@359
  1799
                        { /* FADD FRm, FRn */
nkeynes@359
  1800
                        uint32_t FRn = ((ir>>8)&0xF); uint32_t FRm = ((ir>>4)&0xF); 
nkeynes@359
  1801
                        CHECKFPUEN();
nkeynes@359
  1802
                        if( IS_FPU_DOUBLEPREC() ) {
nkeynes@359
  1803
                    	DR(FRn) += DR(FRm);
nkeynes@359
  1804
                        } else {
nkeynes@359
  1805
                    	FR(FRn) += FR(FRm);
nkeynes@359
  1806
                        }
nkeynes@359
  1807
                        }
nkeynes@359
  1808
                        break;
nkeynes@359
  1809
                    case 0x1:
nkeynes@359
  1810
                        { /* FSUB FRm, FRn */
nkeynes@359
  1811
                        uint32_t FRn = ((ir>>8)&0xF); uint32_t FRm = ((ir>>4)&0xF); 
nkeynes@359
  1812
                        CHECKFPUEN();
nkeynes@359
  1813
                        if( IS_FPU_DOUBLEPREC() ) {
nkeynes@359
  1814
                    	DR(FRn) -= DR(FRm);
nkeynes@359
  1815
                        } else {
nkeynes@359
  1816
                    	FR(FRn) -= FR(FRm);
nkeynes@359
  1817
                        }
nkeynes@359
  1818
                        }
nkeynes@359
  1819
                        break;
nkeynes@359
  1820
                    case 0x2:
nkeynes@359
  1821
                        { /* FMUL FRm, FRn */
nkeynes@359
  1822
                        uint32_t FRn = ((ir>>8)&0xF); uint32_t FRm = ((ir>>4)&0xF); 
nkeynes@359
  1823
                        CHECKFPUEN();
nkeynes@359
  1824
                        if( IS_FPU_DOUBLEPREC() ) {
nkeynes@359
  1825
                    	DR(FRn) *= DR(FRm);
nkeynes@359
  1826
                        } else {
nkeynes@359
  1827
                    	FR(FRn) *= FR(FRm);
nkeynes@359
  1828
                        }
nkeynes@359
  1829
                        }
nkeynes@359
  1830
                        break;
nkeynes@359
  1831
                    case 0x3:
nkeynes@359
  1832
                        { /* FDIV FRm, FRn */
nkeynes@359
  1833
                        uint32_t FRn = ((ir>>8)&0xF); uint32_t FRm = ((ir>>4)&0xF); 
nkeynes@359
  1834
                        CHECKFPUEN();
nkeynes@359
  1835
                        if( IS_FPU_DOUBLEPREC() ) {
nkeynes@359
  1836
                    	DR(FRn) /= DR(FRm);
nkeynes@359
  1837
                        } else {
nkeynes@359
  1838
                    	FR(FRn) /= FR(FRm);
nkeynes@359
  1839
                        }
nkeynes@359
  1840
                        }
nkeynes@359
  1841
                        break;
nkeynes@359
  1842
                    case 0x4:
nkeynes@359
  1843
                        { /* FCMP/EQ FRm, FRn */
nkeynes@359
  1844
                        uint32_t FRn = ((ir>>8)&0xF); uint32_t FRm = ((ir>>4)&0xF); 
nkeynes@359
  1845
                        CHECKFPUEN();
nkeynes@359
  1846
                        if( IS_FPU_DOUBLEPREC() ) {
nkeynes@359
  1847
                    	sh4r.t = ( DR(FRn) == DR(FRm) ? 1 : 0 );
nkeynes@359
  1848
                        } else {
nkeynes@359
  1849
                    	sh4r.t = ( FR(FRn) == FR(FRm) ? 1 : 0 );
nkeynes@359
  1850
                        }
nkeynes@359
  1851
                        }
nkeynes@359
  1852
                        break;
nkeynes@359
  1853
                    case 0x5:
nkeynes@359
  1854
                        { /* FCMP/GT FRm, FRn */
nkeynes@359
  1855
                        uint32_t FRn = ((ir>>8)&0xF); uint32_t FRm = ((ir>>4)&0xF); 
nkeynes@359
  1856
                        CHECKFPUEN();
nkeynes@359
  1857
                        if( IS_FPU_DOUBLEPREC() ) {
nkeynes@359
  1858
                    	sh4r.t = ( DR(FRn) > DR(FRm) ? 1 : 0 );
nkeynes@359
  1859
                        } else {
nkeynes@359
  1860
                    	sh4r.t = ( FR(FRn) > FR(FRm) ? 1 : 0 );
nkeynes@359
  1861
                        }
nkeynes@359
  1862
                        }
nkeynes@359
  1863
                        break;
nkeynes@359
  1864
                    case 0x6:
nkeynes@359
  1865
                        { /* FMOV @(R0, Rm), FRn */
nkeynes@359
  1866
                        uint32_t FRn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1867
                        MEM_FP_READ( sh4r.r[Rm] + R0, FRn );
nkeynes@359
  1868
                        }
nkeynes@359
  1869
                        break;
nkeynes@359
  1870
                    case 0x7:
nkeynes@359
  1871
                        { /* FMOV FRm, @(R0, Rn) */
nkeynes@359
  1872
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t FRm = ((ir>>4)&0xF); 
nkeynes@359
  1873
                        MEM_FP_WRITE( sh4r.r[Rn] + R0, FRm );
nkeynes@359
  1874
                        }
nkeynes@359
  1875
                        break;
nkeynes@359
  1876
                    case 0x8:
nkeynes@359
  1877
                        { /* FMOV @Rm, FRn */
nkeynes@359
  1878
                        uint32_t FRn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1879
                        MEM_FP_READ( sh4r.r[Rm], FRn );
nkeynes@359
  1880
                        }
nkeynes@359
  1881
                        break;
nkeynes@359
  1882
                    case 0x9:
nkeynes@359
  1883
                        { /* FMOV @Rm+, FRn */
nkeynes@359
  1884
                        uint32_t FRn = ((ir>>8)&0xF); uint32_t Rm = ((ir>>4)&0xF); 
nkeynes@359
  1885
                        MEM_FP_READ( sh4r.r[Rm], FRn ); sh4r.r[Rm] += FP_WIDTH;
nkeynes@359
  1886
                        }
nkeynes@359
  1887
                        break;
nkeynes@359
  1888
                    case 0xA:
nkeynes@359
  1889
                        { /* FMOV FRm, @Rn */
nkeynes@359
  1890
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t FRm = ((ir>>4)&0xF); 
nkeynes@359
  1891
                        MEM_FP_WRITE( sh4r.r[Rn], FRm );
nkeynes@359
  1892
                        }
nkeynes@359
  1893
                        break;
nkeynes@359
  1894
                    case 0xB:
nkeynes@359
  1895
                        { /* FMOV FRm, @-Rn */
nkeynes@359
  1896
                        uint32_t Rn = ((ir>>8)&0xF); uint32_t FRm = ((ir>>4)&0xF); 
nkeynes@359
  1897
                        sh4r.r[Rn] -= FP_WIDTH; MEM_FP_WRITE( sh4r.r[Rn], FRm );
nkeynes@359
  1898
                        }
nkeynes@359
  1899
                        break;
nkeynes@359
  1900
                    case 0xC:
nkeynes@359
  1901
                        { /* FMOV FRm, FRn */
nkeynes@359
  1902
                        uint32_t FRn = ((ir>>8)&0xF); uint32_t FRm = ((ir>>4)&0xF); 
nkeynes@359
  1903
                        if( IS_FPU_DOUBLESIZE() )
nkeynes@359
  1904
                    	DR(FRn) = DR(FRm);
nkeynes@359
  1905
                        else
nkeynes@359
  1906
                    	FR(FRn) = FR(FRm);
nkeynes@359
  1907
                        }
nkeynes@359
  1908
                        break;
nkeynes@359
  1909
                    case 0xD:
nkeynes@359
  1910
                        switch( (ir&0xF0) >> 4 ) {
nkeynes@359
  1911
                            case 0x0:
nkeynes@359
  1912
                                { /* FSTS FPUL, FRn */
nkeynes@359
  1913
                                uint32_t FRn = ((ir>>8)&0xF); 
nkeynes@359
  1914
                                CHECKFPUEN(); FR(FRn) = FPULf;
nkeynes@359
  1915
                                }
nkeynes@359
  1916
                                break;
nkeynes@359
  1917
                            case 0x1:
nkeynes@359
  1918
                                { /* FLDS FRm, FPUL */
nkeynes@359
  1919
                                uint32_t FRm = ((ir>>8)&0xF); 
nkeynes@359
  1920
                                CHECKFPUEN(); FPULf = FR(FRm);
nkeynes@359
  1921
                                }
nkeynes@359
  1922
                                break;
nkeynes@359
  1923
                            case 0x2:
nkeynes@359
  1924
                                { /* FLOAT FPUL, FRn */
nkeynes@359
  1925
                                uint32_t FRn = ((ir>>8)&0xF); 
nkeynes@359
  1926
                                CHECKFPUEN();
nkeynes@374
  1927
                                if( IS_FPU_DOUBLEPREC() ) {
nkeynes@374
  1928
                            	if( FRn&1 ) { // No, really...
nkeynes@374
  1929
                            	    dtmp = (double)FPULi;
nkeynes@374
  1930
                            	    FR(FRn) = *(((float *)&dtmp)+1);
nkeynes@374
  1931
                            	} else {
nkeynes@374
  1932
                            	    DRF(FRn>>1) = (double)FPULi;
nkeynes@374
  1933
                            	}
nkeynes@374
  1934
                                } else {
nkeynes@359
  1935
                            	FR(FRn) = (float)FPULi;
nkeynes@359
  1936
                                }
nkeynes@374
  1937
                                }
nkeynes@359
  1938
                                break;
nkeynes@359
  1939
                            case 0x3:
nkeynes@359
  1940
                                { /* FTRC FRm, FPUL */
nkeynes@359
  1941
                                uint32_t FRm = ((ir>>8)&0xF); 
nkeynes@359
  1942
                                CHECKFPUEN();
nkeynes@359
  1943
                                if( IS_FPU_DOUBLEPREC() ) {
nkeynes@374
  1944
                            	if( FRm&1 ) {
nkeynes@374
  1945
                            	    dtmp = 0;
nkeynes@374
  1946
                            	    *(((float *)&dtmp)+1) = FR(FRm);
nkeynes@374
  1947
                            	} else {
nkeynes@374
  1948
                            	    dtmp = DRF(FRm>>1);
nkeynes@374
  1949
                            	}
nkeynes@359
  1950
                                    if( dtmp >= MAX_INTF )
nkeynes@359
  1951
                                        FPULi = MAX_INT;
nkeynes@359
  1952
                                    else if( dtmp <= MIN_INTF )
nkeynes@359
  1953
                                        FPULi = MIN_INT;
nkeynes@359
  1954
                                    else 
nkeynes@359
  1955
                                        FPULi = (int32_t)dtmp;
nkeynes@359
  1956
                                } else {
nkeynes@359
  1957
                            	ftmp = FR(FRm);
nkeynes@359
  1958
                            	if( ftmp >= MAX_INTF )
nkeynes@359
  1959
                            	    FPULi = MAX_INT;
nkeynes@359
  1960
                            	else if( ftmp <= MIN_INTF )
nkeynes@359
  1961
                            	    FPULi = MIN_INT;
nkeynes@359
  1962
                            	else
nkeynes@359
  1963
                            	    FPULi = (int32_t)ftmp;
nkeynes@359
  1964
                                }
nkeynes@359
  1965
                                }
nkeynes@359
  1966
                                break;
nkeynes@359
  1967
                            case 0x4:
nkeynes@359
  1968
                                { /* FNEG FRn */
nkeynes@359
  1969
                                uint32_t FRn = ((ir>>8)&0xF); 
nkeynes@359
  1970
                                CHECKFPUEN();
nkeynes@359
  1971
                                if( IS_FPU_DOUBLEPREC() ) {
nkeynes@359
  1972
                            	DR(FRn) = -DR(FRn);
nkeynes@359
  1973
                                } else {
nkeynes@359
  1974
                                    FR(FRn) = -FR(FRn);
nkeynes@359
  1975
                                }
nkeynes@359
  1976
                                }
nkeynes@359
  1977
                                break;
nkeynes@359
  1978
                            case 0x5:
nkeynes@359
  1979
                                { /* FABS FRn */
nkeynes@359
  1980
                                uint32_t FRn = ((ir>>8)&0xF); 
nkeynes@359
  1981
                                CHECKFPUEN();
nkeynes@359
  1982
                                if( IS_FPU_DOUBLEPREC() ) {
nkeynes@359
  1983
                            	DR(FRn) = fabs(DR(FRn));
nkeynes@359
  1984
                                } else {
nkeynes@359
  1985
                                    FR(FRn) = fabsf(FR(FRn));
nkeynes@359
  1986
                                }
nkeynes@359
  1987
                                }
nkeynes@359
  1988
                                break;
nkeynes@359
  1989
                            case 0x6:
nkeynes@359
  1990
                                { /* FSQRT FRn */
nkeynes@359
  1991
                                uint32_t FRn = ((ir>>8)&0xF); 
nkeynes@359
  1992
                                CHECKFPUEN();
nkeynes@359
  1993
                                if( IS_FPU_DOUBLEPREC() ) {
nkeynes@359
  1994
                            	DR(FRn) = sqrt(DR(FRn));
nkeynes@359
  1995
                                } else {
nkeynes@359
  1996
                                    FR(FRn) = sqrtf(FR(FRn));
nkeynes@359
  1997
                                }
nkeynes@359
  1998
                                }
nkeynes@359
  1999
                                break;
nkeynes@359
  2000
                            case 0x7:
nkeynes@359
  2001
                                { /* FSRRA FRn */
nkeynes@359
  2002
                                uint32_t FRn = ((ir>>8)&0xF); 
nkeynes@359
  2003
                                CHECKFPUEN();
nkeynes@359
  2004
                                if( !IS_FPU_DOUBLEPREC() ) {
nkeynes@359
  2005
                            	FR(FRn) = 1.0/sqrtf(FR(FRn));
nkeynes@359
  2006
                                }
nkeynes@359
  2007
                                }
nkeynes@359
  2008
                                break;
nkeynes@359
  2009
                            case 0x8:
nkeynes@359
  2010
                                { /* FLDI0 FRn */
nkeynes@359
  2011
                                uint32_t FRn = ((ir>>8)&0xF); 
nkeynes@359
  2012
                                CHECKFPUEN();
nkeynes@359
  2013
                                if( IS_FPU_DOUBLEPREC() ) {
nkeynes@359
  2014
                            	DR(FRn) = 0.0;
nkeynes@359
  2015
                                } else {
nkeynes@359
  2016
                                    FR(FRn) = 0.0;
nkeynes@359
  2017
                                }
nkeynes@359
  2018
                                }
nkeynes@359
  2019
                                break;
nkeynes@359
  2020
                            case 0x9:
nkeynes@359
  2021
                                { /* FLDI1 FRn */
nkeynes@359
  2022
                                uint32_t FRn = ((ir>>8)&0xF); 
nkeynes@359
  2023
                                CHECKFPUEN();
nkeynes@359
  2024
                                if( IS_FPU_DOUBLEPREC() ) {
nkeynes@359
  2025
                            	DR(FRn) = 1.0;
nkeynes@359
  2026
                                } else {
nkeynes@359
  2027
                                    FR(FRn) = 1.0;
nkeynes@359
  2028
                                }
nkeynes@359
  2029
                                }
nkeynes@359
  2030
                                break;
nkeynes@359
  2031
                            case 0xA:
nkeynes@359
  2032
                                { /* FCNVSD FPUL, FRn */
nkeynes@359
  2033
                                uint32_t FRn = ((ir>>8)&0xF); 
nkeynes@359
  2034
                                CHECKFPUEN();
nkeynes@359
  2035
                                if( IS_FPU_DOUBLEPREC() && !IS_FPU_DOUBLESIZE() ) {
nkeynes@359
  2036
                            	DR(FRn) = (double)FPULf;
nkeynes@359
  2037
                                }
nkeynes@359
  2038
                                }
nkeynes@359
  2039
                                break;
nkeynes@359
  2040
                            case 0xB:
nkeynes@359
  2041
                                { /* FCNVDS FRm, FPUL */
nkeynes@359
  2042
                                uint32_t FRm = ((ir>>8)&0xF); 
nkeynes@359
  2043
                                CHECKFPUEN();
nkeynes@359
  2044
                                if( IS_FPU_DOUBLEPREC() && !IS_FPU_DOUBLESIZE() ) {
nkeynes@359
  2045
                            	FPULf = (float)DR(FRm);
nkeynes@359
  2046
                                }
nkeynes@359
  2047
                                }
nkeynes@359
  2048
                                break;
nkeynes@359
  2049
                            case 0xE:
nkeynes@359
  2050
                                { /* FIPR FVm, FVn */
nkeynes@359
  2051
                                uint32_t FVn = ((ir>>10)&0x3); uint32_t FVm = ((ir>>8)&0x3); 
nkeynes@359
  2052
                                CHECKFPUEN();
nkeynes@359
  2053
                                if( !IS_FPU_DOUBLEPREC() ) {
nkeynes@359
  2054
                                    int tmp2 = FVn<<2;
nkeynes@359
  2055
                                    tmp = FVm<<2;
nkeynes@359
  2056
                                    FR(tmp2+3) = FR(tmp)*FR(tmp2) +
nkeynes@359
  2057
                                        FR(tmp+1)*FR(tmp2+1) +
nkeynes@359
  2058
                                        FR(tmp+2)*FR(tmp2+2) +
nkeynes@359
  2059
                                        FR(tmp+3)*FR(tmp2+3);
nkeynes@359
  2060
                                }
nkeynes@359
  2061
                                }
nkeynes@359
  2062
                                break;
nkeynes@359
  2063
                            case 0xF:
nkeynes@359
  2064
                                switch( (ir&0x100) >> 8 ) {
nkeynes@359
  2065
                                    case 0x0:
nkeynes@359
  2066
                                        { /* FSCA FPUL, FRn */
nkeynes@359
  2067
                                        uint32_t FRn = ((ir>>9)&0x7)<<1; 
nkeynes@359
  2068
                                        CHECKFPUEN();
nkeynes@359
  2069
                                        if( !IS_FPU_DOUBLEPREC() ) {
nkeynes@391
  2070
                                    	sh4_fsca( FPULi, &(DRF(FRn>>1)) );
nkeynes@391
  2071
                                    	/*
nkeynes@359
  2072
                                            float angle = (((float)(FPULi&0xFFFF))/65536.0) * 2 * M_PI;
nkeynes@359
  2073
                                            FR(FRn) = sinf(angle);
nkeynes@359
  2074
                                            FR((FRn)+1) = cosf(angle);
nkeynes@391
  2075
                                    	*/
nkeynes@359
  2076
                                        }
nkeynes@359
  2077
                                        }
nkeynes@359
  2078
                                        break;
nkeynes@359
  2079
                                    case 0x1:
nkeynes@359
  2080
                                        switch( (ir&0x200) >> 9 ) {
nkeynes@359
  2081
                                            case 0x0:
nkeynes@359
  2082
                                                { /* FTRV XMTRX, FVn */
nkeynes@359
  2083
                                                uint32_t FVn = ((ir>>10)&0x3); 
nkeynes@359
  2084
                                                CHECKFPUEN();
nkeynes@359
  2085
                                                if( !IS_FPU_DOUBLEPREC() ) {
nkeynes@391
  2086
                                            	sh4_ftrv(&(DRF(FVn<<1)), &sh4r.fr[((~sh4r.fpscr)&FPSCR_FR)>>21][0]);
nkeynes@391
  2087
                                            	/*
nkeynes@359
  2088
                                                    tmp = FVn<<2;
nkeynes@374
  2089
                                            	float *xf = &sh4r.fr[((~sh4r.fpscr)&FPSCR_FR)>>21][0];
nkeynes@359
  2090
                                                    float fv[4] = { FR(tmp), FR(tmp+1), FR(tmp+2), FR(tmp+3) };
nkeynes@374
  2091
                                                    FR(tmp) = xf[1] * fv[0] + xf[5]*fv[1] +
nkeynes@374
  2092
                                            	    xf[9]*fv[2] + xf[13]*fv[3];
nkeynes@374
  2093
                                                    FR(tmp+1) = xf[0] * fv[0] + xf[4]*fv[1] +
nkeynes@374
  2094
                                            	    xf[8]*fv[2] + xf[12]*fv[3];
nkeynes@374
  2095
                                                    FR(tmp+2) = xf[3] * fv[0] + xf[7]*fv[1] +
nkeynes@374
  2096
                                            	    xf[11]*fv[2] + xf[15]*fv[3];
nkeynes@374
  2097
                                                    FR(tmp+3) = xf[2] * fv[0] + xf[6]*fv[1] +
nkeynes@374
  2098
                                            	    xf[10]*fv[2] + xf[14]*fv[3];
nkeynes@391
  2099
                                            	*/
nkeynes@359
  2100
                                                }
nkeynes@359
  2101
                                                }
nkeynes@359
  2102
                                                break;
nkeynes@359
  2103
                                            case 0x1:
nkeynes@359
  2104
                                                switch( (ir&0xC00) >> 10 ) {
nkeynes@359
  2105
                                                    case 0x0:
nkeynes@359
  2106
                                                        { /* FSCHG */
nkeynes@359
  2107
                                                        CHECKFPUEN(); sh4r.fpscr ^= FPSCR_SZ;
nkeynes@359
  2108
                                                        }
nkeynes@359
  2109
                                                        break;
nkeynes@359
  2110
                                                    case 0x2:
nkeynes@359
  2111
                                                        { /* FRCHG */
nkeynes@374
  2112
                                                        CHECKFPUEN(); 
nkeynes@374
  2113
                                                        sh4r.fpscr ^= FPSCR_FR; 
nkeynes@374
  2114
                                                        sh4r.fr_bank = &sh4r.fr[(sh4r.fpscr&FPSCR_FR)>>21][0];
nkeynes@359
  2115
                                                        }
nkeynes@359
  2116
                                                        break;
nkeynes@359
  2117
                                                    case 0x3:
nkeynes@359
  2118
                                                        { /* UNDEF */
nkeynes@359
  2119
                                                        UNDEF(ir);
nkeynes@359
  2120
                                                        }
nkeynes@359
  2121
                                                        break;
nkeynes@359
  2122
                                                    default:
nkeynes@359
  2123
                                                        UNDEF();
nkeynes@359
  2124
                                                        break;
nkeynes@359
  2125
                                                }
nkeynes@359
  2126
                                                break;
nkeynes@359
  2127
                                        }
nkeynes@359
  2128
                                        break;
nkeynes@359
  2129
                                }
nkeynes@359
  2130
                                break;
nkeynes@359
  2131
                            default:
nkeynes@359
  2132
                                UNDEF();
nkeynes@359
  2133
                                break;
nkeynes@359
  2134
                        }
nkeynes@359
  2135
                        break;
nkeynes@359
  2136
                    case 0xE:
nkeynes@359
  2137
                        { /* FMAC FR0, FRm, FRn */
nkeynes@359
  2138
                        uint32_t FRn = ((ir>>8)&0xF); uint32_t FRm = ((ir>>4)&0xF); 
nkeynes@359
  2139
                        CHECKFPUEN();
nkeynes@359
  2140
                        if( IS_FPU_DOUBLEPREC() ) {
nkeynes@359
  2141
                            DR(FRn) += DR(FRm)*DR(0);
nkeynes@359
  2142
                        } else {
nkeynes@359
  2143
                    	FR(FRn) += FR(FRm)*FR(0);
nkeynes@359
  2144
                        }
nkeynes@359
  2145
                        }
nkeynes@359
  2146
                        break;
nkeynes@359
  2147
                    default:
nkeynes@359
  2148
                        UNDEF();
nkeynes@359
  2149
                        break;
nkeynes@359
  2150
                }
nkeynes@359
  2151
                break;
nkeynes@359
  2152
        }
nkeynes@1
  2153
nkeynes@1
  2154
    sh4r.pc = sh4r.new_pc;
nkeynes@1
  2155
    sh4r.new_pc += 2;
nkeynes@2
  2156
    sh4r.in_delay_slot = 0;
nkeynes@273
  2157
    return TRUE;
nkeynes@1
  2158
}
.