mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
updated Musashi to MAME 0.117
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@188 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
60305cdd4d
commit
c6a4c89286
13 changed files with 331 additions and 38681 deletions
6
cpu/musashi/Makefile
Normal file
6
cpu/musashi/Makefile
Normal file
|
@ -0,0 +1,6 @@
|
|||
m68kops.c : m68kmake
|
||||
./$<
|
||||
|
||||
clean:
|
||||
$(RM) m68kops.c m68kops.h m68kmake *.o
|
||||
|
|
@ -6,10 +6,10 @@
|
|||
/* ======================================================================== */
|
||||
/*
|
||||
* MUSASHI
|
||||
* Version 3.3
|
||||
* Version 3.31
|
||||
*
|
||||
* A portable Motorola M680x0 processor emulation engine.
|
||||
* Copyright 1998-2001 Karl Stenerud. All rights reserved.
|
||||
* Copyright 1998-2007 Karl Stenerud. All rights reserved.
|
||||
*
|
||||
* This code may be freely used for non-commercial purposes as long as this
|
||||
* copyright notice remains unaltered in the source code and any binary files
|
||||
|
@ -240,6 +240,14 @@ void m68k_set_cmpild_instr_callback(void (*callback)(unsigned int val, int reg)
|
|||
*/
|
||||
void m68k_set_rte_instr_callback(void (*callback)(void));
|
||||
|
||||
/* Set the callback for the TAS instruction.
|
||||
* You must enable M68K_TAS_HAS_CALLBACK in m68kconf.h.
|
||||
* The CPU calls this callback every time it encounters a TAS instruction.
|
||||
* Default behavior: return 1, allow writeback.
|
||||
*/
|
||||
void m68k_set_tas_instr_callback(int (*callback)(void));
|
||||
|
||||
|
||||
|
||||
/* Set the callback for informing of a large PC change.
|
||||
* You must enable M68K_MONITOR_PC in m68kconf.h.
|
||||
|
@ -352,7 +360,7 @@ unsigned int m68k_disassemble(char* str_buff, unsigned int pc, unsigned int cpu_
|
|||
/* Same as above but accepts raw opcode data directly rather than fetching
|
||||
* via the read/write interfaces.
|
||||
*/
|
||||
unsigned int m68k_disassemble_raw(char* str_buff, unsigned int pc, unsigned char* opdata, unsigned char* argdata, int length, unsigned int cpu_type);
|
||||
unsigned int m68k_disassemble_raw(char* str_buff, unsigned int pc, const unsigned char* opdata, const unsigned char* argdata, unsigned int cpu_type);
|
||||
|
||||
|
||||
/* ======================================================================== */
|
||||
|
|
|
@ -8,10 +8,10 @@ must fix:
|
|||
/* ======================================================================== */
|
||||
/*
|
||||
* MUSASHI
|
||||
* Version 3.3
|
||||
* Version 3.31
|
||||
*
|
||||
* A portable Motorola M680x0 processor emulation engine.
|
||||
* Copyright 1998-2001 Karl Stenerud. All rights reserved.
|
||||
* Copyright 1998-2007 Karl Stenerud. All rights reserved.
|
||||
*
|
||||
* This code may be freely used for non-commercial purposes as long as this
|
||||
* copyright notice remains unaltered in the source code and any binary files
|
||||
|
@ -259,6 +259,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
|||
M68KMAKE_OPCODE_HANDLER_HEADER
|
||||
|
||||
#include "m68kcpu.h"
|
||||
extern void m68040_fpu_op0(void);
|
||||
extern void m68040_fpu_op1(void);
|
||||
|
||||
/* ======================================================================== */
|
||||
/* ========================= INSTRUCTION HANDLERS ========================= */
|
||||
|
@ -354,6 +356,8 @@ name size proc ea bit pattern A+-DXWLdxI 0 1 2 4 000 010 020 040
|
|||
M68KMAKE_TABLE_START
|
||||
1010 0 . . 1010............ .......... U U U U 4 4 4 4
|
||||
1111 0 . . 1111............ .......... U U U U 4 4 4 4
|
||||
040fpu0 32 . . 11110010........ .......... . . . U . . . 0
|
||||
040fpu1 32 . . 11110011........ .......... . . . U . . . 0
|
||||
abcd 8 rr . 1100...100000... .......... U U U U 6 6 4 4
|
||||
abcd 8 mm ax7 1100111100001... .......... U U U U 18 18 16 16
|
||||
abcd 8 mm ay7 1100...100001111 .......... U U U U 18 18 16 16
|
||||
|
@ -494,7 +498,7 @@ chk2cmp2 32 . . 0000010011...... A..DXWL... . . U U . . 18 18
|
|||
clr 8 . d 0100001000000... .......... U U U U 4 4 2 2
|
||||
clr 8 . . 0100001000...... A+-DXWL... U U U U 6 4 4 4 notaz hack: changed 000 cycles 8 -> 6 like in starscream for Fatal Rewind
|
||||
clr 16 . d 0100001001000... .......... U U U U 4 4 2 2
|
||||
clr 16 . . 0100001001...... A+-DXWL... U U U U 6 4 4 4 ditto
|
||||
clr 16 . . 0100001001...... A+-DXWL... U U U U 6 4 4 4 notaz hack: ditto
|
||||
clr 32 . d 0100001010000... .......... U U U U 6 6 2 2
|
||||
clr 32 . . 0100001010...... A+-DXWL... U U U U 12 6 4 4
|
||||
cmp 8 . d 1011...000000... .......... U U U U 4 4 2 2
|
||||
|
@ -885,6 +889,29 @@ M68KMAKE_OP(1111, 0, ., .)
|
|||
}
|
||||
|
||||
|
||||
M68KMAKE_OP(040fpu0, 32, ., .)
|
||||
{
|
||||
if(CPU_TYPE_IS_040_PLUS(CPU_TYPE))
|
||||
{
|
||||
m68040_fpu_op0();
|
||||
return;
|
||||
}
|
||||
m68ki_exception_1111();
|
||||
}
|
||||
|
||||
|
||||
M68KMAKE_OP(040fpu1, 32, ., .)
|
||||
{
|
||||
if(CPU_TYPE_IS_040_PLUS(CPU_TYPE))
|
||||
{
|
||||
m68040_fpu_op1();
|
||||
return;
|
||||
}
|
||||
m68ki_exception_1111();
|
||||
}
|
||||
|
||||
|
||||
|
||||
M68KMAKE_OP(abcd, 8, rr, .)
|
||||
{
|
||||
uint* r_dst = &DX;
|
||||
|
@ -1210,8 +1237,9 @@ M68KMAKE_OP(adda, 16, ., a)
|
|||
M68KMAKE_OP(adda, 16, ., .)
|
||||
{
|
||||
uint* r_dst = &AX;
|
||||
uint src = MAKE_INT_16(M68KMAKE_GET_OPER_AY_16);
|
||||
|
||||
*r_dst = MASK_OUT_ABOVE_32(*r_dst + MAKE_INT_16(M68KMAKE_GET_OPER_AY_16));
|
||||
*r_dst = MASK_OUT_ABOVE_32(*r_dst + src);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3100,8 +3128,8 @@ M68KMAKE_OP(bra, 8, ., .)
|
|||
{
|
||||
m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
|
||||
m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR));
|
||||
// if(REG_PC == REG_PPC)
|
||||
// USE_ALL_CYCLES();
|
||||
if(REG_PC == REG_PPC)
|
||||
USE_ALL_CYCLES();
|
||||
}
|
||||
|
||||
|
||||
|
@ -3111,8 +3139,8 @@ M68KMAKE_OP(bra, 16, ., .)
|
|||
REG_PC -= 2;
|
||||
m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
|
||||
m68ki_branch_16(offset);
|
||||
// if(REG_PC == REG_PPC)
|
||||
// USE_ALL_CYCLES();
|
||||
if(REG_PC == REG_PPC)
|
||||
USE_ALL_CYCLES();
|
||||
}
|
||||
|
||||
|
||||
|
@ -3132,8 +3160,8 @@ M68KMAKE_OP(bra, 32, ., .)
|
|||
{
|
||||
m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
|
||||
m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR));
|
||||
// if(REG_PC == REG_PPC)
|
||||
// USE_ALL_CYCLES();
|
||||
if(REG_PC == REG_PPC)
|
||||
USE_ALL_CYCLES();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5258,7 +5286,7 @@ M68KMAKE_OP(jsr, 32, ., .)
|
|||
{
|
||||
uint ea = M68KMAKE_GET_EA_AY_32;
|
||||
m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */
|
||||
m68ki_push_32(MAKE_INT_24(REG_PC)); // notaz: Cyclone can't handle 32bit PC and I neet to debug it
|
||||
m68ki_push_32(REG_PC);
|
||||
m68ki_jump(ea);
|
||||
}
|
||||
|
||||
|
@ -6426,7 +6454,8 @@ M68KMAKE_OP(move, 32, pd, d)
|
|||
uint res = DY;
|
||||
uint ea = EA_AX_PD_32();
|
||||
|
||||
m68ki_write_32(ea, res);
|
||||
m68ki_write_16(ea+2, res & 0xFFFF );
|
||||
m68ki_write_16(ea, (res >> 16) & 0xFFFF );
|
||||
|
||||
FLAG_N = NFLAG_32(res);
|
||||
FLAG_Z = res;
|
||||
|
@ -6440,7 +6469,8 @@ M68KMAKE_OP(move, 32, pd, a)
|
|||
uint res = AY;
|
||||
uint ea = EA_AX_PD_32();
|
||||
|
||||
m68ki_write_32(ea, res);
|
||||
m68ki_write_16(ea+2, res & 0xFFFF );
|
||||
m68ki_write_16(ea, (res >> 16) & 0xFFFF );
|
||||
|
||||
FLAG_N = NFLAG_32(res);
|
||||
FLAG_Z = res;
|
||||
|
@ -6454,7 +6484,8 @@ M68KMAKE_OP(move, 32, pd, .)
|
|||
uint res = M68KMAKE_GET_OPER_AY_32;
|
||||
uint ea = EA_AX_PD_32();
|
||||
|
||||
m68ki_write_32(ea, res);
|
||||
m68ki_write_16(ea+2, res & 0xFFFF );
|
||||
m68ki_write_16(ea, (res >> 16) & 0xFFFF );
|
||||
|
||||
FLAG_N = NFLAG_32(res);
|
||||
FLAG_Z = res;
|
||||
|
@ -6921,7 +6952,15 @@ M68KMAKE_OP(movec, 32, rc, .)
|
|||
case 0x002: /* CACR */
|
||||
if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
|
||||
{
|
||||
REG_CACR = REG_DA[(word2 >> 12) & 15];
|
||||
if (CPU_TYPE_IS_040_PLUS(CPU_TYPE))
|
||||
{
|
||||
REG_CACR = REG_DA[(word2 >> 12) & 15];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* non 68040 can only set the lower 4 bits (C,CE,F,E) */
|
||||
REG_CACR = REG_DA[(word2 >> 12) & 15] & 0x0f;
|
||||
}
|
||||
return;
|
||||
}
|
||||
m68ki_exception_illegal();
|
||||
|
@ -7093,7 +7132,8 @@ M68KMAKE_OP(movem, 32, re, pd)
|
|||
if(register_list & (1 << i))
|
||||
{
|
||||
ea -= 4;
|
||||
m68ki_write_32(ea, REG_DA[15-i]);
|
||||
m68ki_write_16(ea+2, REG_DA[15-i] & 0xFFFF );
|
||||
m68ki_write_16(ea, (REG_DA[15-i] >> 16) & 0xFFFF );
|
||||
count++;
|
||||
}
|
||||
AY = ea;
|
||||
|
@ -8700,8 +8740,7 @@ M68KMAKE_OP(rol, 32, r, .)
|
|||
|
||||
*r_dst = res;
|
||||
|
||||
FLAG_C = (src >> (32 - shift)) << 8;
|
||||
if (shift == 0) FLAG_C = src << 8; // notaz
|
||||
FLAG_C = (src >> ((32 - shift) & 0x1f)) << 8;
|
||||
FLAG_N = NFLAG_32(res);
|
||||
FLAG_Z = res;
|
||||
FLAG_V = VFLAG_CLEAR;
|
||||
|
@ -9721,8 +9760,9 @@ M68KMAKE_OP(suba, 16, ., a)
|
|||
M68KMAKE_OP(suba, 16, ., .)
|
||||
{
|
||||
uint* r_dst = &AX;
|
||||
uint src = MAKE_INT_16(M68KMAKE_GET_OPER_AY_16);
|
||||
|
||||
*r_dst = MASK_OUT_ABOVE_32(*r_dst - MAKE_INT_16(M68KMAKE_GET_OPER_AY_16));
|
||||
*r_dst = MASK_OUT_ABOVE_32(*r_dst - src);
|
||||
}
|
||||
|
||||
|
||||
|
@ -10150,12 +10190,20 @@ M68KMAKE_OP(tas, 8, ., .)
|
|||
{
|
||||
uint ea = M68KMAKE_GET_EA_AY_8;
|
||||
uint dst = m68ki_read_8(ea);
|
||||
uint allow_writeback;
|
||||
|
||||
FLAG_Z = dst;
|
||||
FLAG_N = NFLAG_8(dst);
|
||||
FLAG_V = VFLAG_CLEAR;
|
||||
FLAG_C = CFLAG_CLEAR;
|
||||
// m68ki_write_8(ea, dst | 0x80); // notaz: genesis, but only to mem
|
||||
|
||||
/* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback
|
||||
disabled in order to function properly. Some Amiga software may also rely
|
||||
on this, but only when accessing specific addresses so additional functionality
|
||||
will be needed. */
|
||||
allow_writeback = m68ki_tas_callback();
|
||||
|
||||
if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -126,6 +126,13 @@
|
|||
#define M68K_RTE_CALLBACK() your_rte_handler_function()
|
||||
|
||||
|
||||
/* If ON, CPU will call the callback when it encounters a tas
|
||||
* instruction.
|
||||
*/
|
||||
#define M68K_TAS_HAS_CALLBACK OPT_ON
|
||||
#define M68K_TAS_CALLBACK() your_tas_handler_function()
|
||||
|
||||
|
||||
/* If ON, CPU will call the set fc callback on every memory access to
|
||||
* differentiate between user/supervisor, program/data access like a real
|
||||
* 68000 would. This should be enabled and the callback should be set if you
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
#if 0
|
||||
static const char* copyright_notice =
|
||||
"MUSASHI\n"
|
||||
"Version 3.3 (2001-01-29)\n"
|
||||
"Version 3.31 (2007-07-09)\n"
|
||||
"A portable Motorola M680x0 processor emulation engine.\n"
|
||||
"Copyright 1998-2001 Karl Stenerud. All rights reserved.\n"
|
||||
"Copyright 1998-2007 Karl Stenerud. All rights reserved.\n"
|
||||
"\n"
|
||||
"This code may be freely used for non-commercial purpooses as long as this\n"
|
||||
"copyright notice remains unaltered in the source code and any binary files\n"
|
||||
|
@ -32,15 +32,19 @@ static const char* copyright_notice =
|
|||
/* ================================ INCLUDES ============================== */
|
||||
/* ======================================================================== */
|
||||
|
||||
extern void m68040_fpu_op0(void);
|
||||
extern void m68040_fpu_op1(void);
|
||||
|
||||
#include "m68kops.h"
|
||||
#include "m68kcpu.h"
|
||||
//#include "m68kfpu.c"
|
||||
|
||||
/* ======================================================================== */
|
||||
/* ================================= DATA ================================= */
|
||||
/* ======================================================================== */
|
||||
|
||||
// int m68ki_initial_cycles; // moved to m68k_execute() stack
|
||||
// int m68ki_remaining_cycles = 0; /* Number of clocks remaining */
|
||||
int m68ki_initial_cycles;
|
||||
//int m68ki_remaining_cycles = 0; /* Number of clocks remaining */
|
||||
uint m68ki_tracing = 0;
|
||||
uint m68ki_address_space;
|
||||
|
||||
|
@ -68,8 +72,9 @@ const char* m68ki_cpu_names[] =
|
|||
#endif /* M68K_LOG_ENABLE */
|
||||
|
||||
/* The CPU core */
|
||||
// m68ki_cpu_core m68ki_cpu = {0};
|
||||
// notaz
|
||||
m68ki_cpu_core *m68ki_cpu_p = NULL;
|
||||
//m68ki_cpu_core m68ki_cpu = {0};
|
||||
|
||||
|
||||
#if M68K_EMULATE_ADDRESS_ERROR
|
||||
|
@ -477,6 +482,12 @@ static void default_rte_instr_callback(void)
|
|||
{
|
||||
}
|
||||
|
||||
/* Called when a tas instruction is executed */
|
||||
static int default_tas_instr_callback(void)
|
||||
{
|
||||
return 1; // allow writeback
|
||||
}
|
||||
|
||||
/* Called when the program counter changed by a large value */
|
||||
static unsigned int default_pc_changed_callback_data;
|
||||
static void default_pc_changed_callback(unsigned int new_pc)
|
||||
|
@ -647,6 +658,11 @@ void m68k_set_rte_instr_callback(void (*callback)(void))
|
|||
CALLBACK_RTE_INSTR = callback ? callback : default_rte_instr_callback;
|
||||
}
|
||||
|
||||
void m68k_set_tas_instr_callback(int (*callback)(void))
|
||||
{
|
||||
CALLBACK_TAS_INSTR = callback ? callback : default_tas_instr_callback;
|
||||
}
|
||||
|
||||
void m68k_set_pc_changed_callback(void (*callback)(unsigned int new_pc))
|
||||
{
|
||||
CALLBACK_PC_CHANGED = callback ? callback : default_pc_changed_callback;
|
||||
|
@ -771,8 +787,6 @@ void m68k_set_cpu_type(unsigned int cpu_type)
|
|||
/* ASG: removed per-instruction interrupt checks */
|
||||
int m68k_execute(int num_cycles)
|
||||
{
|
||||
int m68ki_initial_cycles;
|
||||
|
||||
/* Make sure we're not stopped */
|
||||
if(!CPU_STOPPED)
|
||||
{
|
||||
|
@ -788,7 +802,9 @@ int m68k_execute(int num_cycles)
|
|||
m68ki_set_address_error_trap(); /* auto-disable (see m68kcpu.h) */
|
||||
|
||||
/* Main loop. Keep going until we run out of clock cycles */
|
||||
// notaz
|
||||
while(GET_CYCLES() >= 0)
|
||||
// do
|
||||
{
|
||||
/* Set tracing accodring to T1. (T0 is done inside instruction) */
|
||||
m68ki_trace_t1(); /* auto-disable (see m68kcpu.h) */
|
||||
|
@ -809,7 +825,7 @@ int m68k_execute(int num_cycles)
|
|||
|
||||
/* Trace m68k_exception, if necessary */
|
||||
m68ki_exception_if_trace(); /* auto-disable (see m68kcpu.h) */
|
||||
}
|
||||
} // while(GET_CYCLES() > 0); // notaz
|
||||
|
||||
/* set previous PC to current PC for the next entry into the loop */
|
||||
REG_PPC = REG_PC;
|
||||
|
@ -829,19 +845,17 @@ int m68k_execute(int num_cycles)
|
|||
return num_cycles;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
int m68k_cycles_run(void)
|
||||
{
|
||||
return m68ki_initial_cycles - GET_CYCLES();
|
||||
}
|
||||
#endif
|
||||
|
||||
int m68k_cycles_remaining(void)
|
||||
{
|
||||
return GET_CYCLES();
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Change the timeslice */
|
||||
void m68k_modify_timeslice(int cycles)
|
||||
{
|
||||
|
@ -855,7 +869,7 @@ void m68k_end_timeslice(void)
|
|||
m68ki_initial_cycles = GET_CYCLES();
|
||||
SET_CYCLES(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* ASG: rewrote so that the int_level is a mask of the IPL0/IPL1/IPL2 bits */
|
||||
/* KS: Modified so that IPL* bits match with mask positions in the SR
|
||||
|
@ -890,6 +904,7 @@ void m68k_init(void)
|
|||
m68k_set_reset_instr_callback(NULL);
|
||||
m68k_set_cmpild_instr_callback(NULL);
|
||||
m68k_set_rte_instr_callback(NULL);
|
||||
m68k_set_tas_instr_callback(NULL);
|
||||
m68k_set_pc_changed_callback(NULL);
|
||||
m68k_set_fc_callback(NULL);
|
||||
m68k_set_instr_hook_callback(NULL);
|
||||
|
@ -943,17 +958,17 @@ unsigned int m68k_context_size()
|
|||
return sizeof(m68ki_cpu_core);
|
||||
}
|
||||
|
||||
/*
|
||||
unsigned int m68k_get_context(void* dst)
|
||||
{
|
||||
if(dst) *(m68ki_cpu_core*)dst = m68ki_cpu;
|
||||
return sizeof(m68ki_cpu_core);
|
||||
}
|
||||
*/
|
||||
|
||||
void m68k_set_context(void* src)
|
||||
{
|
||||
// notaz
|
||||
if(src) m68ki_cpu_p = src;
|
||||
// if(src) m68ki_cpu = *(m68ki_cpu_core*)src;
|
||||
}
|
||||
|
||||
|
||||
|
@ -964,8 +979,6 @@ void m68k_set_context(void* src)
|
|||
|
||||
#if M68K_COMPILE_FOR_MAME == OPT_ON
|
||||
|
||||
#include "state.h"
|
||||
|
||||
static struct {
|
||||
UINT16 sr;
|
||||
UINT8 stopped;
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
/* ======================================================================== */
|
||||
/*
|
||||
* MUSASHI
|
||||
* Version 3.3
|
||||
* Version 3.31
|
||||
*
|
||||
* A portable Motorola M680x0 processor emulation engine.
|
||||
* Copyright 1998-2001 Karl Stenerud. All rights reserved.
|
||||
* Copyright 1998-2007 Karl Stenerud. All rights reserved.
|
||||
*
|
||||
* This code may be freely used for non-commercial purposes as long as this
|
||||
* copyright notice remains unaltered in the source code and any binary files
|
||||
|
@ -28,6 +28,7 @@
|
|||
|
||||
// notaz: something's missing this
|
||||
#ifndef UINT16
|
||||
#define UINT64 unsigned long long
|
||||
#define UINT32 unsigned int
|
||||
#define UINT16 unsigned short
|
||||
#define UINT8 unsigned char
|
||||
|
@ -65,10 +66,10 @@
|
|||
|
||||
#define sint8 signed char /* ASG: changed from char to signed char */
|
||||
#define sint16 signed short
|
||||
#define sint32 signed long
|
||||
#define sint32 signed int /* AWJ: changed from long to int */
|
||||
#define uint8 unsigned char
|
||||
#define uint16 unsigned short
|
||||
#define uint32 unsigned long
|
||||
#define uint32 unsigned int /* AWJ: changed from long to int */
|
||||
|
||||
/* signed and unsigned int must be at least 32 bits wide */
|
||||
#define sint signed int
|
||||
|
@ -116,7 +117,7 @@
|
|||
|
||||
|
||||
/* Allow for architectures that don't have 32-bit sizes */
|
||||
#if ULONG_MAX == 0xffffffff
|
||||
#if UINT_MAX == 0xffffffff
|
||||
#define MAKE_INT_32(A) (sint32)(A)
|
||||
#else
|
||||
#undef sint32
|
||||
|
@ -127,13 +128,8 @@
|
|||
{
|
||||
return (value & 0x80000000) ? value | ~0xffffffff : value & 0xffffffff;
|
||||
}
|
||||
#endif /* ULONG_MAX == 0xffffffff */
|
||||
#endif /* UINT_MAX == 0xffffffff */
|
||||
|
||||
// notaz
|
||||
INLINE sint32 MAKE_INT_24(uint value)
|
||||
{
|
||||
return (value & 0x800000) ? value | ~0xffffff : value & 0xffffff;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -328,6 +324,11 @@ INLINE sint32 MAKE_INT_24(uint value)
|
|||
#define REG_CAAR m68ki_cpu.caar
|
||||
#define REG_IR m68ki_cpu.ir
|
||||
|
||||
#define REG_FP m68ki_cpu.fpr
|
||||
#define REG_FPCR m68ki_cpu.fpcr
|
||||
#define REG_FPSR m68ki_cpu.fpsr
|
||||
#define REG_FPIAR m68ki_cpu.fpiar
|
||||
|
||||
#define FLAG_T1 m68ki_cpu.t1_flag
|
||||
#define FLAG_T0 m68ki_cpu.t0_flag
|
||||
#define FLAG_S m68ki_cpu.s_flag
|
||||
|
@ -367,6 +368,7 @@ INLINE sint32 MAKE_INT_24(uint value)
|
|||
#define CALLBACK_RESET_INSTR m68ki_cpu.reset_instr_callback
|
||||
#define CALLBACK_CMPILD_INSTR m68ki_cpu.cmpild_instr_callback
|
||||
#define CALLBACK_RTE_INSTR m68ki_cpu.rte_instr_callback
|
||||
#define CALLBACK_TAS_INSTR m68ki_cpu.tas_instr_callback
|
||||
#define CALLBACK_PC_CHANGED m68ki_cpu.pc_changed_callback
|
||||
#define CALLBACK_SET_FC m68ki_cpu.set_fc_callback
|
||||
#define CALLBACK_INSTR_HOOK m68ki_cpu.instr_hook_callback
|
||||
|
@ -487,6 +489,17 @@ INLINE sint32 MAKE_INT_24(uint value)
|
|||
#define m68ki_rte_callback()
|
||||
#endif /* M68K_RTE_HAS_CALLBACK */
|
||||
|
||||
#if M68K_TAS_HAS_CALLBACK
|
||||
#if M68K_TAS_HAS_CALLBACK == OPT_SPECIFY_HANDLER
|
||||
#define m68ki_tas_callback() M68K_TAS_CALLBACK()
|
||||
#else
|
||||
#define m68ki_tas_callback() CALLBACK_TAS_INSTR()
|
||||
#endif
|
||||
#else
|
||||
#define m68ki_tas_callback()
|
||||
#endif /* M68K_TAS_HAS_CALLBACK */
|
||||
|
||||
|
||||
#if M68K_INSTRUCTION_HOOK
|
||||
#if M68K_INSTRUCTION_HOOK == OPT_SPECIFY_HANDLER
|
||||
#define m68ki_instr_hook() M68K_INSTRUCTION_CALLBACK()
|
||||
|
@ -835,6 +848,12 @@ INLINE sint32 MAKE_INT_24(uint value)
|
|||
/* =============================== PROTOTYPES ============================= */
|
||||
/* ======================================================================== */
|
||||
|
||||
typedef union
|
||||
{
|
||||
UINT64 i;
|
||||
double f;
|
||||
} fp_reg;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint cpu_type; /* CPU Type: 68000, 68008, 68010, 68EC020, or 68020 */
|
||||
|
@ -848,6 +867,10 @@ typedef struct
|
|||
uint cacr; /* Cache Control Register (m68020, unemulated) */
|
||||
uint caar; /* Cache Address Register (m68020, unemulated) */
|
||||
uint ir; /* Instruction Register */
|
||||
fp_reg fpr[8]; /* FPU Data Register (m68040) */
|
||||
uint fpiar; /* FPU Instruction Address Register (m68040) */
|
||||
uint fpsr; /* FPU Status Register (m68040) */
|
||||
uint fpcr; /* FPU Control Register (m68040) */
|
||||
uint t1_flag; /* Trace 1 */
|
||||
uint t0_flag; /* Trace 0 */
|
||||
uint s_flag; /* Supervisor */
|
||||
|
@ -887,20 +910,23 @@ typedef struct
|
|||
void (*reset_instr_callback)(void); /* Called when a RESET instruction is encountered */
|
||||
void (*cmpild_instr_callback)(unsigned int, int); /* Called when a CMPI.L #v, Dn instruction is encountered */
|
||||
void (*rte_instr_callback)(void); /* Called when a RTE instruction is encountered */
|
||||
int (*tas_instr_callback)(void); /* Called when a TAS instruction is encountered, allows / disallows writeback */
|
||||
void (*pc_changed_callback)(unsigned int new_pc); /* Called when the PC changes by a large amount */
|
||||
void (*set_fc_callback)(unsigned int new_fc); /* Called when the CPU function code changes */
|
||||
void (*instr_hook_callback)(void); /* Called every instruction cycle prior to execution */
|
||||
|
||||
// notaz
|
||||
sint cyc_remaining_cycles;
|
||||
} m68ki_cpu_core;
|
||||
|
||||
|
||||
// notaz
|
||||
extern m68ki_cpu_core *m68ki_cpu_p;
|
||||
#define m68ki_cpu (*m68ki_cpu_p) // test
|
||||
|
||||
// extern sint m68ki_remaining_cycles;
|
||||
#define m68ki_cpu (*m68ki_cpu_p)
|
||||
#define m68ki_remaining_cycles m68ki_cpu_p->cyc_remaining_cycles
|
||||
|
||||
|
||||
//extern m68ki_cpu_core m68ki_cpu;
|
||||
//extern sint m68ki_remaining_cycles;
|
||||
extern uint m68ki_tracing;
|
||||
extern uint8 m68ki_shift_8_table[];
|
||||
extern uint16 m68ki_shift_16_table[];
|
||||
|
@ -1936,6 +1962,7 @@ m68k_read_memory_8(0x00ffff01);
|
|||
USE_CYCLES(CYC_EXCEPTION[EXCEPTION_ADDRESS_ERROR] - CYC_INSTRUCTION[REG_IR]);
|
||||
}
|
||||
|
||||
|
||||
/* Service an interrupt request and start exception processing */
|
||||
void m68ki_exception_interrupt(uint int_level)
|
||||
{
|
||||
|
@ -1955,10 +1982,7 @@ void m68ki_exception_interrupt(uint int_level)
|
|||
|
||||
/* If we are halted, don't do anything */
|
||||
if(CPU_STOPPED)
|
||||
{
|
||||
printf("mu stopped! (%x)\n", CPU_STOPPED);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Acknowledge the interrupt */
|
||||
vector = m68ki_int_ack(int_level);
|
||||
|
@ -2015,7 +2039,6 @@ void m68ki_exception_interrupt(uint int_level)
|
|||
/* ASG: Check for interrupts */
|
||||
INLINE void m68ki_check_interrupts(void)
|
||||
{
|
||||
//printf("mu level, mask: %04x %04x\n", CPU_INT_LEVEL, FLAG_INT_MASK);
|
||||
if(CPU_INT_LEVEL > FLAG_INT_MASK)
|
||||
m68ki_exception_interrupt(CPU_INT_LEVEL>>8);
|
||||
}
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
/* ======================================================================== */
|
||||
/*
|
||||
* MUSASHI
|
||||
* Version 3.3
|
||||
* Version 3.31
|
||||
*
|
||||
* A portable Motorola M680x0 processor emulation engine.
|
||||
* Copyright 1998-2001 Karl Stenerud. All rights reserved.
|
||||
* Copyright 1998-2007 Karl Stenerud. All rights reserved.
|
||||
*
|
||||
* This code may be freely used for non-commercial purposes as long as this
|
||||
* copyright notice remains unaltered in the source code and any binary files
|
||||
|
@ -204,9 +204,8 @@ static uint g_cpu_pc; /* program counter */
|
|||
static uint g_cpu_ir; /* instruction register */
|
||||
static uint g_cpu_type;
|
||||
static uint g_opcode_type;
|
||||
static unsigned char* g_rawop;
|
||||
static const unsigned char* g_rawop;
|
||||
static uint g_rawbasepc;
|
||||
static uint g_rawlength;
|
||||
|
||||
/* used by ops like asr, ror, addq, etc */
|
||||
static uint g_3bit_qdata_table[8] = {8, 1, 2, 3, 4, 5, 6, 7};
|
||||
|
@ -252,7 +251,7 @@ static uint dasm_read_imm_8(uint advance)
|
|||
if (g_rawop)
|
||||
result = g_rawop[g_cpu_pc + 1 - g_rawbasepc];
|
||||
else
|
||||
result = m68k_read_disassembler_16(g_cpu_pc & g_address_mask) & 0xff;
|
||||
result = m68k_read_disassembler_16(g_cpu_pc & g_address_mask) & 0xffff; // 0xff ???
|
||||
g_cpu_pc += advance;
|
||||
return result;
|
||||
}
|
||||
|
@ -264,7 +263,7 @@ static uint dasm_read_imm_16(uint advance)
|
|||
result = (g_rawop[g_cpu_pc + 0 - g_rawbasepc] << 8) |
|
||||
g_rawop[g_cpu_pc + 1 - g_rawbasepc];
|
||||
else
|
||||
result = m68k_read_disassembler_16(g_cpu_pc & g_address_mask) & 0xffff; // & 0xff; ??
|
||||
result = m68k_read_disassembler_16(g_cpu_pc & g_address_mask) & 0xffff; // 0xff ???
|
||||
g_cpu_pc += advance;
|
||||
return result;
|
||||
}
|
||||
|
@ -278,7 +277,7 @@ static uint dasm_read_imm_32(uint advance)
|
|||
(g_rawop[g_cpu_pc + 2 - g_rawbasepc] << 8) |
|
||||
g_rawop[g_cpu_pc + 3 - g_rawbasepc];
|
||||
else
|
||||
result = m68k_read_disassembler_32(g_cpu_pc & g_address_mask); // & 0xff; ??
|
||||
result = m68k_read_disassembler_32(g_cpu_pc & g_address_mask) & 0xffff; // 0xff ???
|
||||
g_cpu_pc += advance;
|
||||
return result;
|
||||
}
|
||||
|
@ -1688,6 +1687,124 @@ static void d68020_extb_32(void)
|
|||
sprintf(g_dasm_str, "extb.l D%d; (2+)", g_cpu_ir&7);
|
||||
}
|
||||
|
||||
static void d68040_fpu(void)
|
||||
{
|
||||
char float_data_format[8][3] =
|
||||
{
|
||||
".l", ".s", ".x", ".p", ".w", ".d", ".b", ".?"
|
||||
};
|
||||
|
||||
char mnemonic[40];
|
||||
uint w2, src, dst_reg;
|
||||
LIMIT_CPU_TYPES(M68040_PLUS);
|
||||
w2 = read_imm_16();
|
||||
|
||||
src = (w2 >> 10) & 0x7;
|
||||
dst_reg = (w2 >> 7) & 0x7;
|
||||
|
||||
switch ((w2 >> 13) & 0x7)
|
||||
{
|
||||
case 0x0:
|
||||
case 0x2:
|
||||
{
|
||||
switch(w2 & 0x7f)
|
||||
{
|
||||
case 0x00: sprintf(mnemonic, "fmove"); break;
|
||||
case 0x01: sprintf(mnemonic, "fint"); break;
|
||||
case 0x02: sprintf(mnemonic, "fsinh"); break;
|
||||
case 0x03: sprintf(mnemonic, "fintrz"); break;
|
||||
case 0x04: sprintf(mnemonic, "fsqrt"); break;
|
||||
case 0x06: sprintf(mnemonic, "flognp1"); break;
|
||||
case 0x08: sprintf(mnemonic, "fetoxm1"); break;
|
||||
case 0x09: sprintf(mnemonic, "ftanh1"); break;
|
||||
case 0x0a: sprintf(mnemonic, "fatan"); break;
|
||||
case 0x0c: sprintf(mnemonic, "fasin"); break;
|
||||
case 0x0d: sprintf(mnemonic, "fatanh"); break;
|
||||
case 0x0e: sprintf(mnemonic, "fsin"); break;
|
||||
case 0x0f: sprintf(mnemonic, "ftan"); break;
|
||||
case 0x10: sprintf(mnemonic, "fetox"); break;
|
||||
case 0x11: sprintf(mnemonic, "ftwotox"); break;
|
||||
case 0x12: sprintf(mnemonic, "ftentox"); break;
|
||||
case 0x14: sprintf(mnemonic, "flogn"); break;
|
||||
case 0x15: sprintf(mnemonic, "flog10"); break;
|
||||
case 0x16: sprintf(mnemonic, "flog2"); break;
|
||||
case 0x18: sprintf(mnemonic, "fabs"); break;
|
||||
case 0x19: sprintf(mnemonic, "fcosh"); break;
|
||||
case 0x1a: sprintf(mnemonic, "fneg"); break;
|
||||
case 0x1c: sprintf(mnemonic, "facos"); break;
|
||||
case 0x1d: sprintf(mnemonic, "fcos"); break;
|
||||
case 0x1e: sprintf(mnemonic, "fgetexp"); break;
|
||||
case 0x1f: sprintf(mnemonic, "fgetman"); break;
|
||||
case 0x20: sprintf(mnemonic, "fdiv"); break;
|
||||
case 0x21: sprintf(mnemonic, "fmod"); break;
|
||||
case 0x22: sprintf(mnemonic, "fadd"); break;
|
||||
case 0x23: sprintf(mnemonic, "fmul"); break;
|
||||
case 0x24: sprintf(mnemonic, "fsgldiv"); break;
|
||||
case 0x25: sprintf(mnemonic, "frem"); break;
|
||||
case 0x26: sprintf(mnemonic, "fscale"); break;
|
||||
case 0x27: sprintf(mnemonic, "fsglmul"); break;
|
||||
case 0x28: sprintf(mnemonic, "fsub"); break;
|
||||
case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37:
|
||||
sprintf(mnemonic, "fsincos"); break;
|
||||
case 0x38: sprintf(mnemonic, "fcmp"); break;
|
||||
case 0x3a: sprintf(mnemonic, "ftst"); break;
|
||||
case 0x41: sprintf(mnemonic, "fssqrt"); break;
|
||||
case 0x45: sprintf(mnemonic, "fdsqrt"); break;
|
||||
case 0x58: sprintf(mnemonic, "fsabs"); break;
|
||||
case 0x5a: sprintf(mnemonic, "fsneg"); break;
|
||||
case 0x5c: sprintf(mnemonic, "fdabs"); break;
|
||||
case 0x5e: sprintf(mnemonic, "fdneg"); break;
|
||||
case 0x60: sprintf(mnemonic, "fsdiv"); break;
|
||||
case 0x62: sprintf(mnemonic, "fsadd"); break;
|
||||
case 0x63: sprintf(mnemonic, "fsmul"); break;
|
||||
case 0x64: sprintf(mnemonic, "fddiv"); break;
|
||||
case 0x66: sprintf(mnemonic, "fdadd"); break;
|
||||
case 0x67: sprintf(mnemonic, "fdmul"); break;
|
||||
case 0x68: sprintf(mnemonic, "fssub"); break;
|
||||
case 0x6c: sprintf(mnemonic, "fdsub"); break;
|
||||
|
||||
default: sprintf(mnemonic, "FPU (?)"); break;
|
||||
}
|
||||
|
||||
if (w2 & 0x4000)
|
||||
{
|
||||
sprintf(g_dasm_str, "%s%s %s, FP%d", mnemonic, float_data_format[src], get_ea_mode_str_32(g_cpu_ir), dst_reg);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(g_dasm_str, "%s.x FP%d, FP%d", mnemonic, src, dst_reg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x3:
|
||||
{
|
||||
sprintf(g_dasm_str, "fmove /todo");
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x4:
|
||||
case 0x5:
|
||||
{
|
||||
sprintf(g_dasm_str, "fmove /todo");
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x6:
|
||||
case 0x7:
|
||||
{
|
||||
sprintf(g_dasm_str, "fmovem /todo");
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
sprintf(g_dasm_str, "FPU (?) ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void d68000_jmp(void)
|
||||
{
|
||||
sprintf(g_dasm_str, "jmp %s", get_ea_mode_str_32(g_cpu_ir));
|
||||
|
@ -1923,7 +2040,7 @@ static void d68010_movec(void)
|
|||
processor = "?";
|
||||
}
|
||||
|
||||
if(BIT_1(g_cpu_ir))
|
||||
if(BIT_0(g_cpu_ir))
|
||||
sprintf(g_dasm_str, "movec %c%d, %s; (%s)", BIT_F(extension) ? 'A' : 'D', (extension>>12)&7, reg_name, processor);
|
||||
else
|
||||
sprintf(g_dasm_str, "movec %s, %c%d; (%s)", reg_name, BIT_F(extension) ? 'A' : 'D', (extension>>12)&7, processor);
|
||||
|
@ -3073,6 +3190,7 @@ static opcode_struct g_opcode_info[] =
|
|||
{d68020_extb_32 , 0xfff8, 0x49c0, 0x000},
|
||||
{d68000_ext_16 , 0xfff8, 0x4880, 0x000},
|
||||
{d68000_ext_32 , 0xfff8, 0x48c0, 0x000},
|
||||
{d68040_fpu , 0xffc0, 0xf200, 0x000},
|
||||
{d68000_illegal , 0xffff, 0x4afc, 0x000},
|
||||
{d68000_jmp , 0xffc0, 0x4ec0, 0x27b},
|
||||
{d68000_jsr , 0xffc0, 0x4e80, 0x27b},
|
||||
|
@ -3405,13 +3523,12 @@ char* m68ki_disassemble_quick(unsigned int pc, unsigned int cpu_type)
|
|||
return buff;
|
||||
}
|
||||
|
||||
unsigned int m68k_disassemble_raw(char* str_buff, unsigned int pc, unsigned char* opdata, unsigned char* argdata, int length, unsigned int cpu_type)
|
||||
unsigned int m68k_disassemble_raw(char* str_buff, unsigned int pc, const unsigned char* opdata, const unsigned char* argdata, unsigned int cpu_type)
|
||||
{
|
||||
unsigned int result;
|
||||
|
||||
g_rawop = opdata;
|
||||
g_rawbasepc = pc;
|
||||
g_rawlength = length;
|
||||
result = m68k_disassemble(str_buff, pc, cpu_type);
|
||||
g_rawop = NULL;
|
||||
return result;
|
||||
|
@ -3588,6 +3705,27 @@ unsigned int m68k_is_valid_instruction(unsigned int instruction, unsigned int cp
|
|||
return 0;
|
||||
if(g_instruction_table[instruction] == d68040_pflush)
|
||||
return 0;
|
||||
case M68K_CPU_TYPE_68040:
|
||||
if(g_instruction_table[instruction] == d68020_cpbcc_16)
|
||||
return 0;
|
||||
if(g_instruction_table[instruction] == d68020_cpbcc_32)
|
||||
return 0;
|
||||
if(g_instruction_table[instruction] == d68020_cpdbcc)
|
||||
return 0;
|
||||
if(g_instruction_table[instruction] == d68020_cpgen)
|
||||
return 0;
|
||||
if(g_instruction_table[instruction] == d68020_cprestore)
|
||||
return 0;
|
||||
if(g_instruction_table[instruction] == d68020_cpsave)
|
||||
return 0;
|
||||
if(g_instruction_table[instruction] == d68020_cpscc)
|
||||
return 0;
|
||||
if(g_instruction_table[instruction] == d68020_cptrapcc_0)
|
||||
return 0;
|
||||
if(g_instruction_table[instruction] == d68020_cptrapcc_16)
|
||||
return 0;
|
||||
if(g_instruction_table[instruction] == d68020_cptrapcc_32)
|
||||
return 0;
|
||||
}
|
||||
if(cpu_type != M68K_CPU_TYPE_68020 && cpu_type != M68K_CPU_TYPE_68EC020 &&
|
||||
(g_instruction_table[instruction] == d68020_callm ||
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
/* ======================================================================== */
|
||||
/*
|
||||
* MUSASHI
|
||||
* Version 3.3
|
||||
* Version 3.31
|
||||
*
|
||||
* A portable Motorola M680x0 processor emulation engine.
|
||||
* Copyright 1998-2001 Karl Stenerud. All rights reserved.
|
||||
* Copyright 1998-2007 Karl Stenerud. All rights reserved.
|
||||
*
|
||||
* This code may be freely used for non-commercial purposes as long as this
|
||||
* copyright notice remains unaltered in the source code and any binary files
|
||||
|
@ -52,7 +52,7 @@
|
|||
*/
|
||||
|
||||
|
||||
const char* g_version = "3.3";
|
||||
static const char* g_version = "3.31";
|
||||
|
||||
/* ======================================================================== */
|
||||
/* =============================== INCLUDES =============================== */
|
||||
|
@ -88,9 +88,6 @@ const char* g_version = "3.3";
|
|||
#define FILENAME_INPUT "m68k_in.c"
|
||||
#define FILENAME_PROTOTYPE "m68kops.h"
|
||||
#define FILENAME_TABLE "m68kops.c"
|
||||
#define FILENAME_OPS_AC "m68kopac.c"
|
||||
#define FILENAME_OPS_DM "m68kopdm.c"
|
||||
#define FILENAME_OPS_NZ "m68kopnz.c"
|
||||
|
||||
|
||||
/* Identifier sequences recognized by this program */
|
||||
|
@ -240,7 +237,7 @@ void set_opcode_struct(opcode_struct* src, opcode_struct* dst, int ea_mode);
|
|||
void generate_opcode_handler(FILE* filep, body_struct* body, replace_struct* replace, opcode_struct* opinfo, int ea_mode);
|
||||
void generate_opcode_ea_variants(FILE* filep, body_struct* body, replace_struct* replace, opcode_struct* op);
|
||||
void generate_opcode_cc_variants(FILE* filep, body_struct* body, replace_struct* replace, opcode_struct* op_in, int offset);
|
||||
void process_opcode_handlers(void);
|
||||
void process_opcode_handlers(FILE* filep);
|
||||
void populate_table(void);
|
||||
void read_insert(char* insert);
|
||||
|
||||
|
@ -257,9 +254,6 @@ char g_input_filename[M68K_MAX_PATH] = FILENAME_INPUT;
|
|||
FILE* g_input_file = NULL;
|
||||
FILE* g_prototype_file = NULL;
|
||||
FILE* g_table_file = NULL;
|
||||
FILE* g_ops_ac_file = NULL;
|
||||
FILE* g_ops_dm_file = NULL;
|
||||
FILE* g_ops_nz_file = NULL;
|
||||
|
||||
int g_num_functions = 0; /* Number of functions processed */
|
||||
int g_num_primitives = 0; /* Number of function primitives read */
|
||||
|
@ -481,9 +475,6 @@ void error_exit(const char* fmt, ...)
|
|||
|
||||
if(g_prototype_file) fclose(g_prototype_file);
|
||||
if(g_table_file) fclose(g_table_file);
|
||||
if(g_ops_ac_file) fclose(g_ops_ac_file);
|
||||
if(g_ops_dm_file) fclose(g_ops_dm_file);
|
||||
if(g_ops_nz_file) fclose(g_ops_nz_file);
|
||||
if(g_input_file) fclose(g_input_file);
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -500,9 +491,6 @@ void perror_exit(const char* fmt, ...)
|
|||
|
||||
if(g_prototype_file) fclose(g_prototype_file);
|
||||
if(g_table_file) fclose(g_table_file);
|
||||
if(g_ops_ac_file) fclose(g_ops_ac_file);
|
||||
if(g_ops_dm_file) fclose(g_ops_dm_file);
|
||||
if(g_ops_nz_file) fclose(g_ops_nz_file);
|
||||
if(g_input_file) fclose(g_input_file);
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -1001,10 +989,9 @@ void generate_opcode_cc_variants(FILE* filep, body_struct* body, replace_struct*
|
|||
}
|
||||
|
||||
/* Process the opcode handlers section of the input file */
|
||||
void process_opcode_handlers(void)
|
||||
void process_opcode_handlers(FILE* filep)
|
||||
{
|
||||
FILE* input_file = g_input_file;
|
||||
FILE* output_file;
|
||||
char func_name[MAX_LINE_LENGTH+1];
|
||||
char oper_name[MAX_LINE_LENGTH+1];
|
||||
int oper_size;
|
||||
|
@ -1014,9 +1001,6 @@ void process_opcode_handlers(void)
|
|||
replace_struct* replace = malloc(sizeof(replace_struct));
|
||||
body_struct* body = malloc(sizeof(body_struct));
|
||||
|
||||
|
||||
output_file = g_ops_ac_file;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
/* Find the first line of the function */
|
||||
|
@ -1059,23 +1043,17 @@ void process_opcode_handlers(void)
|
|||
if(opinfo == NULL)
|
||||
error_exit("Unable to find matching table entry for %s", func_name);
|
||||
|
||||
/* Change output files if we pass 'c' or 'n' */
|
||||
if(output_file == g_ops_ac_file && oper_name[0] > 'c')
|
||||
output_file = g_ops_dm_file;
|
||||
else if(output_file == g_ops_dm_file && oper_name[0] > 'm')
|
||||
output_file = g_ops_nz_file;
|
||||
|
||||
replace->length = 0;
|
||||
|
||||
/* Generate opcode variants */
|
||||
if(strcmp(opinfo->name, "bcc") == 0 || strcmp(opinfo->name, "scc") == 0)
|
||||
generate_opcode_cc_variants(output_file, body, replace, opinfo, 1);
|
||||
generate_opcode_cc_variants(filep, body, replace, opinfo, 1);
|
||||
else if(strcmp(opinfo->name, "dbcc") == 0)
|
||||
generate_opcode_cc_variants(output_file, body, replace, opinfo, 2);
|
||||
generate_opcode_cc_variants(filep, body, replace, opinfo, 2);
|
||||
else if(strcmp(opinfo->name, "trapcc") == 0)
|
||||
generate_opcode_cc_variants(output_file, body, replace, opinfo, 4);
|
||||
generate_opcode_cc_variants(filep, body, replace, opinfo, 4);
|
||||
else
|
||||
generate_opcode_ea_variants(output_file, body, replace, opinfo);
|
||||
generate_opcode_ea_variants(filep, body, replace, opinfo);
|
||||
}
|
||||
|
||||
free(replace);
|
||||
|
@ -1248,7 +1226,9 @@ int main(int argc, char **argv)
|
|||
/* Inserts */
|
||||
char temp_insert[MAX_INSERT_LENGTH+1];
|
||||
char prototype_footer_insert[MAX_INSERT_LENGTH+1];
|
||||
char table_header_insert[MAX_INSERT_LENGTH+1];
|
||||
char table_footer_insert[MAX_INSERT_LENGTH+1];
|
||||
char ophandler_header_insert[MAX_INSERT_LENGTH+1];
|
||||
char ophandler_footer_insert[MAX_INSERT_LENGTH+1];
|
||||
/* Flags if we've processed certain parts already */
|
||||
int prototype_header_read = 0;
|
||||
|
@ -1260,8 +1240,8 @@ int main(int argc, char **argv)
|
|||
int table_body_read = 0;
|
||||
int ophandler_body_read = 0;
|
||||
|
||||
printf("\n\t\tMusashi v%s 68000, 68008, 68010, 68EC020, 68020 emulator\n", g_version);
|
||||
printf("\t\tCopyright 1998-2000 Karl Stenerud (karl@mame.net)\n\n");
|
||||
printf("\n\tMusashi v%s 68000, 68008, 68010, 68EC020, 68020, 68040 emulator\n", g_version);
|
||||
printf("\tCopyright 1998-2007 Karl Stenerud (karl@mame.net)\n\n");
|
||||
|
||||
/* Check if output path and source for the input file are given */
|
||||
if(argc > 1)
|
||||
|
@ -1293,18 +1273,6 @@ int main(int argc, char **argv)
|
|||
if((g_table_file = fopen(filename, "w")) == NULL)
|
||||
perror_exit("Unable to create table file (%s)\n", filename);
|
||||
|
||||
sprintf(filename, "%s%s", output_path, FILENAME_OPS_AC);
|
||||
if((g_ops_ac_file = fopen(filename, "w")) == NULL)
|
||||
perror_exit("Unable to create ops ac file (%s)\n", filename);
|
||||
|
||||
sprintf(filename, "%s%s", output_path, FILENAME_OPS_DM);
|
||||
if((g_ops_dm_file = fopen(filename, "w")) == NULL)
|
||||
perror_exit("Unable to create ops dm file (%s)\n", filename);
|
||||
|
||||
sprintf(filename, "%s%s", output_path, FILENAME_OPS_NZ);
|
||||
if((g_ops_nz_file = fopen(filename, "w")) == NULL)
|
||||
perror_exit("Unable to create ops nz file (%s)\n", filename);
|
||||
|
||||
if((g_input_file=fopen(g_input_filename, "r")) == NULL)
|
||||
perror_exit("can't open %s for input", g_input_filename);
|
||||
|
||||
|
@ -1320,18 +1288,6 @@ int main(int argc, char **argv)
|
|||
if((g_table_file = fopen(filename, "wt")) == NULL)
|
||||
perror_exit("Unable to create table file (%s)\n", filename);
|
||||
|
||||
sprintf(filename, "%s%s", output_path, FILENAME_OPS_AC);
|
||||
if((g_ops_ac_file = fopen(filename, "wt")) == NULL)
|
||||
perror_exit("Unable to create ops ac file (%s)\n", filename);
|
||||
|
||||
sprintf(filename, "%s%s", output_path, FILENAME_OPS_DM);
|
||||
if((g_ops_dm_file = fopen(filename, "wt")) == NULL)
|
||||
perror_exit("Unable to create ops dm file (%s)\n", filename);
|
||||
|
||||
sprintf(filename, "%s%s", output_path, FILENAME_OPS_NZ);
|
||||
if((g_ops_nz_file = fopen(filename, "wt")) == NULL)
|
||||
perror_exit("Unable to create ops nz file (%s)\n", filename);
|
||||
|
||||
if((g_input_file=fopen(g_input_filename, "rt")) == NULL)
|
||||
perror_exit("can't open %s for input", g_input_filename);
|
||||
|
||||
|
@ -1360,18 +1316,14 @@ int main(int argc, char **argv)
|
|||
{
|
||||
if(table_header_read)
|
||||
error_exit("Duplicate table header");
|
||||
read_insert(temp_insert);
|
||||
fprintf(g_table_file, "%s", temp_insert);
|
||||
read_insert(table_header_insert);
|
||||
table_header_read = 1;
|
||||
}
|
||||
else if(strcmp(section_id, ID_OPHANDLER_HEADER) == 0)
|
||||
{
|
||||
if(ophandler_header_read)
|
||||
error_exit("Duplicate opcode handler header");
|
||||
read_insert(temp_insert);
|
||||
fprintf(g_ops_ac_file, "%s\n\n", temp_insert);
|
||||
fprintf(g_ops_dm_file, "%s\n\n", temp_insert);
|
||||
fprintf(g_ops_nz_file, "%s\n\n", temp_insert);
|
||||
read_insert(ophandler_header_insert);
|
||||
ophandler_header_read = 1;
|
||||
}
|
||||
else if(strcmp(section_id, ID_PROTOTYPE_FOOTER) == 0)
|
||||
|
@ -1424,7 +1376,9 @@ int main(int argc, char **argv)
|
|||
if(ophandler_body_read)
|
||||
error_exit("Duplicate opcode handler section");
|
||||
|
||||
process_opcode_handlers();
|
||||
fprintf(g_table_file, "%s\n\n", ophandler_header_insert);
|
||||
process_opcode_handlers(g_table_file);
|
||||
fprintf(g_table_file, "%s\n\n", ophandler_footer_insert);
|
||||
|
||||
ophandler_body_read = 1;
|
||||
}
|
||||
|
@ -1448,13 +1402,11 @@ int main(int argc, char **argv)
|
|||
if(!ophandler_body_read)
|
||||
error_exit("Missing opcode handler body");
|
||||
|
||||
fprintf(g_table_file, "%s\n\n", table_header_insert);
|
||||
print_opcode_output_table(g_table_file);
|
||||
fprintf(g_table_file, "%s\n\n", table_footer_insert);
|
||||
|
||||
fprintf(g_prototype_file, "%s\n\n", prototype_footer_insert);
|
||||
fprintf(g_table_file, "%s\n\n", table_footer_insert);
|
||||
fprintf(g_ops_ac_file, "%s\n\n", ophandler_footer_insert);
|
||||
fprintf(g_ops_dm_file, "%s\n\n", ophandler_footer_insert);
|
||||
fprintf(g_ops_nz_file, "%s\n\n", ophandler_footer_insert);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -1467,9 +1419,6 @@ int main(int argc, char **argv)
|
|||
/* Close all files and exit */
|
||||
fclose(g_prototype_file);
|
||||
fclose(g_table_file);
|
||||
fclose(g_ops_ac_file);
|
||||
fclose(g_ops_dm_file);
|
||||
fclose(g_ops_nz_file);
|
||||
fclose(g_input_file);
|
||||
|
||||
printf("Generated %d opcode handlers from %d primitives\n", g_num_functions, g_num_primitives);
|
||||
|
|
12199
cpu/musashi/m68kopac.c
12199
cpu/musashi/m68kopac.c
File diff suppressed because it is too large
Load diff
13385
cpu/musashi/m68kopdm.c
13385
cpu/musashi/m68kopdm.c
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue