Previous 199869 Revisions Next

r20067 Saturday 5th January, 2013 at 01:40:33 UTC by Andrew Gardner
dsp16: Added 16-bit immediate load opcode.  [Andrew Gardner]
     Fixed reset behavior.
     Code reorganization.
[src/emu/cpu]cpu.mak
[src/emu/cpu/dsp16]dsp16.c dsp16.h dsp16ops.c*

trunk/src/emu/cpu/dsp16/dsp16.c
r20066r20067
137137
138138void dsp16_device::device_reset()
139139{
140    m_pc = m_ppc = 0x0000;
140   // Page 7-5
141   m_pc = 0x0000;
142   m_sioc = 0x0000;
143   m_pioc = 0x0008;
144   m_rb = 0x0000;
145   m_re = 0x0000;
146   // AUC is not affected by reset
147   m_ppc = m_pc;
141148}
142149
143150
r20066r20067
163170   switch (entry.index())
164171   {
165172      case STATE_GENFLAGS:
166      string.printf("(see below)");
173      string.printf("(multiple below)");
167174         break;
168175
169176      // Placeholder for a better view later (TODO)
r20066r20067
294301   } while (m_icount > 0);
295302}
296303
297
298void dsp16_device::execute_one(const UINT16 op, UINT8& cycles, UINT8& pcAdvance)
299{
300   cycles = 1;
301   pcAdvance = 1;
302
303   const UINT8 opcode = (op >> 11) & 0x1f;
304   switch(opcode)
305   {
306      // Format 1: Multiply/ALU Read/Write Group
307      case 0x06:
308      {
309         // F1, Y
310         //const UINT8 Y = (op & 0x000f);
311         //const UINT8 S = (op & 0x0200) >> 9;
312         //const UINT8 D = (op & 0x0400) >> 10;
313         //const UINT8 F1 = (op & 0x01e0) >> 5;
314         break;
315      }
316      case 0x04: case 0x1c:
317      {
318         // F1 Y=a0[1] | F1 Y=a1[1]
319         //const UINT8 Y = (op & 0x000f);
320         //const UINT8 S = (op & 0x0200) >> 9;
321         //const UINT8 D = (op & 0x0400) >> 10;
322         //const UINT8 F1 = (op & 0x01e0) >> 5;
323         break;
324      }
325      case 0x16:
326      {
327         // F1, x = Y
328         //const UINT8 Y = (op & 0x000f);
329         //const UINT8 S = (op & 0x0200) >> 9;
330         //const UINT8 D = (op & 0x0400) >> 10;
331         //const UINT8 F1 = (op & 0x01e0) >> 5;
332         break;
333      }
334      case 0x17:
335      {
336         // F1, y[l] = Y
337         //const UINT8 Y = (op & 0x000f);
338         //const UINT8 X = (op & 0x0010) >> 4;
339         //const UINT8 S = (op & 0x0200) >> 9;
340         //const UINT8 D = (op & 0x0400) >> 10;
341         //const UINT8 F1 = (op & 0x01e0) >> 5;
342         break;
343      }
344      case 0x1f:
345      {
346         // F1, y = Y, x = *pt++[i]
347         //const UINT8 Y = (op & 0x000f);
348         //const UINT8 X = (op & 0x0010) >> 4;
349         //const UINT8 S = (op & 0x0200) >> 9;
350         //const UINT8 D = (op & 0x0400) >> 10;
351         //const UINT8 F1 = (op & 0x01e0) >> 5;
352         break;
353      }
354      case 0x19: case 0x1b:
355      {
356         // F1, y = a0|1, x = *pt++[i]
357         //const UINT8 Y = (op & 0x000f);
358         //const UINT8 X = (op & 0x0010) >> 4;
359         //const UINT8 S = (op & 0x0200) >> 9;
360         //const UINT8 D = (op & 0x0400) >> 10;
361         //const UINT8 F1 = (op & 0x01e0) >> 5;
362         break;
363      }
364      case 0x14:
365      {
366         // F1, Y = y[1]
367         //const UINT8 Y = (op & 0x000f);
368         //const UINT8 X = (op & 0x0010) >> 4;
369         //const UINT8 S = (op & 0x0200) >> 9;
370         //const UINT8 D = (op & 0x0400) >> 10;
371         //const UINT8 F1 = (op & 0x01e0) >> 5;
372         break;
373      }
374
375      // Format 1a: Multiply/ALU Read/Write Group (major typo in docs on p3-51)
376      case 0x07:
377      {
378         // F1, At[1] = Y
379         //const UINT8 Y = (op & 0x000f);
380         //const UINT8 S = (op & 0x0200) >> 9;
381         //const UINT8 aT = (op & 0x0400) >> 10;
382         //const UINT8 F1 = (op & 0x01e0) >> 5;
383         break;
384      }
385
386      // Format 2: Multiply/ALU Read/Write Group
387      case 0x15:
388      {
389         // F1, Z : y[1]
390         //const UINT8 Z = (op & 0x000f);
391         //const UINT8 X = (op & 0x0010) >> 4;
392         //const UINT8 S = (op & 0x0200) >> 9;
393         //const UINT8 D = (op & 0x0400) >> 10;
394         //const UINT8 F1 = (op & 0x01e0) >> 5;
395         break;
396      }
397      case 0x1d:
398      {
399         // F1, Z : y, x=*pt++[i]
400         //const UINT8 Z = (op & 0x000f);
401         //const UINT8 X = (op & 0x0010) >> 4;
402         //const UINT8 S = (op & 0x0200) >> 9;
403         //const UINT8 D = (op & 0x0400) >> 10;
404         //const UINT8 F1 = (op & 0x01e0) >> 5;
405         break;
406      }
407
408      // Format 2a: Multiply/ALU Read/Write Group
409      case 0x05:
410      {
411         // F1, Z : aT[1]
412         //const UINT8 Z = (op & 0x000f);
413         //const UINT8 X = (op & 0x0010) >> 4;
414         //const UINT8 S = (op & 0x0200) >> 9;
415         //const UINT8 aT = (op & 0x0400) >> 10;
416         //const UINT8 F1 = (op & 0x01e0) >> 5;
417         break;
418      }
419
420      // Format 3: Special Functions
421      case 0x12:
422      case 0x13:
423      {
424         // if|ifc CON F2
425         //const UINT8 CON = (op & 0x001f);
426         //const UINT8 S = (op & 0x0200) >> 9;
427         //const UINT8 D = (op & 0x0400) >> 10;
428         //const UINT8 F2 = (op & 0x01e0) >> 5;
429         break;
430      }
431
432      // Format 4: Branch Direct Group
433      case 0x00: case 0x01:
434      {
435         // goto JA
436         const UINT16 JA = (op & 0x0fff) | (m_pc & 0xf000);
437         m_pc = JA;
438         pcAdvance = 0;
439         break;
440      }
441
442      case 0x10: case 0x11:
443      {
444         // call JA
445         //const UINT16 JA = (op & 0x0fff) | (m_pc & 0xf000);
446         break;
447      }
448
449      // Format 5: Branch Indirect Group
450      case 0x18:
451      {
452         // goto B
453         //const UINT8 B = (op & 0x0700) >> 8;
454         break;
455      }
456
457      // Format 6: Contitional Branch Qualifier/Software Interrupt (icall)
458      case 0x1a:
459      {
460         // if CON [goto/call/return]
461         //const UINT8 CON = (op & 0x001f);
462         break;
463      }
464
465      // Format 7: Data Move Group
466      case 0x09: case 0x0b:
467      {
468         // R = aS
469         //const UINT8 R = (op & 0x03f0) >> 4;
470         //const UINT8 S = (op & 0x1000) >> 12;
471         break;
472      }
473      case 0x08:
474      {
475         // aT = R
476         //const UINT8 R  = (op & 0x03f0) >> 4;
477         //const UINT8 aT = (op & 0x0400) >> 10;
478         break;
479      }
480      case 0x0f:
481      {
482         // R = Y
483         //const UINT8 Y = (op & 0x000f);
484         //const UINT8 R = (op & 0x03f0) >> 4;
485         break;
486      }
487      case 0x0c:
488      {
489         // Y = R
490         //const UINT8 Y = (op & 0x000f);
491         //const UINT8 R = (op & 0x03f0) >> 4;
492         break;
493      }
494      case 0x0d:
495      {
496         // Z : R
497         //const UINT8 Z = (op & 0x000f);
498         //const UINT8 R = (op & 0x03f0) >> 4;
499         break;
500      }
501
502      // Format 8: Data Move (immediate operand - 2 words)
503      case 0x0a:
504      {
505         // R = N
506         //const UINT8 R = (op & 0x03f0) >> 4;
507         pcAdvance++;
508         break;
509      }
510
511      // Format 9: Short Immediate Group
512      case 0x02: case 0x03:
513      {
514         // R = M
515         //const UINT8 M = (op & 0x00ff);
516         //const UINT8 R = (op & 0x0e00) >> 9;
517         break;
518      }
519
520      // Format 10: do - redo
521      case 0x0e:
522      {
523         // do|redo K
524         //const UINT8 K = (op & 0x007f);
525         //const UINT8 NI = (op & 0x0780) >> 7;
526         break;
527      }
528
529      // RESERVED
530      case 0x1e:
531      {
532         break;
533      }
534
535      // UNKNOWN
536      default:
537      {
538         break;
539      }
540   }
541}
304#include "dsp16ops.c"
trunk/src/emu/cpu/dsp16/dsp16ops.c
r0r20067
1#include "dsp16.h"
2
3
4// The YL register is the lower half of the 32 bit Y register
5void* dsp16_device::addressYL()
6{
7   return (((UINT8*)&m_y)+0x4);
8}
9
10void* dsp16_device::registerFromRTable(const UINT8 &R)
11{
12   switch (R)
13   {
14      case 0x00: return (void*)&m_r0;
15      case 0x01: return (void*)&m_r1;
16      case 0x02: return (void*)&m_r2;
17      case 0x03: return (void*)&m_r3;
18      case 0x04: return (void*)&m_j;
19      case 0x05: return (void*)&m_k;
20      case 0x06: return (void*)&m_rb;
21      case 0x07: return (void*)&m_re;
22      case 0x08: return (void*)&m_pt;
23      case 0x09: return (void*)&m_pr;
24      case 0x0a: return (void*)&m_pi;
25      case 0x0b: return (void*)&m_i;
26
27      case 0x10: return (void*)&m_x;
28      case 0x11: return (void*)&m_y;
29      case 0x12: return (void*)addressYL();
30      case 0x13: return (void*)&m_auc;
31      case 0x14: return (void*)&m_psw;
32      case 0x15: return (void*)&m_c0;
33      case 0x16: return (void*)&m_c1;
34      case 0x17: return (void*)&m_c2;
35      case 0x18: return (void*)&m_sioc;
36      //case 0x19: return (void*)&m_srta;
37      //case 0x1a: return (void*)&m_sdx;
38      //case 0x1b: return (void*)&m_tdms;
39      case 0x1c: return (void*)&m_pioc;
40      //case 0x1d: return (void*)&m_pdx0;
41      //case 0x1e: return (void*)&m_pdx1;
42
43      default: return NULL;
44   }
45   return NULL;
46}
47
48
49void dsp16_device::execute_one(const UINT16& op, UINT8& cycles, UINT8& pcAdvance)
50{
51   cycles = 1;
52   pcAdvance = 1;
53
54   const UINT8 opcode = (op >> 11) & 0x1f;
55   switch(opcode)
56   {
57      // Format 1: Multiply/ALU Read/Write Group
58      case 0x06:
59      {
60         // F1, Y
61         //const UINT8 Y = (op & 0x000f);
62         //const UINT8 S = (op & 0x0200) >> 9;
63         //const UINT8 D = (op & 0x0400) >> 10;
64         //const UINT8 F1 = (op & 0x01e0) >> 5;
65         break;
66      }
67      case 0x04: case 0x1c:
68      {
69         // F1 Y=a0[1] | F1 Y=a1[1]
70         //const UINT8 Y = (op & 0x000f);
71         //const UINT8 S = (op & 0x0200) >> 9;
72         //const UINT8 D = (op & 0x0400) >> 10;
73         //const UINT8 F1 = (op & 0x01e0) >> 5;
74         break;
75      }
76      case 0x16:
77      {
78         // F1, x = Y
79         //const UINT8 Y = (op & 0x000f);
80         //const UINT8 S = (op & 0x0200) >> 9;
81         //const UINT8 D = (op & 0x0400) >> 10;
82         //const UINT8 F1 = (op & 0x01e0) >> 5;
83         break;
84      }
85      case 0x17:
86      {
87         // F1, y[l] = Y
88         //const UINT8 Y = (op & 0x000f);
89         //const UINT8 X = (op & 0x0010) >> 4;
90         //const UINT8 S = (op & 0x0200) >> 9;
91         //const UINT8 D = (op & 0x0400) >> 10;
92         //const UINT8 F1 = (op & 0x01e0) >> 5;
93         break;
94      }
95      case 0x1f:
96      {
97         // F1, y = Y, x = *pt++[i]
98         //const UINT8 Y = (op & 0x000f);
99         //const UINT8 X = (op & 0x0010) >> 4;
100         //const UINT8 S = (op & 0x0200) >> 9;
101         //const UINT8 D = (op & 0x0400) >> 10;
102         //const UINT8 F1 = (op & 0x01e0) >> 5;
103         break;
104      }
105      case 0x19: case 0x1b:
106      {
107         // F1, y = a0|1, x = *pt++[i]
108         //const UINT8 Y = (op & 0x000f);
109         //const UINT8 X = (op & 0x0010) >> 4;
110         //const UINT8 S = (op & 0x0200) >> 9;
111         //const UINT8 D = (op & 0x0400) >> 10;
112         //const UINT8 F1 = (op & 0x01e0) >> 5;
113         break;
114      }
115      case 0x14:
116      {
117         // F1, Y = y[1]
118         //const UINT8 Y = (op & 0x000f);
119         //const UINT8 X = (op & 0x0010) >> 4;
120         //const UINT8 S = (op & 0x0200) >> 9;
121         //const UINT8 D = (op & 0x0400) >> 10;
122         //const UINT8 F1 = (op & 0x01e0) >> 5;
123         break;
124      }
125
126      // Format 1a: Multiply/ALU Read/Write Group (major typo in docs on p3-51)
127      case 0x07:
128      {
129         // F1, At[1] = Y
130         //const UINT8 Y = (op & 0x000f);
131         //const UINT8 S = (op & 0x0200) >> 9;
132         //const UINT8 aT = (op & 0x0400) >> 10;
133         //const UINT8 F1 = (op & 0x01e0) >> 5;
134         break;
135      }
136
137      // Format 2: Multiply/ALU Read/Write Group
138      case 0x15:
139      {
140         // F1, Z : y[1]
141         //const UINT8 Z = (op & 0x000f);
142         //const UINT8 X = (op & 0x0010) >> 4;
143         //const UINT8 S = (op & 0x0200) >> 9;
144         //const UINT8 D = (op & 0x0400) >> 10;
145         //const UINT8 F1 = (op & 0x01e0) >> 5;
146         break;
147      }
148      case 0x1d:
149      {
150         // F1, Z : y, x=*pt++[i]
151         //const UINT8 Z = (op & 0x000f);
152         //const UINT8 X = (op & 0x0010) >> 4;
153         //const UINT8 S = (op & 0x0200) >> 9;
154         //const UINT8 D = (op & 0x0400) >> 10;
155         //const UINT8 F1 = (op & 0x01e0) >> 5;
156         break;
157      }
158
159      // Format 2a: Multiply/ALU Read/Write Group
160      case 0x05:
161      {
162         // F1, Z : aT[1]
163         //const UINT8 Z = (op & 0x000f);
164         //const UINT8 X = (op & 0x0010) >> 4;
165         //const UINT8 S = (op & 0x0200) >> 9;
166         //const UINT8 aT = (op & 0x0400) >> 10;
167         //const UINT8 F1 = (op & 0x01e0) >> 5;
168         break;
169      }
170
171      // Format 3: Special Functions
172      case 0x12:
173      case 0x13:
174      {
175         // if|ifc CON F2
176         //const UINT8 CON = (op & 0x001f);
177         //const UINT8 S = (op & 0x0200) >> 9;
178         //const UINT8 D = (op & 0x0400) >> 10;
179         //const UINT8 F2 = (op & 0x01e0) >> 5;
180         break;
181      }
182
183      // Format 4: Branch Direct Group
184      case 0x00: case 0x01:
185      {
186         // goto JA
187         const UINT16 JA = (op & 0x0fff) | (m_pc & 0xf000);
188         m_pc = JA;
189         cycles = 2;
190         pcAdvance = 0;
191         break;
192      }
193
194      case 0x10: case 0x11:
195      {
196         // call JA
197         //const UINT16 JA = (op & 0x0fff) | (m_pc & 0xf000);
198         break;
199      }
200
201      // Format 5: Branch Indirect Group
202      case 0x18:
203      {
204         // goto B
205         //const UINT8 B = (op & 0x0700) >> 8;
206         break;
207      }
208
209      // Format 6: Contitional Branch Qualifier/Software Interrupt (icall)
210      case 0x1a:
211      {
212         // if CON [goto/call/return]
213         //const UINT8 CON = (op & 0x001f);
214         break;
215      }
216
217      // Format 7: Data Move Group
218      case 0x09: case 0x0b:
219      {
220         // R = aS
221         //const UINT8 R = (op & 0x03f0) >> 4;
222         //const UINT8 S = (op & 0x1000) >> 12;
223         break;
224      }
225      case 0x08:
226      {
227         // aT = R
228         //const UINT8 R  = (op & 0x03f0) >> 4;
229         //const UINT8 aT = (op & 0x0400) >> 10;
230         break;
231      }
232      case 0x0f:
233      {
234         // R = Y
235         //const UINT8 Y = (op & 0x000f);
236         //const UINT8 R = (op & 0x03f0) >> 4;
237         break;
238      }
239      case 0x0c:
240      {
241         // Y = R
242         //const UINT8 Y = (op & 0x000f);
243         //const UINT8 R = (op & 0x03f0) >> 4;
244         break;
245      }
246      case 0x0d:
247      {
248         // Z : R
249         //const UINT8 Z = (op & 0x000f);
250         //const UINT8 R = (op & 0x03f0) >> 4;
251         break;
252      }
253
254      // Format 8: Data Move (immediate operand - 2 words)
255      case 0x0a:
256      {
257         // R = N
258         const UINT8 R = (op & 0x03f0) >> 4;
259         const UINT16 iVal = opcode_read(1);
260         void* reg = registerFromRTable(R);
261         if (reg == &m_auc || reg == &m_c0 || reg == &m_c1 || reg == &m_c2)
262         {
263            *(UINT8*)reg = iVal & 0x00ff;   // 8 bit registers
264         }
265         else if (reg == &m_i)
266         {
267            *(UINT16*)reg = iVal & 0x0fff;   // 12 bit register
268         }
269         else if (reg == &m_y || reg == addressYL())
270         {
271            *(UINT16*)reg = iVal;      // Temporary
272            //writeYxRegister(iVal);   // TODO
273         }
274         else
275         {
276            *(UINT16*)reg = iVal;         // The rest
277         }
278
279         cycles = 2;
280         pcAdvance = 2;
281         break;
282      }
283
284      // Format 9: Short Immediate Group
285      case 0x02: case 0x03:
286      {
287         // R = M
288         //const UINT8 M = (op & 0x00ff);
289         //const UINT8 R = (op & 0x0e00) >> 9;
290         break;
291      }
292
293      // Format 10: do - redo
294      case 0x0e:
295      {
296         // do|redo K
297         //const UINT8 K = (op & 0x007f);
298         //const UINT8 NI = (op & 0x0780) >> 7;
299         break;
300      }
301
302      // RESERVED
303      case 0x1e:
304      {
305         break;
306      }
307
308      // UNKNOWN
309      default:
310      {
311         break;
312      }
313   }
314}
trunk/src/emu/cpu/dsp16/dsp16.h
r20066r20067
8888   UINT8 m_c0;
8989   UINT8 m_c1;
9090   UINT8 m_c2;
91   // Serial, parallel, etc.
91   // Serial and parallel interfaces
9292   UINT16 m_sioc;
9393   UINT16 m_pioc;
9494
r20066r20067
108108    int m_icount;
109109
110110   // operations
111   void execute_one(const UINT16 op, UINT8& cycles, UINT8& pcAdvance);
111   void execute_one(const UINT16& op, UINT8& cycles, UINT8& pcAdvance);
112
113   void* registerFromRTable(const UINT8& R);
114
115   // helpers
116   void* addressYL();
117   //void writeYxRegister(const UINT16& value);
112118};
113119
114120
trunk/src/emu/cpu/cpu.mak
r20066r20067
197197DASMOBJS += $(CPUOBJ)/dsp16/dsp16dis.o
198198endif
199199
200$(CPUOBJ)/dsp16/dsp16.o:   $(CPUSRC)/dsp16/dsp16.c \
200$(CPUOBJ)/dsp16/dsp16.o:   $(CPUSRC)/dsp16/dsp16ops.c \
201                     $(CPUSRC)/dsp16/dsp16.c \
201202                     $(CPUSRC)/dsp16/dsp16.h
202203
203204

Previous 199869 Revisions Next


© 1997-2024 The MAME Team