trunk/src/emu/cpu/amis2000/amis2000.c
| r243573 | r243574 | |
| 6 | 6 | Overall functionality is similar to (and probably derived from) NEC uCOM-4. |
| 7 | 7 | |
| 8 | 8 | References: |
| 9 | | - AMI MOS Products Catalog Winter 1979 |
| 9 | - AMI MOS Products Catalog 1979/1980 |
| 10 | 10 | - AMI S2000 Programming Manual (rev. 2) |
| 11 | 11 | |
| 12 | 12 | TODO: |
| r243573 | r243574 | |
| 27 | 27 | // S2000 is the most basic one, 64 nibbles internal RAM and 1KB internal ROM |
| 28 | 28 | // S2150 increased RAM to 80 nibbles and ROM to 1.5KB |
| 29 | 29 | // high-voltage output versions of these chips (S2000A and S2150A) are identical overall |
| 30 | | const device_type AMI_S2000 = &device_creator<amis2000_device>; |
| 31 | | const device_type AMI_S2150 = &device_creator<amis2150_device>; |
| 30 | const device_type AMI_S2000 = &device_creator<amis2000_cpu_device>; |
| 31 | const device_type AMI_S2150 = &device_creator<amis2150_cpu_device>; |
| 32 | 32 | |
| 33 | // S2152 is an extension to S2150, removing the K pins and adding a better timer |
| 34 | const device_type AMI_S2152 = &device_creator<amis2152_cpu_device>; |
| 33 | 35 | |
| 36 | |
| 34 | 37 | // internal memory maps |
| 35 | | static ADDRESS_MAP_START(program_1k, AS_PROGRAM, 8, amis2000_device) |
| 38 | static ADDRESS_MAP_START(program_1k, AS_PROGRAM, 8, amis2000_base_device) |
| 36 | 39 | AM_RANGE(0x0000, 0x03ff) AM_ROM |
| 37 | 40 | ADDRESS_MAP_END |
| 38 | 41 | |
| 39 | | static ADDRESS_MAP_START(program_1_5k, AS_PROGRAM, 8, amis2000_device) |
| 42 | static ADDRESS_MAP_START(program_1_5k, AS_PROGRAM, 8, amis2000_base_device) |
| 40 | 43 | AM_RANGE(0x0000, 0x03ff) AM_ROM |
| 41 | 44 | AM_RANGE(0x0400, 0x05ff) AM_NOP // 0x00 |
| 42 | 45 | AM_RANGE(0x0600, 0x07ff) AM_ROM |
| 43 | 46 | ADDRESS_MAP_END |
| 44 | 47 | |
| 45 | 48 | |
| 46 | | static ADDRESS_MAP_START(data_64x4, AS_DATA, 8, amis2000_device) |
| 49 | static ADDRESS_MAP_START(data_64x4, AS_DATA, 8, amis2000_base_device) |
| 47 | 50 | AM_RANGE(0x00, 0x3f) AM_RAM |
| 48 | 51 | ADDRESS_MAP_END |
| 49 | 52 | |
| 50 | | static ADDRESS_MAP_START(data_80x4, AS_DATA, 8, amis2000_device) |
| 53 | static ADDRESS_MAP_START(data_80x4, AS_DATA, 8, amis2000_base_device) |
| 51 | 54 | AM_RANGE(0x00, 0x3f) AM_RAM |
| 52 | 55 | AM_RANGE(0x40, 0x4f) AM_RAM |
| 53 | 56 | ADDRESS_MAP_END |
| 54 | 57 | |
| 55 | 58 | |
| 56 | 59 | // device definitions |
| 57 | | amis2000_device::amis2000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 58 | | : cpu_device(mconfig, AMI_S2000, "AMI S2000", tag, owner, clock, "amis2000", __FILE__), |
| 59 | | m_program_config("program", ENDIANNESS_BIG, 8, 13, 0, ADDRESS_MAP_NAME(program_1k)), |
| 60 | | m_data_config("data", ENDIANNESS_BIG, 8, 6, 0, ADDRESS_MAP_NAME(data_64x4)), |
| 61 | | m_bu_bits(2), |
| 62 | | m_callstack_bits(10), |
| 63 | | m_callstack_depth(3), |
| 64 | | m_read_k(*this), |
| 65 | | m_read_i(*this), |
| 66 | | m_read_d(*this), |
| 67 | | m_write_d(*this), |
| 68 | | m_write_a(*this) |
| 69 | | { |
| 70 | | } |
| 60 | amis2000_cpu_device::amis2000_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 61 | : amis2000_base_device(mconfig, AMI_S2000, "AMI S2000", tag, owner, clock, 2, 10, 3, 13, ADDRESS_MAP_NAME(program_1k), 6, ADDRESS_MAP_NAME(data_64x4), "amis2000", __FILE__) |
| 62 | { } |
| 71 | 63 | |
| 72 | | amis2000_device::amis2000_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT8 bu_bits, UINT8 callstack_bits, UINT8 callstack_depth, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data, const char *shortname, const char *source) |
| 73 | | : cpu_device(mconfig, type, name, tag, owner, clock, shortname, source), |
| 74 | | m_program_config("program", ENDIANNESS_BIG, 8, prgwidth, 0, program), |
| 75 | | m_data_config("data", ENDIANNESS_BIG, 8, datawidth, 0, data), |
| 76 | | m_bu_bits(bu_bits), |
| 77 | | m_callstack_bits(callstack_bits), |
| 78 | | m_callstack_depth(callstack_depth), |
| 79 | | m_read_k(*this), |
| 80 | | m_read_i(*this), |
| 81 | | m_read_d(*this), |
| 82 | | m_write_d(*this), |
| 83 | | m_write_a(*this) |
| 84 | | { |
| 85 | | } |
| 64 | amis2150_cpu_device::amis2150_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 65 | : amis2000_base_device(mconfig, AMI_S2150, "AMI S2150", tag, owner, clock, 3, 11, 3, 13, ADDRESS_MAP_NAME(program_1_5k), 7, ADDRESS_MAP_NAME(data_80x4), "amis2150", __FILE__) |
| 66 | { } |
| 86 | 67 | |
| 87 | | amis2150_device::amis2150_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 88 | | : amis2000_device(mconfig, AMI_S2150, "AMI S2150", tag, owner, clock, 3, 11, 3, 13, ADDRESS_MAP_NAME(program_1_5k), 7, ADDRESS_MAP_NAME(data_80x4), "amis2150", __FILE__) |
| 89 | | { |
| 90 | | } |
| 68 | amis2152_cpu_device::amis2152_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 69 | : amis2000_base_device(mconfig, AMI_S2152, "AMI S2152", tag, owner, clock, 3, 11, 3, 13, ADDRESS_MAP_NAME(program_1_5k), 7, ADDRESS_MAP_NAME(data_80x4), "amis2152", __FILE__) |
| 70 | { } |
| 91 | 71 | |
| 92 | 72 | |
| 73 | |
| 93 | 74 | // disasm |
| 94 | | void amis2000_device::state_string_export(const device_state_entry &entry, astring &string) |
| 75 | void amis2000_base_device::state_string_export(const device_state_entry &entry, astring &string) |
| 95 | 76 | { |
| 96 | 77 | switch (entry.index()) |
| 97 | 78 | { |
| r243573 | r243574 | |
| 110 | 91 | } |
| 111 | 92 | } |
| 112 | 93 | |
| 113 | | offs_t amis2000_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) |
| 94 | offs_t amis2000_base_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) |
| 114 | 95 | { |
| 115 | 96 | extern CPU_DISASSEMBLE(amis2000); |
| 116 | 97 | return CPU_DISASSEMBLE_NAME(amis2000)(this, buffer, pc, oprom, opram, options); |
| r243573 | r243574 | |
| 128 | 109 | S2000_ACC, S2000_E, S2000_CY |
| 129 | 110 | }; |
| 130 | 111 | |
| 131 | | void amis2000_device::device_start() |
| 112 | void amis2000_base_device::device_start() |
| 132 | 113 | { |
| 133 | 114 | m_program = &space(AS_PROGRAM); |
| 134 | 115 | m_data = &space(AS_DATA); |
| r243573 | r243574 | |
| 138 | 119 | m_read_d.resolve_safe(0); |
| 139 | 120 | m_write_d.resolve_safe(); |
| 140 | 121 | m_write_a.resolve_safe(); |
| 122 | m_write_f.resolve_safe(); |
| 141 | 123 | |
| 142 | 124 | m_bu_mask = (1 << m_bu_bits) - 1; |
| 143 | 125 | m_callstack_mask = (1 << m_callstack_bits) - 1; |
| r243573 | r243574 | |
| 202 | 184 | // device_reset - device-specific reset |
| 203 | 185 | //------------------------------------------------- |
| 204 | 186 | |
| 205 | | void amis2000_device::device_reset() |
| 187 | void amis2000_base_device::device_reset() |
| 206 | 188 | { |
| 207 | 189 | m_pc = 0; |
| 208 | 190 | m_op = 0; |
| r243573 | r243574 | |
| 220 | 202 | // execute |
| 221 | 203 | //------------------------------------------------- |
| 222 | 204 | |
| 223 | | void amis2000_device::execute_run() |
| 205 | void amis2000_base_device::execute_run() |
| 224 | 206 | { |
| 225 | 207 | while (m_icount > 0) |
| 226 | 208 | { |
trunk/src/emu/cpu/amis2000/amis2000.h
| r243573 | r243574 | |
| 14 | 14 | |
| 15 | 15 | // generic input pins (4 bits each) |
| 16 | 16 | #define MCFG_AMI_S2000_READ_K_CB(_devcb) \ |
| 17 | | amis2000_device::set_read_k_callback(*device, DEVCB_##_devcb); |
| 17 | amis2000_base_device::set_read_k_callback(*device, DEVCB_##_devcb); |
| 18 | 18 | |
| 19 | 19 | #define MCFG_AMI_S2000_READ_I_CB(_devcb) \ |
| 20 | | amis2000_device::set_read_i_callback(*device, DEVCB_##_devcb); |
| 20 | amis2000_base_device::set_read_i_callback(*device, DEVCB_##_devcb); |
| 21 | 21 | |
| 22 | 22 | // 8-bit external databus coupled as input/output pins |
| 23 | 23 | #define MCFG_AMI_S2000_READ_D_CB(_devcb) \ |
| 24 | | amis2000_device::set_read_d_callback(*device, DEVCB_##_devcb); |
| 24 | amis2000_base_device::set_read_d_callback(*device, DEVCB_##_devcb); |
| 25 | 25 | |
| 26 | 26 | #define MCFG_AMI_S2000_WRITE_D_CB(_devcb) \ |
| 27 | | amis2000_device::set_write_d_callback(*device, DEVCB_##_devcb); |
| 27 | amis2000_base_device::set_write_d_callback(*device, DEVCB_##_devcb); |
| 28 | 28 | |
| 29 | 29 | // 13-bit external addressbus coupled as output pins |
| 30 | 30 | #define MCFG_AMI_S2000_WRITE_A_CB(_devcb) \ |
| 31 | | amis2000_device::set_write_a_callback(*device, DEVCB_##_devcb); |
| 31 | amis2000_base_device::set_write_a_callback(*device, DEVCB_##_devcb); |
| 32 | 32 | |
| 33 | // F_out pin (only for S2152) |
| 34 | #define MCFG_AMI_S2152_FOUT_CB(_devcb) \ |
| 35 | amis2000_base_device::set_write_f_callback(*device, DEVCB_##_devcb); |
| 33 | 36 | |
| 34 | | class amis2000_device : public cpu_device |
| 37 | |
| 38 | class amis2000_base_device : public cpu_device |
| 35 | 39 | { |
| 36 | 40 | public: |
| 37 | 41 | // construction/destruction |
| 38 | | amis2000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 39 | | amis2000_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT8 bu_bits, UINT8 callstack_bits, UINT8 callstack_depth, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data, const char *shortname, const char *source); |
| 42 | amis2000_base_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT8 bu_bits, UINT8 callstack_bits, UINT8 callstack_depth, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data, const char *shortname, const char *source) |
| 43 | : cpu_device(mconfig, type, name, tag, owner, clock, shortname, source) |
| 44 | , m_program_config("program", ENDIANNESS_BIG, 8, prgwidth, 0, program) |
| 45 | , m_data_config("data", ENDIANNESS_BIG, 8, datawidth, 0, data) |
| 46 | , m_bu_bits(bu_bits) |
| 47 | , m_callstack_bits(callstack_bits) |
| 48 | , m_callstack_depth(callstack_depth) |
| 49 | , m_read_k(*this) |
| 50 | , m_read_i(*this) |
| 51 | , m_read_d(*this) |
| 52 | , m_write_d(*this) |
| 53 | , m_write_a(*this) |
| 54 | , m_write_f(*this) |
| 55 | { } |
| 40 | 56 | |
| 41 | 57 | // static configuration helpers |
| 42 | | template<class _Object> static devcb_base &set_read_k_callback(device_t &device, _Object object) { return downcast<amis2000_device &>(device).m_read_k.set_callback(object); } |
| 43 | | template<class _Object> static devcb_base &set_read_i_callback(device_t &device, _Object object) { return downcast<amis2000_device &>(device).m_read_i.set_callback(object); } |
| 44 | | template<class _Object> static devcb_base &set_read_d_callback(device_t &device, _Object object) { return downcast<amis2000_device &>(device).m_read_d.set_callback(object); } |
| 45 | | template<class _Object> static devcb_base &set_write_d_callback(device_t &device, _Object object) { return downcast<amis2000_device &>(device).m_write_d.set_callback(object); } |
| 46 | | template<class _Object> static devcb_base &set_write_a_callback(device_t &device, _Object object) { return downcast<amis2000_device &>(device).m_write_a.set_callback(object); } |
| 58 | template<class _Object> static devcb_base &set_read_k_callback(device_t &device, _Object object) { return downcast<amis2000_base_device &>(device).m_read_k.set_callback(object); } |
| 59 | template<class _Object> static devcb_base &set_read_i_callback(device_t &device, _Object object) { return downcast<amis2000_base_device &>(device).m_read_i.set_callback(object); } |
| 60 | template<class _Object> static devcb_base &set_read_d_callback(device_t &device, _Object object) { return downcast<amis2000_base_device &>(device).m_read_d.set_callback(object); } |
| 61 | template<class _Object> static devcb_base &set_write_d_callback(device_t &device, _Object object) { return downcast<amis2000_base_device &>(device).m_write_d.set_callback(object); } |
| 62 | template<class _Object> static devcb_base &set_write_a_callback(device_t &device, _Object object) { return downcast<amis2000_base_device &>(device).m_write_a.set_callback(object); } |
| 63 | template<class _Object> static devcb_base &set_write_f_callback(device_t &device, _Object object) { return downcast<amis2000_base_device &>(device).m_write_f.set_callback(object); } |
| 47 | 64 | |
| 48 | 65 | protected: |
| 49 | 66 | // device-level overrides |
| r243573 | r243574 | |
| 103 | 120 | devcb_read8 m_read_d; |
| 104 | 121 | devcb_write8 m_write_d; |
| 105 | 122 | devcb_write16 m_write_a; |
| 123 | devcb_write_line m_write_f; |
| 106 | 124 | |
| 107 | 125 | // misc internal helpers |
| 108 | 126 | UINT8 ram_r(); |
| r243573 | r243574 | |
| 112 | 130 | void d_latch_out(bool active); |
| 113 | 131 | |
| 114 | 132 | // opcode handlers |
| 115 | | void op_lai(); |
| 116 | | void op_lab(); |
| 117 | | void op_lae(); |
| 118 | | void op_xab(); |
| 119 | | void op_xabu(); |
| 120 | | void op_xae(); |
| 121 | | void op_lbe(); |
| 122 | | void op_lbep(); |
| 123 | | void op_lbz(); |
| 124 | | void op_lbf(); |
| 133 | virtual void op_lai(); |
| 134 | virtual void op_lab(); |
| 135 | virtual void op_lae(); |
| 136 | virtual void op_xab(); |
| 137 | virtual void op_xabu(); |
| 138 | virtual void op_xae(); |
| 139 | virtual void op_lbe(); |
| 140 | virtual void op_lbep(); |
| 141 | virtual void op_lbz(); |
| 142 | virtual void op_lbf(); |
| 125 | 143 | |
| 126 | | void op_lam(); |
| 127 | | void op_xc(); |
| 128 | | void op_xci(); |
| 129 | | void op_xcd(); |
| 130 | | void op_stm(); |
| 131 | | void op_rsm(); |
| 144 | virtual void op_lam(); |
| 145 | virtual void op_xc(); |
| 146 | virtual void op_xci(); |
| 147 | virtual void op_xcd(); |
| 148 | virtual void op_stm(); |
| 149 | virtual void op_rsm(); |
| 132 | 150 | |
| 133 | | void op_inp(); |
| 134 | | void op_out(); |
| 135 | | void op_disb(); |
| 136 | | void op_disn(); |
| 137 | | void op_mvs(); |
| 138 | | void op_psh(); |
| 139 | | void op_psl(); |
| 140 | | void op_eur(); |
| 151 | virtual void op_inp(); |
| 152 | virtual void op_out(); |
| 153 | virtual void op_disb(); |
| 154 | virtual void op_disn(); |
| 155 | virtual void op_mvs(); |
| 156 | virtual void op_psh(); |
| 157 | virtual void op_psl(); |
| 158 | virtual void op_eur(); |
| 141 | 159 | |
| 142 | | void op_pp(); |
| 143 | | void op_jmp(); |
| 144 | | void op_jms(); |
| 145 | | void op_rt(); |
| 146 | | void op_rts(); |
| 147 | | void op_nop(); |
| 148 | | void op_halt(); |
| 160 | virtual void op_pp(); |
| 161 | virtual void op_jmp(); |
| 162 | virtual void op_jms(); |
| 163 | virtual void op_rt(); |
| 164 | virtual void op_rts(); |
| 165 | virtual void op_nop(); |
| 166 | virtual void op_halt(); |
| 149 | 167 | |
| 150 | | void op_szc(); |
| 151 | | void op_szm(); |
| 152 | | void op_szi(); |
| 153 | | void op_szk(); |
| 154 | | void op_sbe(); |
| 155 | | void op_sam(); |
| 156 | | void op_sos(); |
| 157 | | void op_tf1(); |
| 158 | | void op_tf2(); |
| 168 | virtual void op_szc(); |
| 169 | virtual void op_szm(); |
| 170 | virtual void op_szi(); |
| 171 | virtual void op_szk(); |
| 172 | virtual void op_sbe(); |
| 173 | virtual void op_sam(); |
| 174 | virtual void op_sos(); |
| 175 | virtual void op_tf1(); |
| 176 | virtual void op_tf2(); |
| 159 | 177 | |
| 160 | | void op_adcs(); |
| 161 | | void op_adis(); |
| 162 | | void op_add(); |
| 163 | | void op_and(); |
| 164 | | void op_xor(); |
| 165 | | void op_stc(); |
| 166 | | void op_rsc(); |
| 167 | | void op_cma(); |
| 168 | | void op_sf1(); |
| 169 | | void op_rf1(); |
| 170 | | void op_sf2(); |
| 171 | | void op_rf2(); |
| 178 | virtual void op_adcs(); |
| 179 | virtual void op_adis(); |
| 180 | virtual void op_add(); |
| 181 | virtual void op_and(); |
| 182 | virtual void op_xor(); |
| 183 | virtual void op_stc(); |
| 184 | virtual void op_rsc(); |
| 185 | virtual void op_cma(); |
| 186 | virtual void op_sf1(); |
| 187 | virtual void op_rf1(); |
| 188 | virtual void op_sf2(); |
| 189 | virtual void op_rf2(); |
| 172 | 190 | }; |
| 173 | 191 | |
| 174 | 192 | |
| 175 | | class amis2150_device : public amis2000_device |
| 193 | class amis2000_cpu_device : public amis2000_base_device |
| 176 | 194 | { |
| 177 | 195 | public: |
| 178 | | amis2150_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 196 | amis2000_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 179 | 197 | }; |
| 180 | 198 | |
| 181 | 199 | |
| 200 | class amis2150_cpu_device : public amis2000_base_device |
| 201 | { |
| 202 | public: |
| 203 | amis2150_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 204 | }; |
| 182 | 205 | |
| 206 | |
| 207 | class amis2152_cpu_device : public amis2000_base_device |
| 208 | { |
| 209 | public: |
| 210 | amis2152_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 211 | }; |
| 212 | |
| 213 | |
| 214 | |
| 183 | 215 | extern const device_type AMI_S2000; |
| 184 | 216 | extern const device_type AMI_S2150; |
| 217 | extern const device_type AMI_S2152; |
| 185 | 218 | |
| 186 | 219 | |
| 187 | 220 | #endif /* _AMIS2000_H_ */ |
trunk/src/emu/cpu/amis2000/amis2000op.inc
| r243573 | r243574 | |
| 2 | 2 | |
| 3 | 3 | // internal helpers |
| 4 | 4 | |
| 5 | | inline UINT8 amis2000_device::ram_r() |
| 5 | inline UINT8 amis2000_base_device::ram_r() |
| 6 | 6 | { |
| 7 | 7 | UINT16 address = m_bu << 4 | m_bl; |
| 8 | 8 | return m_data->read_byte(address) & 0xf; |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | | inline void amis2000_device::ram_w(UINT8 data) |
| 11 | inline void amis2000_base_device::ram_w(UINT8 data) |
| 12 | 12 | { |
| 13 | 13 | UINT16 address = m_bu << 4 | m_bl; |
| 14 | 14 | m_data->write_byte(address, data & 0xf); |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | | void amis2000_device::pop_callstack() |
| 17 | void amis2000_base_device::pop_callstack() |
| 18 | 18 | { |
| 19 | 19 | m_pc = (m_pc & ~m_callstack_mask) | (m_callstack[0] & m_callstack_mask); |
| 20 | 20 | for (int i = 0; i < m_callstack_depth-1; i++) |
| 21 | 21 | m_callstack[i] = m_callstack[i+1]; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | | void amis2000_device::push_callstack() |
| 24 | void amis2000_base_device::push_callstack() |
| 25 | 25 | { |
| 26 | 26 | for (int i = m_callstack_depth-1; i >= 1; i--) |
| 27 | 27 | m_callstack[i] = m_callstack[i-1]; |
| 28 | 28 | m_callstack[0] = m_pc & m_callstack_mask; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | | void amis2000_device::d_latch_out(bool active) |
| 31 | void amis2000_base_device::d_latch_out(bool active) |
| 32 | 32 | { |
| 33 | 33 | m_write_d(0, active ? (m_d ^ m_d_polarity) : 0, 0xff); |
| 34 | 34 | m_d_active = active; |
| r243573 | r243574 | |
| 37 | 37 | |
| 38 | 38 | // Register Instructions |
| 39 | 39 | |
| 40 | | void amis2000_device::op_lai() |
| 40 | void amis2000_base_device::op_lai() |
| 41 | 41 | { |
| 42 | 42 | // LAI X: load ACC with X, select I and K inputs |
| 43 | 43 | // note: only execute the first one in a sequence of LAI |
| r243573 | r243574 | |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | | void amis2000_device::op_lab() |
| 52 | void amis2000_base_device::op_lab() |
| 53 | 53 | { |
| 54 | 54 | // LAB: load ACC with BL |
| 55 | 55 | m_acc = m_bl; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | | void amis2000_device::op_lae() |
| 58 | void amis2000_base_device::op_lae() |
| 59 | 59 | { |
| 60 | 60 | // LAE: load ACC with E |
| 61 | 61 | m_acc = m_e; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | | void amis2000_device::op_xab() |
| 64 | void amis2000_base_device::op_xab() |
| 65 | 65 | { |
| 66 | 66 | // XAB: exchange ACC with BL |
| 67 | 67 | UINT8 old_acc = m_acc; |
| r243573 | r243574 | |
| 69 | 69 | m_bl = old_acc; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | | void amis2000_device::op_xabu() |
| 72 | void amis2000_base_device::op_xabu() |
| 73 | 73 | { |
| 74 | 74 | // XABU: exchange ACC with BU |
| 75 | 75 | UINT8 old_acc = m_acc; |
| r243573 | r243574 | |
| 77 | 77 | m_bu = old_acc & m_bu_mask; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | | void amis2000_device::op_xae() |
| 80 | void amis2000_base_device::op_xae() |
| 81 | 81 | { |
| 82 | 82 | // XAE: exchange ACC with E |
| 83 | 83 | UINT8 old_acc = m_acc; |
| r243573 | r243574 | |
| 85 | 85 | m_e = old_acc; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | | void amis2000_device::op_lbe() |
| 88 | void amis2000_base_device::op_lbe() |
| 89 | 89 | { |
| 90 | 90 | // LBE Y: load BU with Y, load BL with E |
| 91 | 91 | // note: only execute the first one in a sequence of LB* |
| r243573 | r243574 | |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | | void amis2000_device::op_lbep() |
| 100 | void amis2000_base_device::op_lbep() |
| 101 | 101 | { |
| 102 | 102 | // LBEP Y: load BU with Y, load BL with E+1 |
| 103 | 103 | // note: only execute the first one in a sequence of LB* |
| r243573 | r243574 | |
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | | void amis2000_device::op_lbz() |
| 112 | void amis2000_base_device::op_lbz() |
| 113 | 113 | { |
| 114 | 114 | // LBZ Y: load BU with Y, load BL with 0 |
| 115 | 115 | // note: only execute the first one in a sequence of LB* |
| r243573 | r243574 | |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | | void amis2000_device::op_lbf() |
| 124 | void amis2000_base_device::op_lbf() |
| 125 | 125 | { |
| 126 | 126 | // LBF Y: load BU with Y, load BL with 15 |
| 127 | 127 | // note: only execute the first one in a sequence of LB* |
| r243573 | r243574 | |
| 136 | 136 | |
| 137 | 137 | // RAM Instructions |
| 138 | 138 | |
| 139 | | void amis2000_device::op_lam() |
| 139 | void amis2000_base_device::op_lam() |
| 140 | 140 | { |
| 141 | 141 | // LAM _Y: load ACC with RAM, xor BU with _Y |
| 142 | 142 | m_acc = ram_r(); |
| r243573 | r243574 | |
| 144 | 144 | m_bu ^= (param & m_bu_mask); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | | void amis2000_device::op_xc() |
| 147 | void amis2000_base_device::op_xc() |
| 148 | 148 | { |
| 149 | 149 | // XC _Y: exchange ACC with RAM, xor BU with _Y |
| 150 | 150 | UINT8 old_acc = m_acc; |
| r243573 | r243574 | |
| 154 | 154 | m_bu ^= (param & m_bu_mask); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | | void amis2000_device::op_xci() |
| 157 | void amis2000_base_device::op_xci() |
| 158 | 158 | { |
| 159 | 159 | // XCI _Y: exchange ACC with RAM, increment BL(skip next on carry), xor BU with _Y |
| 160 | 160 | op_xc(); |
| r243573 | r243574 | |
| 162 | 162 | m_skip = (m_bl == 0); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | | void amis2000_device::op_xcd() |
| 165 | void amis2000_base_device::op_xcd() |
| 166 | 166 | { |
| 167 | 167 | // XCD _Y: exchange ACC with RAM, decrement BL(skip next on carry), xor BU with _Y |
| 168 | 168 | op_xc(); |
| r243573 | r243574 | |
| 170 | 170 | m_skip = (m_bl == 0xf); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | | void amis2000_device::op_stm() |
| 173 | void amis2000_base_device::op_stm() |
| 174 | 174 | { |
| 175 | 175 | // STM Z: set RAM bit Z |
| 176 | 176 | UINT8 param = 1 << (m_op & 0x03); |
| 177 | 177 | ram_w(ram_r() | param); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | | void amis2000_device::op_rsm() |
| 180 | void amis2000_base_device::op_rsm() |
| 181 | 181 | { |
| 182 | 182 | // RSM Z: reset RAM bit Z |
| 183 | 183 | UINT8 param = 1 << (m_op & 0x03); |
| r243573 | r243574 | |
| 187 | 187 | |
| 188 | 188 | // Input/Output Instructions |
| 189 | 189 | |
| 190 | | void amis2000_device::op_inp() |
| 190 | void amis2000_base_device::op_inp() |
| 191 | 191 | { |
| 192 | 192 | // INP: input D-pins to ACC and RAM |
| 193 | 193 | UINT8 in = m_d_active ? m_d : m_read_d(0, 0xff); |
| r243573 | r243574 | |
| 195 | 195 | ram_w(in >> 4 & 0xf); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | | void amis2000_device::op_out() |
| 198 | void amis2000_base_device::op_out() |
| 199 | 199 | { |
| 200 | 200 | // OUT: pulse output ACC and RAM to D-pins |
| 201 | 201 | logerror("%s unknown opcode $%02X at $%04X\n", tag(), m_op, m_pc); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | | void amis2000_device::op_disb() |
| 204 | void amis2000_base_device::op_disb() |
| 205 | 205 | { |
| 206 | 206 | // DISB: set D-latch to ACC and RAM directly |
| 207 | 207 | m_d = m_acc | ram_r() << 4; |
| 208 | 208 | d_latch_out(true); |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | | void amis2000_device::op_disn() |
| 211 | void amis2000_base_device::op_disn() |
| 212 | 212 | { |
| 213 | 213 | // DISN: set D-latch to ACC+carry via on-die segment decoder |
| 214 | 214 | static const UINT8 lut_segment_decoder[0x10] = |
| r243573 | r243574 | |
| 220 | 220 | d_latch_out(true); |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | | void amis2000_device::op_mvs() |
| 223 | void amis2000_base_device::op_mvs() |
| 224 | 224 | { |
| 225 | 225 | // MVS: output master strobe latch to A-pins |
| 226 | 226 | d_latch_out(false); |
| 227 | 227 | m_write_a(0, m_a, 0xffff); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | | void amis2000_device::op_psh() |
| 230 | void amis2000_base_device::op_psh() |
| 231 | 231 | { |
| 232 | 232 | // PSH: preset high(BL) master strobe latch |
| 233 | 233 | switch (m_bl) |
| r243573 | r243574 | |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | | void amis2000_device::op_psl() |
| 257 | void amis2000_base_device::op_psl() |
| 258 | 258 | { |
| 259 | 259 | // PSL: preset low(BL) master strobe latch |
| 260 | 260 | switch (m_bl) |
| r243573 | r243574 | |
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | | void amis2000_device::op_eur() |
| 284 | void amis2000_base_device::op_eur() |
| 285 | 285 | { |
| 286 | 286 | // EUR: set timer frequency(European) and D-latch polarity, via ACC |
| 287 | 287 | m_d_polarity = (m_acc & 1) ? 0x00 : 0xff; |
| r243573 | r243574 | |
| 291 | 291 | |
| 292 | 292 | // Program Control Instructions |
| 293 | 293 | |
| 294 | | void amis2000_device::op_pp() |
| 294 | void amis2000_base_device::op_pp() |
| 295 | 295 | { |
| 296 | 296 | // PP _X: prepare page/bank with _X |
| 297 | 297 | UINT8 param = ~m_op & 0x0f; |
| r243573 | r243574 | |
| 301 | 301 | m_pbr = param & 7; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | | void amis2000_device::op_jmp() |
| 304 | void amis2000_base_device::op_jmp() |
| 305 | 305 | { |
| 306 | 306 | // JMP X: jump to X(+PP) |
| 307 | 307 | UINT16 mask = 0x3f; |
| r243573 | r243574 | |
| 316 | 316 | m_pc = (m_pc & ~mask) | param; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | | void amis2000_device::op_jms() |
| 319 | void amis2000_base_device::op_jms() |
| 320 | 320 | { |
| 321 | 321 | // JMS X: call to X(+PP) |
| 322 | 322 | m_icount--; |
| r243573 | r243574 | |
| 328 | 328 | m_pc |= 0x3c0; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | | void amis2000_device::op_rt() |
| 331 | void amis2000_base_device::op_rt() |
| 332 | 332 | { |
| 333 | 333 | // RT: return from subroutine |
| 334 | 334 | pop_callstack(); |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | | void amis2000_device::op_rts() |
| 337 | void amis2000_base_device::op_rts() |
| 338 | 338 | { |
| 339 | 339 | // RTS: return from subroutine and skip next |
| 340 | 340 | op_rt(); |
| 341 | 341 | m_skip = true; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | | void amis2000_device::op_nop() |
| 344 | void amis2000_base_device::op_nop() |
| 345 | 345 | { |
| 346 | 346 | // NOP: no operation |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | | void amis2000_device::op_halt() |
| 349 | void amis2000_base_device::op_halt() |
| 350 | 350 | { |
| 351 | 351 | // HALT: debugger breakpoint for devkit-use |
| 352 | 352 | logerror("%s unknown opcode $%02X at $%04X\n", tag(), m_op, m_pc); |
| r243573 | r243574 | |
| 355 | 355 | |
| 356 | 356 | // Skip Instructions |
| 357 | 357 | |
| 358 | | void amis2000_device::op_szc() |
| 358 | void amis2000_base_device::op_szc() |
| 359 | 359 | { |
| 360 | 360 | // SZC: skip next on zero(no) carry |
| 361 | 361 | m_skip = !m_carry; |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | | void amis2000_device::op_szm() |
| 364 | void amis2000_base_device::op_szm() |
| 365 | 365 | { |
| 366 | 366 | // SZM Z: skip next on zero RAM bit Z |
| 367 | 367 | UINT8 param = 1 << (m_op & 0x03); |
| 368 | 368 | m_skip = !(ram_r() & param); |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | | void amis2000_device::op_szi() |
| 371 | void amis2000_base_device::op_szi() |
| 372 | 372 | { |
| 373 | 373 | // SZI: skip next on I pin(s) |
| 374 | 374 | m_skip = ((~m_read_i(0, 0xff) & m_ki_mask) != 0); |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | | void amis2000_device::op_szk() |
| 377 | void amis2000_base_device::op_szk() |
| 378 | 378 | { |
| 379 | 379 | // SZK: skip next on K pin(s) |
| 380 | 380 | m_skip = ((~m_read_k(0, 0xff) & m_ki_mask) != 0); |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | | void amis2000_device::op_sbe() |
| 383 | void amis2000_base_device::op_sbe() |
| 384 | 384 | { |
| 385 | 385 | // SBE: skip next on BL equals E |
| 386 | 386 | m_skip = (m_bl == m_e); |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | | void amis2000_device::op_sam() |
| 389 | void amis2000_base_device::op_sam() |
| 390 | 390 | { |
| 391 | 391 | // SAM: skip next on ACC equals RAM |
| 392 | 392 | m_skip = (m_acc == ram_r()); |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | | void amis2000_device::op_sos() |
| 395 | void amis2000_base_device::op_sos() |
| 396 | 396 | { |
| 397 | 397 | // SOS: skip next on SF(timer output), clear SF |
| 398 | 398 | logerror("%s unknown opcode $%02X at $%04X\n", tag(), m_op, m_pc); |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | | void amis2000_device::op_tf1() |
| 401 | void amis2000_base_device::op_tf1() |
| 402 | 402 | { |
| 403 | 403 | // TF1: skip next on flag 1 |
| 404 | 404 | m_skip = ((m_f & 0x01) != 0); |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | | void amis2000_device::op_tf2() |
| 407 | void amis2000_base_device::op_tf2() |
| 408 | 408 | { |
| 409 | 409 | // TF2: skip next on flag 2 |
| 410 | 410 | m_skip = ((m_f & 0x02) != 0); |
| r243573 | r243574 | |
| 413 | 413 | |
| 414 | 414 | // Arithmetic and Logical Instructions |
| 415 | 415 | |
| 416 | | void amis2000_device::op_adcs() |
| 416 | void amis2000_base_device::op_adcs() |
| 417 | 417 | { |
| 418 | 418 | // ADCS: add RAM to ACC+carry, skip next on not carry |
| 419 | 419 | m_acc += ram_r() + m_carry; |
| r243573 | r243574 | |
| 422 | 422 | m_acc &= 0xf; |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | | void amis2000_device::op_adis() |
| 425 | void amis2000_base_device::op_adis() |
| 426 | 426 | { |
| 427 | 427 | // ADIS X: add X to ACC, skip next on not carry |
| 428 | 428 | UINT8 param = m_op & 0x0f; |
| r243573 | r243574 | |
| 431 | 431 | m_acc &= 0xf; |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | | void amis2000_device::op_add() |
| 434 | void amis2000_base_device::op_add() |
| 435 | 435 | { |
| 436 | 436 | // ADD: add RAM to ACC |
| 437 | 437 | m_acc = (m_acc + ram_r()) & 0xf; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | | void amis2000_device::op_and() |
| 440 | void amis2000_base_device::op_and() |
| 441 | 441 | { |
| 442 | 442 | // AND: and ACC with RAM |
| 443 | 443 | m_acc &= ram_r(); |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | | void amis2000_device::op_xor() |
| 446 | void amis2000_base_device::op_xor() |
| 447 | 447 | { |
| 448 | 448 | // XOR: xor ACC with RAM |
| 449 | 449 | m_acc ^= ram_r(); |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | | void amis2000_device::op_stc() |
| 452 | void amis2000_base_device::op_stc() |
| 453 | 453 | { |
| 454 | 454 | // STC: set carry |
| 455 | 455 | m_carry = 1; |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | | void amis2000_device::op_rsc() |
| 458 | void amis2000_base_device::op_rsc() |
| 459 | 459 | { |
| 460 | 460 | // RSC: reset carry |
| 461 | 461 | m_carry = 0; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | | void amis2000_device::op_cma() |
| 464 | void amis2000_base_device::op_cma() |
| 465 | 465 | { |
| 466 | 466 | // CMA: complement ACC |
| 467 | 467 | m_acc ^= 0xf; |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | | void amis2000_device::op_sf1() |
| 470 | void amis2000_base_device::op_sf1() |
| 471 | 471 | { |
| 472 | 472 | // SF1: set flag 1 |
| 473 | 473 | m_f |= 0x01; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | | void amis2000_device::op_rf1() |
| 476 | void amis2000_base_device::op_rf1() |
| 477 | 477 | { |
| 478 | 478 | // RF1: reset flag 1 |
| 479 | 479 | m_f &= ~0x01; |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | | void amis2000_device::op_sf2() |
| 482 | void amis2000_base_device::op_sf2() |
| 483 | 483 | { |
| 484 | 484 | // SF2: set flag 2 |
| 485 | 485 | m_f |= 0x02; |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | | void amis2000_device::op_rf2() |
| 488 | void amis2000_base_device::op_rf2() |
| 489 | 489 | { |
| 490 | 490 | // RF2: reset flag 2 |
| 491 | 491 | m_f &= ~0x02; |