mirror of
https://github.com/holub/mame
synced 2025-07-04 01:18:59 +03:00
clipper: Scope down enums (nw)
This commit is contained in:
parent
d37b6d9b4f
commit
0f510928f8
@ -7,8 +7,38 @@
|
|||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
enum clipper_registers
|
// convenience macros for frequently used instruction fields
|
||||||
|
#define R1 (m_info.r1)
|
||||||
|
#define R2 (m_info.r2)
|
||||||
|
|
||||||
|
// convenience macros for dealing with the psw
|
||||||
|
#define PSW(mask) (m_psw & PSW_##mask)
|
||||||
|
#define SSW(mask) (m_ssw & SSW_##mask)
|
||||||
|
|
||||||
|
// macros for setting psw condition codes
|
||||||
|
#define FLAGS(C,V,Z,N) \
|
||||||
|
m_psw = (m_psw & ~(PSW_C | PSW_V | PSW_Z | PSW_N)) | (((C) << 3) | ((V) << 2) | ((Z) << 1) | ((N) << 0));
|
||||||
|
#define FLAGS_CV(C,V) \
|
||||||
|
m_psw = (m_psw & ~(PSW_C | PSW_V)) | (((C) << 3) | ((V) << 2));
|
||||||
|
#define FLAGS_ZN(Z,N) \
|
||||||
|
m_psw = (m_psw & ~(PSW_Z | PSW_N)) | (((Z) << 1) | ((N) << 0));
|
||||||
|
|
||||||
|
// over/underflow for addition/subtraction from here: http://stackoverflow.com/questions/199333/how-to-detect-integer-overflow-in-c-c
|
||||||
|
#define OF_ADD(a, b) ((b > 0) && (a > INT_MAX - b))
|
||||||
|
#define UF_ADD(a, b) ((b < 0) && (a < INT_MIN - b))
|
||||||
|
#define OF_SUB(a, b) ((b < 0) && (a > INT_MAX + b))
|
||||||
|
#define UF_SUB(a, b) ((b > 0) && (a < INT_MIN + b))
|
||||||
|
|
||||||
|
// CLIPPER logic for carry and overflow flags
|
||||||
|
#define C_ADD(a, b) ((u32)a + (u32)b < (u32)a)
|
||||||
|
#define V_ADD(a, b) (OF_ADD((s32)a, (s32)b) || UF_ADD((s32)a, (s32)b))
|
||||||
|
#define C_SUB(a, b) ((u32)a < (u32)b)
|
||||||
|
#define V_SUB(a, b) (OF_SUB((s32)a, (s32)b) || UF_SUB((s32)a, (s32)b))
|
||||||
|
|
||||||
|
class clipper_device : public cpu_device
|
||||||
{
|
{
|
||||||
|
enum registers
|
||||||
|
{
|
||||||
CLIPPER_R0, CLIPPER_R1, CLIPPER_R2, CLIPPER_R3, CLIPPER_R4, CLIPPER_R5, CLIPPER_R6, CLIPPER_R7,
|
CLIPPER_R0, CLIPPER_R1, CLIPPER_R2, CLIPPER_R3, CLIPPER_R4, CLIPPER_R5, CLIPPER_R6, CLIPPER_R7,
|
||||||
CLIPPER_R8, CLIPPER_R9, CLIPPER_R10, CLIPPER_R11, CLIPPER_R12, CLIPPER_R13, CLIPPER_R14, CLIPPER_R15,
|
CLIPPER_R8, CLIPPER_R9, CLIPPER_R10, CLIPPER_R11, CLIPPER_R12, CLIPPER_R13, CLIPPER_R14, CLIPPER_R15,
|
||||||
|
|
||||||
@ -18,10 +48,10 @@ enum clipper_registers
|
|||||||
CLIPPER_PSW,
|
CLIPPER_PSW,
|
||||||
CLIPPER_SSW,
|
CLIPPER_SSW,
|
||||||
CLIPPER_PC,
|
CLIPPER_PC,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum clipper_addressing_modes
|
enum addressing_modes
|
||||||
{
|
{
|
||||||
ADDR_MODE_PC32 = 0x10,
|
ADDR_MODE_PC32 = 0x10,
|
||||||
ADDR_MODE_ABS32 = 0x30,
|
ADDR_MODE_ABS32 = 0x30,
|
||||||
ADDR_MODE_REL32 = 0x60,
|
ADDR_MODE_REL32 = 0x60,
|
||||||
@ -30,11 +60,11 @@ enum clipper_addressing_modes
|
|||||||
ADDR_MODE_ABS16 = 0xb0,
|
ADDR_MODE_ABS16 = 0xb0,
|
||||||
ADDR_MODE_PCX = 0xd0,
|
ADDR_MODE_PCX = 0xd0,
|
||||||
ADDR_MODE_RELX = 0xe0,
|
ADDR_MODE_RELX = 0xe0,
|
||||||
};
|
};
|
||||||
|
|
||||||
// branch conditions
|
// branch conditions
|
||||||
enum clipper_branch_conditions
|
enum branch_conditions
|
||||||
{
|
{
|
||||||
BRANCH_T = 0x0,
|
BRANCH_T = 0x0,
|
||||||
BRANCH_LT = 0x1,
|
BRANCH_LT = 0x1,
|
||||||
BRANCH_LE = 0x2,
|
BRANCH_LE = 0x2,
|
||||||
@ -51,10 +81,10 @@ enum clipper_branch_conditions
|
|||||||
BRANCH_N = 0xd,
|
BRANCH_N = 0xd,
|
||||||
BRANCH_NN = 0xe,
|
BRANCH_NN = 0xe,
|
||||||
BRANCH_FN = 0xf,
|
BRANCH_FN = 0xf,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum clipper_psw
|
enum psw
|
||||||
{
|
{
|
||||||
PSW_N = 0x00000001, // negative
|
PSW_N = 0x00000001, // negative
|
||||||
PSW_Z = 0x00000002, // zero
|
PSW_Z = 0x00000002, // zero
|
||||||
PSW_V = 0x00000004, // overflow
|
PSW_V = 0x00000004, // overflow
|
||||||
@ -77,10 +107,10 @@ enum clipper_psw
|
|||||||
PSW_T = 0x00800000, // trace trap
|
PSW_T = 0x00800000, // trace trap
|
||||||
PSW_CTS = 0x0f000000, // cpu trap status (4 bits)
|
PSW_CTS = 0x0f000000, // cpu trap status (4 bits)
|
||||||
PSW_MTS = 0xf0000000, // memory trap status (4 bits)
|
PSW_MTS = 0xf0000000, // memory trap status (4 bits)
|
||||||
};
|
};
|
||||||
|
|
||||||
enum clipper_ssw
|
enum clipper_ssw
|
||||||
{
|
{
|
||||||
SSW_IN = 0x0000000f, // interrupt number (4 bits)
|
SSW_IN = 0x0000000f, // interrupt number (4 bits)
|
||||||
SSW_IL = 0x000000f0, // interrupt level (4 bits)
|
SSW_IL = 0x000000f0, // interrupt level (4 bits)
|
||||||
SSW_EI = 0x00000100, // enable interrupts
|
SSW_EI = 0x00000100, // enable interrupts
|
||||||
@ -96,10 +126,10 @@ enum clipper_ssw
|
|||||||
SSW_K = 0x20000000, // protect key
|
SSW_K = 0x20000000, // protect key
|
||||||
SSW_U = 0x40000000, // user mode
|
SSW_U = 0x40000000, // user mode
|
||||||
SSW_P = 0x80000000, // previous mode
|
SSW_P = 0x80000000, // previous mode
|
||||||
};
|
};
|
||||||
|
|
||||||
enum clipper_exception_vectors
|
enum exception_vectors
|
||||||
{
|
{
|
||||||
// data memory trap group
|
// data memory trap group
|
||||||
EXCEPTION_D_CORRECTED_MEMORY_ERROR = 0x108,
|
EXCEPTION_D_CORRECTED_MEMORY_ERROR = 0x108,
|
||||||
EXCEPTION_D_UNCORRECTABLE_MEMORY_ERROR = 0x110,
|
EXCEPTION_D_UNCORRECTABLE_MEMORY_ERROR = 0x110,
|
||||||
@ -137,20 +167,20 @@ enum clipper_exception_vectors
|
|||||||
|
|
||||||
// prioritized interrupts (0x800-0xff8)
|
// prioritized interrupts (0x800-0xff8)
|
||||||
EXCEPTION_INTERRUPT_BASE = 0x800,
|
EXCEPTION_INTERRUPT_BASE = 0x800,
|
||||||
};
|
};
|
||||||
|
|
||||||
// trap source values are shifted into the correct field in the psw
|
// trap source values are shifted into the correct field in the psw
|
||||||
enum clipper_cpu_trap_sources
|
enum cpu_trap_sources
|
||||||
{
|
{
|
||||||
CTS_NO_CPU_TRAP = 0 << 24,
|
CTS_NO_CPU_TRAP = 0 << 24,
|
||||||
CTS_DIVIDE_BY_ZERO = 2 << 24,
|
CTS_DIVIDE_BY_ZERO = 2 << 24,
|
||||||
CTS_ILLEGAL_OPERATION = 4 << 24,
|
CTS_ILLEGAL_OPERATION = 4 << 24,
|
||||||
CTS_PRIVILEGED_INSTRUCTION = 5 << 24,
|
CTS_PRIVILEGED_INSTRUCTION = 5 << 24,
|
||||||
CTS_TRACE_TRAP = 7 << 24,
|
CTS_TRACE_TRAP = 7 << 24,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum clipper_memory_trap_sources
|
enum memory_trap_sources
|
||||||
{
|
{
|
||||||
MTS_NO_MEMORY_TRAP = 0 << 28,
|
MTS_NO_MEMORY_TRAP = 0 << 28,
|
||||||
MTS_CORRECTED_MEMORY_ERROR = 1 << 28,
|
MTS_CORRECTED_MEMORY_ERROR = 1 << 28,
|
||||||
MTS_UNCORRECTABLE_MEMORY_ERROR = 2 << 28,
|
MTS_UNCORRECTABLE_MEMORY_ERROR = 2 << 28,
|
||||||
@ -158,38 +188,8 @@ enum clipper_memory_trap_sources
|
|||||||
MTS_PAGE_FAULT = 5 << 28,
|
MTS_PAGE_FAULT = 5 << 28,
|
||||||
MTS_READ_OR_EXECUTE_PROTECT_FAULT = 6 << 28,
|
MTS_READ_OR_EXECUTE_PROTECT_FAULT = 6 << 28,
|
||||||
MTS_WRITE_PROTECT_FAULT = 7 << 28,
|
MTS_WRITE_PROTECT_FAULT = 7 << 28,
|
||||||
};
|
};
|
||||||
|
|
||||||
// convenience macros for frequently used instruction fields
|
|
||||||
#define R1 (m_info.r1)
|
|
||||||
#define R2 (m_info.r2)
|
|
||||||
|
|
||||||
// convenience macros for dealing with the psw
|
|
||||||
#define PSW(mask) (m_psw & PSW_##mask)
|
|
||||||
#define SSW(mask) (m_ssw & SSW_##mask)
|
|
||||||
|
|
||||||
// macros for setting psw condition codes
|
|
||||||
#define FLAGS(C,V,Z,N) \
|
|
||||||
m_psw = (m_psw & ~(PSW_C | PSW_V | PSW_Z | PSW_N)) | (((C) << 3) | ((V) << 2) | ((Z) << 1) | ((N) << 0));
|
|
||||||
#define FLAGS_CV(C,V) \
|
|
||||||
m_psw = (m_psw & ~(PSW_C | PSW_V)) | (((C) << 3) | ((V) << 2));
|
|
||||||
#define FLAGS_ZN(Z,N) \
|
|
||||||
m_psw = (m_psw & ~(PSW_Z | PSW_N)) | (((Z) << 1) | ((N) << 0));
|
|
||||||
|
|
||||||
// over/underflow for addition/subtraction from here: http://stackoverflow.com/questions/199333/how-to-detect-integer-overflow-in-c-c
|
|
||||||
#define OF_ADD(a, b) ((b > 0) && (a > INT_MAX - b))
|
|
||||||
#define UF_ADD(a, b) ((b < 0) && (a < INT_MIN - b))
|
|
||||||
#define OF_SUB(a, b) ((b < 0) && (a > INT_MAX + b))
|
|
||||||
#define UF_SUB(a, b) ((b > 0) && (a < INT_MIN + b))
|
|
||||||
|
|
||||||
// CLIPPER logic for carry and overflow flags
|
|
||||||
#define C_ADD(a, b) ((u32)a + (u32)b < (u32)a)
|
|
||||||
#define V_ADD(a, b) (OF_ADD((s32)a, (s32)b) || UF_ADD((s32)a, (s32)b))
|
|
||||||
#define C_SUB(a, b) ((u32)a < (u32)b)
|
|
||||||
#define V_SUB(a, b) (OF_SUB((s32)a, (s32)b) || UF_SUB((s32)a, (s32)b))
|
|
||||||
|
|
||||||
class clipper_device : public cpu_device
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
clipper_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, u32 clock, const char *shortname, const char *source);
|
clipper_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, u32 clock, const char *shortname, const char *source);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user