Skip to content

Commit

Permalink
cpu/kl1839vm1.cpp: Updated save state
Browse files Browse the repository at this point in the history
  • Loading branch information
holub committed Jan 31, 2025
1 parent 0df543d commit 7bd9ea4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 28 deletions.
38 changes: 25 additions & 13 deletions src/devices/cpu/mpk1839/kl1839vm1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ void kl1839vm1_device::vax_decode_pc()
m_op_size = 1;
AMC = op << 4;

m_pcm_queue.clear();
std::vector<u32> tmp_args;
const vax_disassembler::mode* args = vax_disassembler::get_operands(op);
u8 arg_n = 0;
do
Expand All @@ -686,7 +686,7 @@ void kl1839vm1_device::vax_decode_pc()

// byte
case vax_disassembler::mode::bb:
m_pcm_queue.push_back(s8(m_ram.read_byte(PC + m_op_size)));
tmp_args.push_back(s8(m_ram.read_byte(PC + m_op_size)));
m_mem_reg[arg_n] = 0x8f;
m_op_size += 1;
break;
Expand All @@ -700,19 +700,19 @@ void kl1839vm1_device::vax_decode_pc()
u8 p = m_ram.read_byte(PC + m_op_size);
if (p == 0x8f) // M
{
m_pcm_queue.push_back(m_ram.read_byte(PC + m_op_size + 1));
tmp_args.push_back(m_ram.read_byte(PC + m_op_size + 1));
m_mem_reg[arg_n] = p;
m_op_size += 2;
}
else if ((p & 0xf0) == 0x80) // M = R(n)+
{
m_pcm_queue.push_back(p & 0x0f);
tmp_args.push_back(p & 0x0f);
m_mem_reg[arg_n] = p;
m_op_size += 1;
}
else if ((p & 0xf0) == 0x50) // R
{
m_pcm_queue.push_back(p & 0x0f);
tmp_args.push_back(p & 0x0f);
m_mem_reg[arg_n] = p;
m_op_size += 1;
}
Expand All @@ -726,7 +726,7 @@ void kl1839vm1_device::vax_decode_pc()

// word
case vax_disassembler::mode::bw:
m_pcm_queue.push_back(s16(m_ram.read_word(PC + m_op_size)));
tmp_args.push_back(s16(m_ram.read_word(PC + m_op_size)));
m_mem_reg[arg_n] = 0x8f;
m_op_size += 2;
break;
Expand All @@ -742,19 +742,19 @@ void kl1839vm1_device::vax_decode_pc()
u8 p = m_ram.read_byte(PC + m_op_size);
if (p == 0x8f) // M
{
m_pcm_queue.push_back(m_ram.read_dword(PC + m_op_size + 1));
tmp_args.push_back(m_ram.read_dword(PC + m_op_size + 1));
m_mem_reg[arg_n] = p;
m_op_size += 5;
}
else if ((p & 0xf0) == 0x80) // M = R(n)+
{
m_pcm_queue.push_back(p & 0x0f);
tmp_args.push_back(p & 0x0f);
m_mem_reg[arg_n] = p;
m_op_size += 1;
}
else if ((p & 0xf0) == 0x50) // R
{
m_pcm_queue.push_back(p & 0x0f);
tmp_args.push_back(p & 0x0f);
m_mem_reg[arg_n] = p;
m_op_size += 1;
}
Expand All @@ -768,16 +768,23 @@ void kl1839vm1_device::vax_decode_pc()

default:
LOGVAX("(%x): unknown operand mode %02d in OP=%02x (n=%d)\n", PC, u8(mode), op, arg_n + 1);
m_pcm_queue.clear();
tmp_args.clear();
m_op_size = 0;
break;
}

++arg_n;
} while ((arg_n < 6) && (args[arg_n] != vax_disassembler::mode::none));

m_pcm_queue.clear();
if (m_op_size > 0) // above completed without failure
{
while (!tmp_args.empty())
{
m_pcm_queue.push_back(tmp_args.back());
tmp_args.pop_back();
}

u8 args_type = 0;
if (!m_pcm_queue.empty())
{
Expand Down Expand Up @@ -895,8 +902,8 @@ u32 kl1839vm1_device::vax_pcm_pull(bool is_bo)
}
else
{
PCM = m_pcm_queue.front();
m_pcm_queue.pop_front();
PCM = m_pcm_queue.back();
m_pcm_queue.pop_back();

bool is_mem = (m_mem_reg[0] & 0xf0) == 0x80;
if (is_bo && !is_mem)
Expand All @@ -919,6 +926,7 @@ u32 kl1839vm1_device::vax_pcm_pull(bool is_bo)
void kl1839vm1_device::device_start()
{
m_vax_dasm = std::make_unique<vax_disassembler>();
m_pcm_queue.resize(6);

space(AS_OPCODES).cache(m_microcode);
space(AS_DATA).specific(m_sysram);
Expand All @@ -932,8 +940,12 @@ void kl1839vm1_device::device_start()
save_item(NAME(m_amc));
save_item(NAME(m_ppc));
save_item(NAME(m_fp));
save_pointer(NAME(m_reg), 0x20);
save_item(NAME(m_jzdra_waiting));
save_pointer(NAME(m_consts), 0x10);
save_pointer(NAME(m_reg), 0x20);
save_item(NAME(m_op_size));
save_item(NAME(m_pcm_queue));
save_pointer(NAME(m_mem_reg), 6);

// Register debugger state
state_add(KL1839_AMC, "AMC", AMC).formatstr("%08X");
Expand Down
30 changes: 15 additions & 15 deletions src/devices/cpu/mpk1839/kl1839vm1.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,21 @@ class kl1839vm1_device : public cpu_device

std::unique_ptr<util::disasm_interface> m_vax_dasm;

PAIR m_vma_tmp; // do we have int reg for this?
PAIR m_rv;
PAIR m_sch;
PAIR m_rsp;
PAIR m_amc; // Microdode PC
PAIR m_ppc; // previous program counter
bool m_fp;
bool m_jzdra_waiting;
u32 m_consts[0x10] = { 0x4, 0x2, 0x8, 0x1, 0x0, 0, 0, 0x66, 0, 0xc00000, 0xffffffff, 0x1f0000, 0x4000000, 0, 0, 0 };
PAIR m_reg[0x20];
int m_icount;
u32 m_op_size;

std::deque<u32> m_pcm_queue;
u8 m_mem_reg[6];
PAIR m_vma_tmp; // do we have int reg for this?
PAIR m_rv;
PAIR m_sch;
PAIR m_rsp;
PAIR m_amc; // Microcode PC
PAIR m_ppc; // previous program counter
bool m_fp;
bool m_jzdra_waiting;
u32 m_consts[0x10] = { 0x4, 0x2, 0x8, 0x1, 0x0, 0, 0, 0x66, 0, 0xc00000, 0xffffffff, 0x1f0000, 0x4000000, 0, 0, 0 };
PAIR m_reg[0x20];
int m_icount;
u32 m_op_size;

std::vector<u32> m_pcm_queue;
u8 m_mem_reg[6];
};

DECLARE_DEVICE_TYPE(KL1839VM1, kl1839vm1_device)
Expand Down

0 comments on commit 7bd9ea4

Please sign in to comment.