diff --git a/src/devices/cpu/patinhofeio/patinho_feio.cpp b/src/devices/cpu/patinhofeio/patinho_feio.cpp new file mode 100644 index 00000000000..30ad62c925d --- /dev/null +++ b/src/devices/cpu/patinhofeio/patinho_feio.cpp @@ -0,0 +1,73 @@ +// license:GPL2+ +// copyright-holders:Felipe Sanches +/* + Patinho Feio +*/ + +#include "emu.h" +#include "debugger.h" +#include "patinho_feio.h" + +#define CI m_ci //The program counter is called "contador de instrucoes" in portuguese +#define ACC m_acc + +#define ADDRESS_MASK_4K 0xFFF +#define INCREMENT_CI_4K (CI = (CI+1) & ADDRESS_MASK_4K) + +const device_type PATINHO_FEIO = &device_creator; + +patinho_feio_device::patinho_feio_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : cpu_device(mconfig, PATINHO_FEIO, "PATINHO FEIO", tag, owner, clock, "patinho_feio_cpu", __FILE__) +{ +} + +void patinho_feio_device::device_start() +{ + m_ci = 0; + m_acc = 0; + + m_program = &space(AS_PROGRAM); + + save_item(NAME(m_ci)); + save_item(NAME(m_acc)); + + // Register state for debugger + state_add( PATINHO_FEIO_PC, "CI", m_pc ).mask(0xFFF); + state_add( PATINHO_FEIO_ACC, "ACC", m_acc ).mask(0xFF); +} + + +void patinho_feio_device::device_reset() +{ +} +/* execute instructions on this CPU until icount expires */ +void patinho_feio_device::execute_run() +{ + do + { + debugger_instruction_hook(this, CI); + + if ((! m_run)){ + m_icount = 0; /* if processor is stopped, just burn cycles */ + } else { + execute_instruction(); + m_icount --; + } + } + while (m_icount > 0); +} + + +/* execute one instruction */ +void patinho_feio_device::execute_instruction() +{ +// char opcode = patinho_feio_read(CI); + INCREMENT_CI_4K; +} + +offs_t patinho_feio_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) +{ + extern CPU_DISASSEMBLE( patinho_feio ); + return CPU_DISASSEMBLE_NAME(patinho_feio)(this, buffer, pc, oprom, opram, options); +} + diff --git a/src/devices/cpu/patinhofeio/patinho_feio.h b/src/devices/cpu/patinhofeio/patinho_feio.h new file mode 100644 index 00000000000..545fe70ed12 --- /dev/null +++ b/src/devices/cpu/patinhofeio/patinho_feio.h @@ -0,0 +1,61 @@ +// license:GPL2+ +// copyright-holders:Felipe Sanches +#pragma once + +#ifndef __PATINHOFEIO_H__ +#define __PATINHOFEIO_H__ + +/* register IDs */ +enum +{ + PATINHOFEIO_CI=1, PATINHOFEIO_ACC +}; + +class patinho_feio_device : public cpu_device +{ +public: + // construction/destruction + patinho_feio_device(const machine_config &mconfig, const char *_tag, device_t *_owner, UINT32 _clock); + +protected: + virtual void execute_run(); + virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options); + + address_space_config m_program_config; + + /* processor registers */ + int m_acc; /* accumulator (8 bits) */ + int m_ci; /* program counter (12 bits) (CI stands for "Contador de Instrucao")*/ + + /* processor state flip-flops */ + unsigned int m_run; /* processor is running */ + + int m_address_mask; /* address mask */ + int m_ir_mask; /* IR mask */ + int m_icount; + + address_space *m_program; + + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // device_execute_interface overrides + virtual UINT32 execute_min_cycles() const { return 1; } + virtual UINT32 execute_max_cycles() const { return 3; } + + // device_memory_interface overrides + virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const { return (spacenum == AS_PROGRAM) ? &m_program_config : NULL; } + + // device_disasm_interface overrides + virtual UINT32 disasm_min_opcode_bytes() const { return 4; } + virtual UINT32 disasm_max_opcode_bytes() const { return 4; } + +private: + void execute_instruction(); +}; + + +extern const device_type PATINHO_FEIO; + +#endif /* __PATINHOFEIO_H__ */ diff --git a/src/devices/cpu/patinhofeio/patinho_feio_dasm.cpp b/src/devices/cpu/patinhofeio/patinho_feio_dasm.cpp new file mode 100644 index 00000000000..b4e21ac3a0b --- /dev/null +++ b/src/devices/cpu/patinhofeio/patinho_feio_dasm.cpp @@ -0,0 +1,36 @@ +// license:GPL2+ +// copyright-holders:Felipe Sanches +#include "emu.h" +#include "cpu/patinhofeio/patinho_feio.h" + +CPU_DISASSEMBLE( patinho_feio ) +{ +// int md; +// int x; +// md = oprom[1] << 8 | oprom[0]; +// x = md & 0xFFF; + + //single-opcode instructions + switch (oprom[0]) + { + case 0x80: + sprintf (buffer, "LIMPO"); + break; + case 0x85: + sprintf (buffer, "INC"); + break; + case 0x96: + sprintf (buffer, "SV 1"); + break; + case 0x99: + sprintf (buffer, "TRE"); + break; + case 0x9D: + sprintf (buffer, "PARE"); + break; + default: + sprintf (buffer, "illegal"); + break; + } + return 1; +}