From 9729ebc804add1e34ab3cd6b2838f99b578e28b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Mon, 30 Nov 2015 16:02:46 -0200 Subject: [PATCH] [patinho] Implement PLAN and PLAZ instructions and fix a bug in all of the instructions dealing with indexed memory access --- src/devices/cpu/patinhofeio/patinho_feio.cpp | 30 ++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/devices/cpu/patinhofeio/patinho_feio.cpp b/src/devices/cpu/patinhofeio/patinho_feio.cpp index b2d928253ab..d5ec7701648 100644 --- a/src/devices/cpu/patinhofeio/patinho_feio.cpp +++ b/src/devices/cpu/patinhofeio/patinho_feio.cpp @@ -361,10 +361,10 @@ void patinho_feio_cpu_device::execute_instruction() return; case 0x10: //PLAX = "Pula indexado": Jump to indexed address - value = (opcode & 0x0F) << 8 | READ_BYTE_PATINHO(PC); + tmp = (opcode & 0x0F) << 8 | READ_BYTE_PATINHO(PC); INCREMENT_PC_4K; m_idx = READ_INDEX_REG(); - PC = compute_effective_address(m_idx + value); + PC = compute_effective_address(m_idx + tmp); return; case 0x20: //ARM = "Armazena": Store the value of the accumulator into a given memory position @@ -374,10 +374,10 @@ void patinho_feio_cpu_device::execute_instruction() return; case 0x30: //ARMX = "Armazena indexado": Store the value of the accumulator into a given indexed memory position - value = (opcode & 0x0F) << 8 | READ_BYTE_PATINHO(PC); + tmp = (opcode & 0x0F) << 8 | READ_BYTE_PATINHO(PC); INCREMENT_PC_4K; m_idx = READ_INDEX_REG(); - addr = compute_effective_address(m_idx + value); + addr = compute_effective_address(m_idx + tmp); WRITE_BYTE_PATINHO(addr, ACC); return; case 0x40: @@ -388,10 +388,10 @@ void patinho_feio_cpu_device::execute_instruction() return; case 0x50: //CARX = "Carga indexada": Load a value from a given indexed memory position into the accumulator - value = (opcode & 0x0F) << 8 | READ_BYTE_PATINHO(PC); + tmp = (opcode & 0x0F) << 8 | READ_BYTE_PATINHO(PC); INCREMENT_PC_4K; m_idx = READ_INDEX_REG(); - addr = compute_effective_address(m_idx + value); + addr = compute_effective_address(m_idx + tmp); ACC = READ_BYTE_PATINHO(addr); return; case 0x60: @@ -403,13 +403,27 @@ void patinho_feio_cpu_device::execute_instruction() return; case 0x70: //SOMX = "Soma indexada": Add a value from a given indexed memory position into the accumulator - value = (opcode & 0x0F) << 8 | READ_BYTE_PATINHO(PC); + tmp = (opcode & 0x0F) << 8 | READ_BYTE_PATINHO(PC); INCREMENT_PC_4K; m_idx = READ_INDEX_REG(); - addr = compute_effective_address(m_idx + value); + addr = compute_effective_address(m_idx + tmp); ACC += READ_BYTE_PATINHO(addr); //TODO: update V and T flags return; + case 0xA0: + //PLAN = "Pula se ACC negativo": Jump to a given address if ACC is negative + addr = compute_effective_address((opcode & 0x0F) << 8 | READ_BYTE_PATINHO(PC)); + INCREMENT_PC_4K; + if ((signed char) ACC < 0) + PC = addr; + return; + case 0xB0: + //PLAZ = "Pula se ACC for zero": Jump to a given address if ACC is zero + addr = compute_effective_address((opcode & 0x0F) << 8 | READ_BYTE_PATINHO(PC)); + INCREMENT_PC_4K; + if (ACC == 0) + PC = addr; + return; case 0xF0: //PUG = "Pula e guarda": Jump and store. // It stores the return address to addr and addr+1