Previous 199869 Revisions Next

r20275 Tuesday 15th January, 2013 at 05:35:38 UTC by Andrew Gardner
DSP16: The PC moves on from potentially all used opcodes now.  [Andrew Gardner]

Out of whatsnew.txt:
I believe I've roughed in each of the opcodes the QSound program uses (every
opcode the dsp16 has except three, apparently).  Even without all flags being
set and conditions being tested, reasonable memory regions are being accessed. 
Unfortunately, though, I've found what I believe to be my first bad opcode
(at PC=03e6 and will have to do a bit of spelunking to see what I can make of
that).
[src/emu/cpu/dsp16]dsp16.c dsp16.h dsp16dis.c dsp16ops.c

trunk/src/emu/cpu/dsp16/dsp16dis.c
r20274r20275
505505         const UINT8 R = (op & 0x03f0) >> 4;
506506         astring yString = disasmYField(Y);
507507         astring rString = disasmRField(R);
508            // TODO: page 3-31 "special function encoding"
508509         sprintf(buffer, "%s = %s", yString.cstr(), rString.cstr());
509510         break;
510511      }
trunk/src/emu/cpu/dsp16/dsp16.c
r20274r20275
5757     m_c2(0),
5858     m_sioc(0),
5959     m_srta(0),
60     m_sdx(0),
6061     m_pioc(0),
62     m_pdx0(0),
63     m_pdx1(0),
6164     m_ppc(0),
6265     m_cacheStart(CACHE_INVALID),
6366     m_cacheEnd(CACHE_INVALID),
r20274r20275
108111   state_add(DSP16_C2,       "C2",        m_c2);
109112   state_add(DSP16_SIOC,     "SIOC",      m_sioc).formatstr("%16s");
110113   state_add(DSP16_SRTA,     "SRTA",      m_srta);
111   state_add(DSP16_PIOC,     "PIOC",      m_pioc); //.formatstr("%16s");
114   state_add(DSP16_SDX,      "SDX",       m_sdx);
115   state_add(DSP16_PIOC,     "PIOC",      m_pioc);
116   state_add(DSP16_PDX0,     "PDX0",      m_pdx0);
117   state_add(DSP16_PDX1,     "PDX1",      m_pdx1);
112118
113119   // register our state for saving
114120   save_item(NAME(m_i));
r20274r20275
136142   save_item(NAME(m_c2));
137143   save_item(NAME(m_sioc));
138144   save_item(NAME(m_srta));
145   save_item(NAME(m_sdx));
139146   save_item(NAME(m_pioc));
147   save_item(NAME(m_pdx0));
148   save_item(NAME(m_pdx1));
140149   save_item(NAME(m_ppc));
141150   save_item(NAME(m_cacheStart));
142151   save_item(NAME(m_cacheEnd));
trunk/src/emu/cpu/dsp16/dsp16ops.c
r20274r20275
112112      case 0x10: return (void*)&m_x;
113113      case 0x11: return (void*)&m_y;
114114      case 0x12: return (void*)addressYL();
115      case 0x13: return (void*)&m_auc;
115      case 0x13: return (void*)&m_auc;   // zero extended
116116      case 0x14: return (void*)&m_psw;
117      case 0x15: return (void*)&m_c0;
118      case 0x16: return (void*)&m_c1;
119      case 0x17: return (void*)&m_c2;
117      case 0x15: return (void*)&m_c0;      // sign extended
118      case 0x16: return (void*)&m_c1;      // sign extended
119      case 0x17: return (void*)&m_c2;      // sign extended
120120      case 0x18: return (void*)&m_sioc;
121121      case 0x19: return (void*)&m_srta;
122      //case 0x1a: return (void*)&m_sdx;
122      case 0x1a: return (void*)&m_sdx;
123123      //case 0x1b: return (void*)&m_tdms;
124124      case 0x1c: return (void*)&m_pioc;
125      //case 0x1d: return (void*)&m_pdx0;
126      //case 0x1e: return (void*)&m_pdx1;
125      case 0x1d: return (void*)&m_pdx0;
126      case 0x1e: return (void*)&m_pdx1;
127127
128128      default: return NULL;
129129   }
r20274r20275
213213}
214214
215215
216void dsp16_device::executeZFieldPartOne(const UINT8& Z, UINT16* rN)
217{
218   const UINT8 lower = Z & 0x03;
219   switch (lower)
220   {
221      case 0x00: /* nop */ break;
222      case 0x01: (*rN)++; break;
223      case 0x02: (*rN)--; break;
224      case 0x03: (*rN) += m_j; break;
225   }
226}
227
228
229void dsp16_device::executeZFieldPartTwo(const UINT8& Z, UINT16* rN)
230{
231   const UINT8 lower = Z & 0x03;
232   switch (lower)
233   {
234      case 0x00: (*rN)++; break;
235      case 0x01: /* nop */   break;
236      case 0x02: (*rN) += 2; break;
237      case 0x03: (*rN) += m_k; break;
238   }
239}
240
241
216242void dsp16_device::execute_one(const UINT16& op, UINT8& cycles, UINT8& pcAdvance)
217243{
218244   cycles = 1;
r20274r20275
262288      }
263289      case 0x16:
264290      {
265         // F1, x = Y
266         //const UINT8 Y = (op & 0x000f);
267         //const UINT8 S = (op & 0x0200) >> 9;
268         //const UINT8 D = (op & 0x0400) >> 10;
269         //const UINT8 F1 = (op & 0x01e0) >> 5;
291         // F1, x = Y  :  (page 3-42)
292         const UINT8 Y = (op & 0x000f);
293         const UINT8 S = (op & 0x0200) >> 9;
294         const UINT8 D = (op & 0x0400) >> 10;
295         const UINT8 F1 = (op & 0x01e0) >> 5;
296         executeF1Field(F1, D, S);
297         UINT16* sourceReg = (UINT16*)registerFromYFieldUpper(Y);
298         writeRegister(&m_x, data_read(*sourceReg));
299         executeYFieldPost(Y);
300         cycles = 1;
301         pcAdvance = 1;
270302         break;
271303      }
272304      case 0x17:
r20274r20275
293325      }
294326      case 0x1f:
295327      {
296         // F1, y = Y, x = *pt++[i]
297         //const UINT8 Y = (op & 0x000f);
298         //const UINT8 X = (op & 0x0010) >> 4;
299         //const UINT8 S = (op & 0x0200) >> 9;
300         //const UINT8 D = (op & 0x0400) >> 10;
301         //const UINT8 F1 = (op & 0x01e0) >> 5;
328         // F1, y = Y, x = *pt++[i]  :  (page 3-46)
329         const UINT8 Y = (op & 0x000f);
330         const UINT8 X = (op & 0x0010) >> 4;
331         const UINT8 S = (op & 0x0200) >> 9;
332         const UINT8 D = (op & 0x0400) >> 10;
333         const UINT8 F1 = (op & 0x01e0) >> 5;
334         executeF1Field(F1, D, S);
335         UINT16* sourceRegR = (UINT16*)registerFromYFieldUpper(Y);
336         writeRegister(&m_y, data_read(*sourceRegR));
337         executeYFieldPost(Y);
338         writeRegister(&m_x, data_read(m_pt));
339         switch (X)
340         {
341            case 0x00: m_pt++;      break;
342            case 0x01: m_pt += m_i; break;
343         }
344         cycles = 2;      // TODO: 1 if cached
345         pcAdvance = 1;
302346         break;
303347      }
304348      case 0x19: case 0x1b:
r20274r20275
313357         if (Y != 0x00) printf("Unknown opcode @ PC=0x%04x", m_pc);
314358         m_y = (useA1) ? (m_a1 & 0xffffffff) : (m_a0 & 0xffffffff);      // TODO: What happens to Ax when it goes 32 bit (pc=3f & pc=47)?
315359         executeF1Field(F1, D, S);
316         m_x = data_read(m_pt);                                 // TODO: EXM Pin & internal/external ROM?  Research.
360         writeRegister(&m_x, data_read(m_pt));                     // TODO: EXM Pin & internal/external ROM?  Research.
317361         switch (X)
318362         {
319363            case 0x00: m_pt++;      break;
r20274r20275
375419      // Format 2: Multiply/ALU Read/Write Group
376420      case 0x15:
377421      {
378         // F1, Z : y[1]
379         //const UINT8 Z = (op & 0x000f);
380         //const UINT8 X = (op & 0x0010) >> 4;
381         //const UINT8 S = (op & 0x0200) >> 9;
382         //const UINT8 D = (op & 0x0400) >> 10;
383         //const UINT8 F1 = (op & 0x01e0) >> 5;
422         // F1, Z : y[1]  :  (page 3-54)
423         const UINT8 Z = (op & 0x000f);
424         const UINT8 X = (op & 0x0010) >> 4;
425         const UINT8 S = (op & 0x0200) >> 9;
426         const UINT8 D = (op & 0x0400) >> 10;
427         const UINT8 F1 = (op & 0x01e0) >> 5;
428            executeF1Field(F1, D, S);
429            UINT16 temp = 0x0000;
430            UINT16* rN = (UINT16*)registerFromYFieldUpper(Z);
431            switch (X)
432            {
433                case 0x00:
434                    temp = m_y & 0x0000ffff;
435                    m_y &= 0xffff0000;
436                    m_y |= data_read(*rN);
437                    executeZFieldPartOne(Z, rN);
438                    data_write(*rN, temp);
439                    executeZFieldPartTwo(Z, rN);
440                    break;
441                case 0x01:
442                    temp = (m_y & 0xffff0000) >> 16;
443                    m_y &= 0x0000ffff;
444                    m_y |= (data_read(*rN) << 16);
445                    executeZFieldPartOne(Z, rN);
446                    data_write(*rN, temp);
447                    executeZFieldPartTwo(Z, rN);
448                    break;
449            }
450            cycles = 2;
451            pcAdvance = 1;
384452         break;
385453      }
386454      case 0x1d:
r20274r20275
497565      }
498566      case 0x08:
499567      {
500         // aT = R
501         //const UINT8 R  = (op & 0x03f0) >> 4;
502         //const UINT8 aT = (op & 0x0400) >> 10;
568         // aT = R  :  (page 3-30)
569         const UINT8 R  = (op & 0x03f0) >> 4;
570         const UINT8 aT = (op & 0x0400) >> 10;
571         UINT64* destinationReg = NULL;
572         switch(aT)
573         {
574            case 0: destinationReg = &m_a1; break;
575            case 1: destinationReg = &m_a0; break;
576            default: break;
577         }
578         void* sourceReg = registerFromRTable(R);
579         *destinationReg &= U64(0x00000ffff);
580         *destinationReg |= (*(UINT16*)sourceReg) << 16;      // TODO: Fix for all registers
581         if (*(UINT16*)sourceReg & 0x8000)
582            *destinationReg |= U64(0xf00000000);
583         // TODO: Special function encoding
584         cycles = 2;
585         pcAdvance = 1;
503586         break;
504587      }
505588      case 0x0f:
r20274r20275
573656            // Do
574657            m_cacheStart = m_pc + 1;
575658            m_cacheEnd = m_pc + NI + 1;
576            m_cacheIterations = K-1;   // -1 because we check the counter below
659            m_cacheIterations = K-1;   // -1 because we check the counter @ the end
577660            cycles = 1;
578661            pcAdvance = 1;
579662         }
580663         else
581664         {
582665            // Redo
583            m_cacheIterations = K-1;   // -1 because we check the counter below
666            m_cacheIterations = K-1;   // -1 because we check the counter @ the end
584667            m_cacheRedoNextPC = m_pc + 1;
585668            m_pc = m_cacheStart;
586669            pcAdvance = 0;
trunk/src/emu/cpu/dsp16/dsp16.h
r20274r20275
8383   // Serial and parallel interfaces
8484   UINT16 m_sioc;
8585   UINT16 m_srta;
86   UINT16 m_sdx;
8687   UINT16 m_pioc;
88   UINT16 m_pdx0;   // pdx0 & pdx1 refer to the same physical register (page 6-1)
89   UINT16 m_pdx1;   //   but we keep them seperate for logic's sake.
8790
8891   // internal stuff
8992   UINT16 m_ppc;
r20274r20275
120123   // execution
121124   void executeF1Field(const UINT8& F1, const UINT8& D, const UINT8& S);
122125   void executeYFieldPost(const UINT8& Y);
126   void executeZFieldPartOne(const UINT8& Z, UINT16* rN);
127   void executeZFieldPartTwo(const UINT8& Z, UINT16* rN);
123128
124129   // helpers
125130   void* addressYL();
r20274r20275
163168   DSP16_C2,
164169   DSP16_SIOC,
165170   DSP16_SRTA,
166   DSP16_PIOC
171   DSP16_SDX,
172   DSP16_PIOC,
173    DSP16_PDX0,
174    DSP16_PDX1
167175};
168176
169177

Previous 199869 Revisions Next


© 1997-2024 The MAME Team