Previous 199869 Revisions Next

r20224 Saturday 12th January, 2013 at 20:34:11 UTC by Andrew Gardner
DSP16: Additional opcodes & disassembly fixes.  [Andrew Gardner]
[src/emu/cpu/dsp16]dsp16.c dsp16.h dsp16dis.c dsp16ops.c

trunk/src/emu/cpu/dsp16/dsp16.c
r20223r20224
3030
3131dsp16_device::dsp16_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
3232   : cpu_device(mconfig, DSP16, "DSP16", tag, owner, clock),
33      m_program_config("program", ENDIANNESS_LITTLE, 16, 16, -1),
34      m_data_config("data", ENDIANNESS_LITTLE, 16, 16, -1),
35      m_i(0),
36      m_pc(0),
37      m_pt(0),
38      m_pr(0),
39      m_pi(0),
40      m_j(0),
41      m_k(0),
42      m_rb(0),
43      m_re(0),
44      m_r0(0),
45      m_r1(0),
46      m_r2(0),
47      m_r3(0),
48      m_x(0),
49      m_y(0),
50      m_p(0),
51      m_a0(0),
52      m_a1(0),
53      m_auc(0),
54      m_psw(0),
55      m_c0(0),
56      m_c1(0),
57      m_c2(0),
58      m_sioc(0),
59      m_pioc(0),
60      m_ppc(0),
61      m_cacheStart(CACHE_INVALID),
62      m_cacheEnd(CACHE_INVALID),
63      m_cacheRedoNextPC(CACHE_INVALID),
64      m_cacheIterations(0),
65      m_program(NULL),
66      m_data(NULL),
67      m_direct(NULL),
68      m_icount(0)
33     m_program_config("program", ENDIANNESS_LITTLE, 16, 16, -1),
34     m_data_config("data", ENDIANNESS_LITTLE, 16, 16, -1),
35     m_i(0),
36     m_pc(0),
37     m_pt(0),
38     m_pr(0),
39     m_pi(0),
40     m_j(0),
41     m_k(0),
42     m_rb(0),
43     m_re(0),
44     m_r0(0),
45     m_r1(0),
46     m_r2(0),
47     m_r3(0),
48     m_x(0),
49     m_y(0),
50     m_p(0),
51     m_a0(0),
52     m_a1(0),
53     m_auc(0),
54     m_psw(0),
55     m_c0(0),
56     m_c1(0),
57     m_c2(0),
58     m_sioc(0),
59     m_srta(0),
60     m_pioc(0),
61     m_ppc(0),
62     m_cacheStart(CACHE_INVALID),
63     m_cacheEnd(CACHE_INVALID),
64     m_cacheRedoNextPC(CACHE_INVALID),
65     m_cacheIterations(0),
66     m_program(NULL),
67     m_data(NULL),
68     m_direct(NULL),
69     m_icount(0)
6970{
7071   // Allocate & setup
7172}
r20223r20224
106107   state_add(DSP16_C1,       "C1",        m_c1);
107108   state_add(DSP16_C2,       "C2",        m_c2);
108109   state_add(DSP16_SIOC,     "SIOC",      m_sioc).formatstr("%16s");
110   state_add(DSP16_SRTA,     "SRTA",      m_srta);
109111   state_add(DSP16_PIOC,     "PIOC",      m_pioc); //.formatstr("%16s");
110112
111113   // register our state for saving
r20223r20224
133135   save_item(NAME(m_c1));
134136   save_item(NAME(m_c2));
135137   save_item(NAME(m_sioc));
138   save_item(NAME(m_srta));
136139   save_item(NAME(m_pioc));
137140   save_item(NAME(m_ppc));
138141   save_item(NAME(m_cacheStart));
r20223r20224
159162   // Page 7-5
160163   m_pc = 0x0000;
161164   m_sioc = 0x0000;
165   // SRTA is unaltered by reset
162166   m_pioc = 0x0008;
163167   m_rb = 0x0000;
164168   m_re = 0x0000;
r20223r20224
182186const address_space_config *dsp16_device::memory_space_config(address_spacenum spacenum) const
183187{
184188   return (spacenum == AS_PROGRAM) ? &m_program_config :
185         (spacenum == AS_DATA) ? &m_data_config :
186         NULL;
189         (spacenum == AS_DATA) ? &m_data_config :
190         NULL;
187191}
188192
189193
r20223r20224
312316   do
313317   {
314318      // debugging
315      m_ppc = m_pc;   // copy PC to previous PC
319      m_ppc = m_pc;   // copy PC to previous PC
316320      debugger_instruction_hook(this, m_pc);
317321
318322      // instruction fetch & execute
trunk/src/emu/cpu/dsp16/dsp16dis.c
r20223r20224
111111
112112      default: return "UNKNOWN";
113113   }
114   return "";
114   return ret;
115115}
116116
117117astring disasmCONField(const UINT8& CON)
r20223r20224
234234{
235235   switch (SI)
236236   {
237      case 0x00: return 0;    // Not a software interrupt
238      case 0x01: return 1;    // Software Interrupt
237      case 0x00: return 0;   // Not a software interrupt
238      case 0x01: return 1;   // Software Interrupt
239239   }
240240   return false;
241241}
r20223r20224
270270      {
271271         // F1 Y=a0[1] | F1 Y=a1[1]
272272         const UINT8 Y = (op & 0x000f);
273         const UINT8 X = (op & 0x0010) >> 4;
273274         const UINT8 S = (op & 0x0200) >> 9;
274275         const UINT8 D = (op & 0x0400) >> 10;
275276         const UINT8 F1 = (op & 0x01e0) >> 5;
276277         astring yString = disasmYField(Y);
277278         astring fString = disasmF1Field(F1, D, S);
278279         astring aString = (opcode == 0x1c) ? "a0" : "a1";
279         sprintf(buffer, "%s = %s, %s", yString.cstr(), aString.cstr(), fString.cstr());
280         astring xString = (X) ? "" : "l";
281         sprintf(buffer, "%s = %s%s, %s", yString.cstr(), aString.cstr(), xString.cstr(), fString.cstr());
280282         break;
281283      }
282284      case 0x16:
trunk/src/emu/cpu/dsp16/dsp16ops.c
r20223r20224
4545}
4646
4747
48bool dsp16_device::conditionTest(const UINT8& CON)
49{
50   switch (CON)
51   {
52      case 0x00: return (m_psw & 0x8000);
53      case 0x01: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
54      case 0x02: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
55      case 0x03: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
56      case 0x04: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
57      case 0x05: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
58      case 0x06: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
59      case 0x07: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
60      case 0x08: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
61      case 0x09: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
62      case 0x0a: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
63      case 0x0b: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
64      case 0x0c: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
65      case 0x0d: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
66      case 0x0e: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
67      case 0x0f: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
68      case 0x10: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
69      case 0x11: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
70      default: logerror("Unrecognized condition at PC=0x%04x\n", m_pc); break;
71   }
72   return false;
73}
74
75
4876void* dsp16_device::registerFromRImmediateField(const UINT8& R)
4977{
5078   switch (R)
r20223r20224
90118      case 0x16: return (void*)&m_c1;
91119      case 0x17: return (void*)&m_c2;
92120      case 0x18: return (void*)&m_sioc;
93      //case 0x19: return (void*)&m_srta;
121      case 0x19: return (void*)&m_srta;
94122      //case 0x1a: return (void*)&m_sdx;
95123      //case 0x1b: return (void*)&m_tdms;
96124      case 0x1c: return (void*)&m_pioc;
r20223r20224
109137   //UINT64* destinationReg = NULL;
110138   //switch (D)
111139   //{
112   //  case 0x00: destinationReg = &m_a0;
113   //  case 0x01: destinationReg = &m_a1;
114   //  default: break;
140   //   case 0x00: destinationReg = &m_a0;
141   //   case 0x01: destinationReg = &m_a1;
142   //   default: break;
115143   //}
116144
117145   // Which source is being used?
118146   //UINT64* sourceReg = NULL;
119147   //switch (S)
120148   //{
121   //  case 0x00: sourceReg = &m_a0;
122   //  case 0x01: sourceReg = &m_a1;
123   //  default: break;
149   //   case 0x00: sourceReg = &m_a0;
150   //   case 0x01: sourceReg = &m_a1;
151   //   default: break;
124152   //}
125
153   
126154   switch (F1)
127155   {
128156      case 0x00: printf("UNIMPLEMENTED F1 operation @ PC 0x%04x\n", m_pc); break;
r20223r20224
173201      case 0x03: opReg = &m_r3; break;
174202      default: break;
175203   }
176
204   
177205   const UINT8 lower = Y & 0x03;
178206   switch (lower)
179207   {
r20223r20224
209237      }
210238      case 0x04: case 0x1c:
211239      {
212         // F1 Y=a0[1] | F1 Y=a1[1]
213         //const UINT8 Y = (op & 0x000f);
214         //const UINT8 S = (op & 0x0200) >> 9;
215         //const UINT8 D = (op & 0x0400) >> 10;
216         //const UINT8 F1 = (op & 0x01e0) >> 5;
240         // F1 Y=a0[1] | F1 Y=a1[1]  :  (page 3-40)
241         const UINT8 Y = (op & 0x000f);
242         const UINT8 X = (op & 0x0010) >> 4;
243         const UINT8 S = (op & 0x0200) >> 9;
244         const UINT8 D = (op & 0x0400) >> 10;
245         const UINT8 F1 = (op & 0x01e0) >> 5;
246         UINT16* destinationReg = (UINT16*)registerFromYFieldUpper(Y);
247         UINT16 aRegValue = 0x0000;
248         if (op & 0xc000)
249         {
250            aRegValue = (X) ? (m_a0 & 0x0ffff0000) >> 16 : m_a0 & 0x00000ffff;
251         }
252         else
253         {
254            aRegValue = (X) ? (m_a1 & 0x0ffff0000) >> 16 : m_a1 & 0x00000ffff;
255         }
256         data_write(*destinationReg, aRegValue);
257         executeYFieldPost(Y);
258         executeF1Field(F1, D, S);
259         cycles = 2;
260         pcAdvance = 1;
217261         break;
218262      }
219263      case 0x16:
r20223r20224
259303      }
260304      case 0x19: case 0x1b:
261305      {
262         // F1, y = a0|1, x = *pt++[i]
306         // NEXT!
307         // F1, y = a0|1, x = *pt++[i]  :  (page 3-48)
263308         //const UINT8 Y = (op & 0x000f);
264309         //const UINT8 X = (op & 0x0010) >> 4;
265310         //const UINT8 S = (op & 0x0200) >> 9;
r20223r20224
355400      case 0x13:
356401      {
357402         // if|ifc CON F2
358         //const UINT8 CON = (op & 0x001f);
403         const UINT8 CON = (op & 0x001f);
359404         //const UINT8 S = (op & 0x0200) >> 9;
360405         //const UINT8 D = (op & 0x0400) >> 10;
361406         //const UINT8 F2 = (op & 0x01e0) >> 5;
407         bool conditionFulfilled = conditionTest(CON);
408         if (conditionFulfilled)
409         {
410            printf("Fulfilled condition not yet implemented @ PC=0x%04x", m_pc);
411         }
412         cycles = 1;
413         pcAdvance = 1;
362414         break;
363415      }
364416
r20223r20224
387439      // Format 5: Branch Indirect Group
388440      case 0x18:
389441      {
390         // goto B
391         //const UINT8 B = (op & 0x0700) >> 8;
442         // goto B  :  (page 3-21)
443         const UINT8 B = (op & 0x0700) >> 8;
444         switch (B)
445         {
446            case 0x00: m_pc = m_pr; break;
447            case 0x01: printf("UNIMPLEMENTED branch instruction @ PC 0x%04x\n", m_pc); break;
448            case 0x02: printf("UNIMPLEMENTED branch instruction @ PC 0x%04x\n", m_pc); break;
449            case 0x03: printf("UNIMPLEMENTED branch instruction @ PC 0x%04x\n", m_pc); break;
450            default: logerror("DSP16: Invalid branch indirect instruction executed at PC=0x%04x\n.", m_pc); break;
451         }
452         cycles = 2;
453         pcAdvance = 0;
392454         break;
393455      }
394456
r20223r20224
417479      }
418480      case 0x0f:
419481      {
420         // R = Y
421         //const UINT8 Y = (op & 0x000f);
422         //const UINT8 R = (op & 0x03f0) >> 4;
482         // R = Y  :  (page 3-32)
483         const UINT8 Y = (op & 0x000f);
484         const UINT8 R = (op & 0x03f0) >> 4;
485         UINT16* sourceReg = (UINT16*)registerFromYFieldUpper(Y);
486         void* destinationReg = registerFromRTable(R);
487         writeRegister(destinationReg, data_read(*sourceReg));
488         executeYFieldPost(Y);
489         cycles = 2;
490         pcAdvance = 1;
423491         break;
424492      }
425493      case 0x0c:
r20223r20224
463531         const INT8 M = (op & 0x00ff);
464532         const UINT8 R = (op & 0x0e00) >> 9;
465533         void* reg = registerFromRImmediateField(R);
466         writeRegister(reg, (INT16)M);   // Sign extend 8 bit int
534         writeRegister(reg, (INT16)M);   // Sign extend 8 bit int
467535         cycles = 1;
468536         pcAdvance = 1;
469537         break;
r20223r20224
480548            // Do
481549            m_cacheStart = m_pc + 1;
482550            m_cacheEnd = m_pc + NI + 1;
483            m_cacheIterations = K-1;    // -1 because we check the counter below
551            m_cacheIterations = K-1;   // -1 because we check the counter below
484552            cycles = 1;
485553            pcAdvance = 1;
486554         }
487555         else
488556         {
489557            // Redo
490            m_cacheIterations = K-1;    // -1 because we check the counter below
558            m_cacheIterations = K-1;   // -1 because we check the counter below
491559            m_cacheRedoNextPC = m_pc + 1;
492560            m_pc = m_cacheStart;
493561            pcAdvance = 0;
trunk/src/emu/cpu/dsp16/dsp16.h
r20223r20224
5555
5656   // CPU registers
5757   // ROM Address Arithmetic Unit (XAAU)
58   UINT16 m_i;     // 12 bits
58   UINT16 m_i;      // 12 bits
5959   UINT16 m_pc;
6060   UINT16 m_pt;
6161   UINT16 m_pr;
r20223r20224
7373   UINT16 m_x;
7474   UINT32 m_y;
7575   UINT32 m_p;
76   UINT64 m_a0;    // 36 bits
77   UINT64 m_a1;    // 36 bits
78   UINT8 m_auc;    // 6 bits
76   UINT64 m_a0;   // 36 bits
77   UINT64 m_a1;   // 36 bits
78   UINT8 m_auc;   // 6 bits
7979   UINT16 m_psw;
8080   UINT8 m_c0;
8181   UINT8 m_c1;
8282   UINT8 m_c2;
8383   // Serial and parallel interfaces
8484   UINT16 m_sioc;
85   UINT16 m_srta;
8586   UINT16 m_pioc;
8687
8788   // internal stuff
r20223r20224
123124   // helpers
124125   void* addressYL();
125126   void writeRegister(void* reg, const UINT16& value);
127   bool conditionTest(const UINT8& CON);
126128};
127129
128130
r20223r20224
136138
137139enum
138140{
139   DSP16_I,        // ROM Address Arithmetic Unit (XAAU)
141   DSP16_I,      // ROM Address Arithmetic Unit (XAAU)
140142   DSP16_PC,
141143   DSP16_PT,
142144   DSP16_PR,
143145   DSP16_PI,
144   DSP16_J,        // RAM Address Arithmetic Unit (YAAU)
146   DSP16_J,      // RAM Address Arithmetic Unit (YAAU)
145147   DSP16_K,
146148   DSP16_RB,
147149   DSP16_RE,
r20223r20224
149151   DSP16_R1,
150152   DSP16_R2,
151153   DSP16_R3,
152   DSP16_X,        // Data Arithmetic Unit (DAU)
154   DSP16_X,      // Data Arithmetic Unit (DAU)
153155   DSP16_Y,
154156   DSP16_P,
155157   DSP16_A0,
r20223r20224
160162   DSP16_C1,
161163   DSP16_C2,
162164   DSP16_SIOC,
165   DSP16_SRTA,
163166   DSP16_PIOC
164167};
165168

Previous 199869 Revisions Next


© 1997-2024 The MAME Team