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