48
48
#define GET_PC (cpustate->ADDR[cpustate->pc_pos])
50
50
/***************************************************************************
52
***************************************************************************/
54
#define I4004_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \
55
CPU_STATE_ENTRY(I4004_##_name, #_name, _format, i4004_state, _member, _datamask, ~0, _flags)
57
static const cpu_state_entry state_array[] =
59
I4004_STATE_ENTRY(PC, "%03X", PC.w.l, 0x0fff, 0)
60
I4004_STATE_ENTRY(GENPC,"%03X", PC.w.l, 0x0fff, CPUSTATE_NOSHOW)
61
I4004_STATE_ENTRY(A, "%01X", A, 0x0f, 0)
62
I4004_STATE_ENTRY(R01, "%02X", R[0], 0xff, 0)
63
I4004_STATE_ENTRY(R23, "%02X", R[1], 0xff, 0)
64
I4004_STATE_ENTRY(R45, "%02X", R[2], 0xff, 0)
65
I4004_STATE_ENTRY(R67, "%02X", R[3], 0xff, 0)
66
I4004_STATE_ENTRY(R89, "%02X", R[4], 0xff, 0)
67
I4004_STATE_ENTRY(RAB, "%02X", R[5], 0xff, 0)
68
I4004_STATE_ENTRY(RCD, "%02X", R[6], 0xff, 0)
69
I4004_STATE_ENTRY(REF, "%02X", R[7], 0xff, 0)
70
I4004_STATE_ENTRY(ADDR1, "%03X", ADDR[0].w.l, 0x0fff, 0)
71
I4004_STATE_ENTRY(ADDR2, "%03X", ADDR[1].w.l, 0x0fff, 0)
72
I4004_STATE_ENTRY(ADDR3, "%03X", ADDR[2].w.l, 0x0fff, 0)
73
I4004_STATE_ENTRY(ADDR4, "%03X", ADDR[3].w.l, 0x0fff, 0)
74
I4004_STATE_ENTRY(RAM, "%03X", RAM.w.l, 0x0fff, 0)
77
static const cpu_state_table state_table_template =
79
NULL, /* pointer to the base of state (offsets are relative to this) */
80
0, /* subtype this table refers to */
81
ARRAY_LENGTH(state_array), /* number of entries */
82
state_array /* array of entries */
85
/***************************************************************************
87
52
***************************************************************************/
89
54
INLINE i4004_state *get_safe_token(running_device *device)
91
56
assert(device != NULL);
92
assert(device->token != NULL);
93
assert(device->type == CPU);
94
assert(cpu_get_type(device) == CPU_I4004);
95
return (i4004_state *)device->token;
57
assert(device->type() == I4004);
58
return (i4004_state *)downcast<legacy_cpu_device *>(device)->token();
98
61
INLINE UINT8 ROP(i4004_state *cpustate)
484
442
i4004_state *cpustate = get_safe_token(device);
486
444
/* set up the state table */
487
cpustate->state = state_table_template;
488
cpustate->state.baseptr = cpustate;
489
cpustate->state.subtypemask = 1;
446
device_state_interface *state;
447
device->interface(state);
448
state->state_add(I4004_PC, "PC", cpustate->PC.w.l).mask(0x0fff);
449
state->state_add(STATE_GENPC, "GENPC", cpustate->PC.w.l).mask(0x0fff).noshow();
450
state->state_add(STATE_GENFLAGS, "GENFLAGS", cpustate->flags).mask(0x0f).callimport().callexport().noshow().formatstr("%4s");
451
state->state_add(I4004_A, "A", cpustate->A).mask(0x0f);
454
for (int regnum = 0; regnum < 8; regnum++)
455
state->state_add(I4004_R01 + regnum, tempstr.format("R%X%X", regnum*2, regnum*2+1), cpustate->R[regnum]);
457
for (int addrnum = 0; addrnum < 4; addrnum++)
458
state->state_add(I4004_ADDR1 + addrnum, tempstr.format("ADDR%d", addrnum + 1), cpustate->ADDR[addrnum].w.l).mask(0xfff);
460
state->state_add(I4004_RAM, "RAM", cpustate->RAM.w.l).mask(0x0fff);
491
463
cpustate->device = device;
544
516
static CPU_IMPORT_STATE( i4004 )
518
i4004_state *cpustate = get_safe_token(device);
520
switch (entry.index())
523
cpustate->C = (cpustate->flags >> 1) & 1;
524
cpustate->TEST = (cpustate->flags >> 0) & 1;
548
529
static CPU_EXPORT_STATE( i4004 )
531
i4004_state *cpustate = get_safe_token(device);
533
switch (entry.index())
536
cpustate->flags = ((cpustate->A == 0) ? 0x04 : 0x00) |
537
(cpustate->C ? 0x02 : 0x00) |
538
(cpustate->TEST ? 0x01 : 0x00);
543
static CPU_EXPORT_STRING( i4004 )
545
i4004_state *cpustate = get_safe_token(device);
547
switch (entry.index())
550
string.printf(".%c%c%c",
551
(cpustate->A==0) ? 'Z':'.',
552
cpustate->C ? 'C':'.',
553
cpustate->TEST ? 'T':'.');
552
558
/***************************************************************************