Previous 199869 Revisions Next

r34743 Friday 30th January, 2015 at 18:28:31 UTC by hap
added most straightforward opcodes
[src/emu/cpu/amis2000]amis2000.c amis2000.h amis2000op.inc

trunk/src/emu/cpu/amis2000/amis2000.c
r243254r243255
114114enum
115115{
116116   S2000_PC=1, S2000_BL, S2000_BU,
117   S2000_ACC, S2000_E
117   S2000_ACC, S2000_E, S2000_CARRY
118118};
119119
120120void amis2000_device::device_start()
r243254r243255
134134   // zerofill
135135   memset(m_callstack, 0, sizeof(m_callstack));
136136   m_pc = 0;
137   m_skip = false;
137138   m_op = 0;
138139   m_f = 0;
140   m_carry = 0;
139141   m_bl = 0;
140142   m_bu = 0;
141143   m_acc = 0;
142144   m_e = 0;
145   m_i = 0;
146   m_k = 0;
143147
144148   // register for savestates
145149   save_item(NAME(m_callstack));
146150   save_item(NAME(m_pc));
151   save_item(NAME(m_skip));
147152   save_item(NAME(m_op));
148153   save_item(NAME(m_f));
154   save_item(NAME(m_carry));
149155   save_item(NAME(m_bl));
150156   save_item(NAME(m_bu));
151157   save_item(NAME(m_acc));
152158   save_item(NAME(m_e));
159   save_item(NAME(m_i));
160   save_item(NAME(m_k));
153161
154162   // register state for debugger
155163   state_add(S2000_PC,     "PC",     m_pc    ).formatstr("%04X");
r243254r243255
157165   state_add(S2000_BU,     "BU",     m_bu    ).formatstr("%01X");
158166   state_add(S2000_ACC,    "ACC",    m_acc   ).formatstr("%01X");
159167   state_add(S2000_E,      "E",      m_e     ).formatstr("%01X");
168   state_add(S2000_CARRY,  "CARRY",  m_carry ).formatstr("%01X");
160169
161170   state_add(STATE_GENPC, "curpc", m_pc).formatstr("%04X").noshow();
162171   state_add(STATE_GENFLAGS, "GENFLAGS", m_f).formatstr("%6s").noshow();
r243254r243255
192201      debugger_instruction_hook(this, m_pc);
193202      m_op = m_program->read_byte(m_pc);
194203      m_pc = (m_pc + 1) & 0x1fff;
204     
205      if (m_skip)
206      {
207         // always skip over PP prefix
208         m_skip = ((m_op & 0xf0) == 0x60);
209         continue;
210      }
195211
196212      switch (m_op & 0xf0)
197213      {
trunk/src/emu/cpu/amis2000/amis2000.h
r243254r243255
7878   UINT16 m_callstack[5];      // max 5
7979
8080   UINT16 m_pc;
81   bool m_skip;
8182   UINT8 m_op;
8283   UINT8 m_f;                  // generic flags: 2 on 2000/2150, 6 on 2200/2400
84   UINT8 m_carry;              // carry flag
8385   UINT8 m_bl;                 // 4-bit ram index x
8486   UINT8 m_bu;                 // 2/3-bit ram index y
85   UINT8 m_acc;
86   UINT8 m_e;
87   UINT8 m_acc;                // 4-bit accumulator
88   UINT8 m_e;                  // 4-bit generic register
89   UINT8 m_i;                  // 4-bit i-pins latch
90   UINT8 m_k;                  // 4-bit k-pins latch
8791
8892   devcb_read8 m_read_k;
8993   devcb_read8 m_read_i;
r243254r243255
9397
9498   int m_icount;
9599   
100   UINT8 ram_r();
101   void ram_w(UINT8 data);
96102   void op_illegal();
97103   
98104   void op_lai();
trunk/src/emu/cpu/amis2000/amis2000op.inc
r243254r243255
22
33// internal helpers
44
5UINT8 amis2000_device::ram_r()
6{
7   UINT16 address = m_bu << m_bu_bits | m_bl;
8   return m_data->read_byte(address) & 0xf;
9}
10
11void amis2000_device::ram_w(UINT8 data)
12{
13   UINT16 address = m_bu << m_bu_bits | m_bl;
14   m_data->write_byte(address, data & 0xf);
15}
16
517void amis2000_device::op_illegal()
618{
719   logerror("%s unknown opcode $%02X at $%04X\n", tag(), m_op, m_pc);
r243254r243255
1325void amis2000_device::op_lai()
1426{
1527   // LAI X: load ACC with X, select I and K inputs
16   op_illegal();
28   UINT8 param = m_op & 0x0f;
29   m_acc = param;
30   m_i = m_read_i(0, 0xff) & param;
31   m_k = m_read_k(0, 0xff) & param;
1732}
1833
1934void amis2000_device::op_lab()
2035{
2136   // LAB: load ACC with BL
22   op_illegal();
37   m_acc = m_bl;
2338}
2439
2540void amis2000_device::op_lae()
2641{
2742   // LAE: load ACC with E
28   op_illegal();
43   m_acc = m_e;
2944}
3045
3146void amis2000_device::op_xab()
3247{
3348   // XAB: exchange ACC with BL
34   op_illegal();
49   UINT8 old_acc = m_acc;
50   m_acc = m_bl;
51   m_bl = old_acc;
3552}
3653
3754void amis2000_device::op_xabu()
3855{
3956   // XABU: exchange ACC with BU
40   op_illegal();
57   UINT8 old_acc = m_acc;
58   m_acc = (m_acc & ~m_bu_mask) | (m_bu & m_bu_mask);
59   m_bu = old_acc & m_bu_mask;
4160}
4261
4362void amis2000_device::op_xae()
4463{
4564   // XAE: exchange ACC with E
46   op_illegal();
65   UINT8 old_acc = m_acc;
66   m_acc = m_e;
67   m_e = old_acc;
4768}
4869
4970void amis2000_device::op_lbe()
5071{
5172   // LBE Y: load BU with Y, load BL with E
52   op_illegal();
73   UINT8 param = m_op & 0x03;
74   m_bu = param & m_bu_mask;
75   m_bl = m_e;
5376}
5477
5578void amis2000_device::op_lbep()
5679{
5780   // LBEP Y: load BU with Y, load BL with E+1
58   op_illegal();
81   UINT8 param = m_op & 0x03;
82   m_bu = param & m_bu_mask;
83   m_bl = m_e + 1;
5984}
6085
6186void amis2000_device::op_lbz()
6287{
6388   // LBZ Y: load BU with Y, load BL with 0
64   op_illegal();
89   UINT8 param = m_op & 0x03;
90   m_bu = param & m_bu_mask;
91   m_bl = 0;
6592}
6693
6794void amis2000_device::op_lbf()
6895{
6996   // LBF Y: load BU with Y, load BL with 15
70   op_illegal();
97   UINT8 param = m_op & 0x03;
98   m_bu = param & m_bu_mask;
99   m_bl = 0xf;
71100}
72101
73102
r243254r243255
76105void amis2000_device::op_lam()
77106{
78107   // LAM _Y: load ACC with RAM, xor BU with _Y
79   op_illegal();
108   m_acc = ram_r();
109   UINT8 param = ~m_op & 0x03;
110   m_bu ^= param & m_bu_mask;
80111}
81112
82113void amis2000_device::op_xc()
83114{
84115   // XC _Y: exchange ACC with RAM, xor BU with _Y
85   op_illegal();
116   UINT8 old_acc = m_acc;
117   m_acc = ram_r();
118   ram_w(old_acc);
119   UINT8 param = ~m_op & 0x03;
120   m_bu ^= param & m_bu_mask;
86121}
87122
88123void amis2000_device::op_xci()
89124{
90125   // XCI _Y: exchange ACC with RAM, increment BL(skip next on carry), xor BU with _Y
91   op_illegal();
126   op_xc();
127   m_bl = (m_bl + 1) & 0xf;
128   m_skip = (m_bl == 0);
92129}
93130
94131void amis2000_device::op_xcd()
95132{
96133   // XCD _Y: exchange ACC with RAM, decrement BL(skip next on carry), xor BU with _Y
97   op_illegal();
134   op_xc();
135   m_bl = (m_bl - 1) & 0xf;
136   m_skip = (m_bl == 0xf);
98137}
99138
100139void amis2000_device::op_stm()
101140{
102141   // STM Z: set RAM bit Z
103   op_illegal();
142   UINT8 param = 1 << (m_op & 0x03);
143   ram_w(ram_r() | param);
104144}
105145
106146void amis2000_device::op_rsm()
107147{
108148   // RSM Z: reset RAM bit Z
109   op_illegal();
149   UINT8 param = 1 << (m_op & 0x03);
150   ram_w(ram_r() & ~param);
110151}
111152
112153
r243254r243255
204245void amis2000_device::op_szc()
205246{
206247   // SZC: skip next on zero(no) carry
207   op_illegal();
248   m_skip = !m_carry;
208249}
209250
210251void amis2000_device::op_szm()
211252{
212253   // SZM Z: skip next on zero RAM bit Z
213   op_illegal();
254   UINT8 param = 1 << (m_op & 0x03);
255   m_skip = !(ram_r() & param);
214256}
215257
216258void amis2000_device::op_szi()
217259{
218260   // SZI: skip next on zero I pin(s)
219   op_illegal();
261   m_skip = !m_i;
220262}
221263
222264void amis2000_device::op_szk()
223265{
224266   // SZK: skip next on zero K pin(s)
225   op_illegal();
267   m_skip = !m_k;
226268}
227269
228270void amis2000_device::op_sbe()
229271{
230272   // SBE: skip next on BL equ E
231   op_illegal();
273   m_skip = (m_bl == m_e);
232274}
233275
234276void amis2000_device::op_sam()
235277{
236278   // SAM: skip next on ACC equ RAM
237   op_illegal();
279   m_skip = (m_acc == ram_r());
238280}
239281
240282void amis2000_device::op_sos()
r243254r243255
246288void amis2000_device::op_tf1()
247289{
248290   // TF1: skip next on flag 1
249   op_illegal();
291   m_skip = (m_f & 0x01);
250292}
251293
252294void amis2000_device::op_tf2()
253295{
254296   // TF2: skip next on flag 2
255   op_illegal();
297   m_skip = (m_f & 0x02);
256298}
257299
258300
r243254r243255
261303void amis2000_device::op_adcs()
262304{
263305   // ADCS: add RAM to ACC+carry, skip next on no carry
264   op_illegal();
306   m_acc += ram_r() + m_carry;
307   m_carry = m_acc >> 4 & 1;
308   m_skip = !m_carry;
309   m_acc &= 0xf;
265310}
266311
267312void amis2000_device::op_adis()
268313{
269314   // ADIS X: add X to ACC, skip next on no carry
270   op_illegal();
315   UINT8 param = m_op & 0x0f;
316   m_acc += param;
317   m_skip = !(m_acc >> 4 & 1);
318   m_acc &= 0xf;
271319}
272320
273321void amis2000_device::op_add()
274322{
275323   // ADD: add RAM to ACC
276   op_illegal();
324   m_acc = (m_acc + ram_r()) & 0xf;
277325}
278326
279327void amis2000_device::op_and()
280328{
281329   // AND: and ACC with RAM
282   op_illegal();
330   m_acc &= ram_r();
283331}
284332
285333void amis2000_device::op_xor()
286334{
287335   // XOR: xor ACC with RAM
288   op_illegal();
336   m_acc ^= ram_r();
289337}
290338
291339void amis2000_device::op_stc()
292340{
293341   // STC: set carry
294   op_illegal();
342   m_carry = 1;
295343}
296344
297345void amis2000_device::op_rsc()
298346{
299347   // RSC: reset carry
300   op_illegal();
348   m_carry = 0;
301349}
302350
303351void amis2000_device::op_cma()
304352{
305353   // CMA: complement ACC
306   op_illegal();
354   m_acc ^= 0xf;
307355}
308356
309357void amis2000_device::op_sf1()
310358{
311359   // SF1: set flag 1
312   op_illegal();
360   m_f |= 0x01;
313361}
314362
315363void amis2000_device::op_rf1()
316364{
317365   // RF1: reset flag 1
318   op_illegal();
366   m_f &= ~0x01;
319367}
320368
321369void amis2000_device::op_sf2()
322370{
323371   // SF2: set flag 2
324   op_illegal();
372   m_f |= 0x02;
325373}
326374
327375void amis2000_device::op_rf2()
328376{
329377   // RF2: reset flag 2
330   op_illegal();
378   m_f &= ~0x02;
331379}


Previous 199869 Revisions Next


© 1997-2024 The MAME Team