Previous 15994 Revisions Next

r7206 Sunday 31st January, 2010 at 12:51:33 UTC by Robbbert
[APEXC] 1. Added pseudo PC register for the debugger, it will now highlight the next instruction to be executed.
2. Added "normal" addresses to disassembler output, so anyone can see the program flow.
[src/emu/cpu/apexc]apexc.c apexc.h apexcdsm.c

src/emu/cpu/apexc/apexc.c
r7205r7206
356356
357357   int running;   /* 1 flag: */
358358            /* running: flag implied by the existence of the stop instruction */
359   UINT32 pc;   /* address of next instruction for the disassembler */
359360
360361   running_device *device;
361362   const address_space *program;
r7205r7206
540541   function = (cpustate->cr >> 7) & 0x1F;
541542   c6 = (cpustate->cr >> 1) & 0x3F;
542543   vector = cpustate->cr & 1;
544   cpustate->pc = y<<2;
543545
544546   function &= 0x1E;   /* this is a mere guess - the LSBit is reserved for future additions */
545547
r7205r7206
595597         {
596598            /* load ml with X */
597599            delay1 = load_ml(cpustate, x, vector);
600            cpustate->pc = x<<2;
598601            /* burn pre-fetch delay if needed */
599602            if (delay1)
600603            {
r7205r7206
827830
828831   do
829832   {
830      debugger_instruction_hook(device, effective_address(cpustate, cpustate->ml));
833      debugger_instruction_hook(device, cpustate->pc);
831834
832835      if (cpustate->running)
833836         execute(cpustate);
r7205r7206
870873   case CPUINFO_INT_REGISTER + APEXC_A:      cpustate->a = info->i;                     break;
871874   case CPUINFO_INT_REGISTER + APEXC_R:      cpustate->r = info->i;                     break;
872875   case CPUINFO_INT_REGISTER + APEXC_ML:      cpustate->ml = info->i & 0x3ff;               break;
876   case CPUINFO_INT_REGISTER + APEXC_PC:      cpustate->pc = info->i;               break;
873877   case CPUINFO_INT_REGISTER + APEXC_WS:      cpustate->working_store = info->i & 0xf;      break;
874878   case CPUINFO_INT_REGISTER + APEXC_STATE:   cpustate->running = info->i ? TRUE : FALSE;      break;
875879   }
r7205r7206
904908
905909   case CPUINFO_INT_SP:                     info->i = 0;   /* no SP */            break;
906910   case CPUINFO_INT_PC:
907      /* no PC - return memory location register instead, this should be
908        equivalent unless executed in the midst of an instruction */
909      info->i = effective_address(cpustate, cpustate->ml);
910      break;
911   case CPUINFO_INT_PREVIOUSPC:               info->i = 0;   /* no PC */            break;
911   case CPUINFO_INT_PREVIOUSPC:               info->i = cpustate->pc;   /* psuedo-PC */            break;
912912
913913   /*case CPUINFO_INT_INPUT_STATE + ...:*/                     /* no interrupts */
914914
r7205r7206
916916   case CPUINFO_INT_REGISTER + APEXC_A:         info->i = cpustate->a;                  break;
917917   case CPUINFO_INT_REGISTER + APEXC_R:         info->i = cpustate->r;                  break;
918918   case CPUINFO_INT_REGISTER + APEXC_ML:         info->i = cpustate->ml;                  break;
919   case CPUINFO_INT_REGISTER + APEXC_PC:         info->i = cpustate->pc;                  break;
919920   case CPUINFO_INT_REGISTER + APEXC_WS:         info->i = cpustate->working_store;         break;
920921   case CPUINFO_INT_REGISTER + APEXC_STATE:      info->i = cpustate->running;            break;
921922   case CPUINFO_INT_REGISTER + APEXC_ML_FULL:      info->i = effective_address(cpustate, cpustate->ml);   break;
r7205r7206
940941   case CPUINFO_STR_REGISTER + APEXC_A:         sprintf(info->s, "A :%08X", cpustate->a); break;
941942   case CPUINFO_STR_REGISTER + APEXC_R:         sprintf(info->s, "R :%08X", cpustate->r); break;
942943   case CPUINFO_STR_REGISTER + APEXC_ML:         sprintf(info->s, "ML:%03X", cpustate->ml); break;
944   case CPUINFO_STR_REGISTER + APEXC_PC:         sprintf(info->s, "PC:%03X", cpustate->pc); break;
943945   case CPUINFO_STR_REGISTER + APEXC_WS:         sprintf(info->s, "WS:%01X", cpustate->working_store); break;
944946
945947   case CPUINFO_STR_REGISTER + APEXC_STATE:      sprintf(info->s, "CPU state:%01X", cpustate->running ? TRUE : FALSE); break;
src/emu/cpu/apexc/apexcdsm.c
r7205r7206
5151
5252    For vector instructions, replace the first space on the right of the mnemonic
5353    with a 'v'.
54
55   01-Feb-2010 (Robbbert):
56   I've added the actual address, (as shown in the extreme left of the debugger
57   output), so that you can see much easier how the program will flow. Example:
58
59   +C  XXX(##/##)   XXX(##/##)
60
61   The X value shows where the data word is located, and the Y value is the
62   address of the next instruction.
5463*/
5564enum _format_type {branch, shiftl, shiftr, multiply, store, swap, one_address, two_address};
5665typedef enum _format_type format_type;
r7205r7206
104113   case two_address:
105114   case branch:
106115   case swap:
107      buffer += sprintf(buffer, "%-10s", mnemonic);   /* 10 chars*/
116      buffer += sprintf(buffer, "   %-10s", mnemonic);   /* 10 chars*/
108117      break;
109118
110119   case shiftl:
r7205r7206
113122         n = c6;
114123      else
115124         n = 64-c6;
116      buffer += sprintf(buffer, "%-2s(%2d)    ", mnemonic, n);   /* 10 chars */
125      buffer += sprintf(buffer, "   %-2s(%2d)    ", mnemonic, n);   /* 10 chars */
117126      break;
118127
119128   case multiply:
120129      n = 33-c6;
121130      if (n == 32)
122131         /* case "32" : do not show bit specifier */
123         buffer += sprintf(buffer, "%-10s", mnemonic);   /* 10 chars */
132         buffer += sprintf(buffer, "   %-10s", mnemonic);   /* 10 chars */
124133      else
125         buffer += sprintf(buffer, "%-2s(%2d)    ", mnemonic, n);   /* 10 chars */
134         buffer += sprintf(buffer, "   %-2s(%2d)    ", mnemonic, n);   /* 10 chars */
126135      break;
127136
128137   case store:
129138      if (c6 == 0)
130139      {   /* case "1-32" : do not show bit specifier */
131         buffer += sprintf(buffer, "%-10s", mnemonic);   /* 10 chars*/
140         buffer += sprintf(buffer, "   %-10s", mnemonic);   /* 10 chars*/
132141      }
133142      else if (c6 & 0x20)
134143      {   /* case "1-n" */
135144         n = c6-32;
136         buffer += sprintf(buffer, "%-2s (1-%02d) ", mnemonic, n);   /* 10 chars */
145         buffer += sprintf(buffer, "   %-2s (1-%02d) ", mnemonic, n);   /* 10 chars */
137146      }
138147      else
139148      {   /* case "n-32" */
140149         n = c6+1;
141         buffer += sprintf(buffer, "%-2s(%02d-32) ", mnemonic, n);   /* 8 chars */
150         buffer += sprintf(buffer, "   %-2s(%02d-32) ", mnemonic, n);   /* 8 chars */
142151      }
143152   }
144153
r7205r7206
147156   {
148157   case branch:
149158      buffer--;   /* eat last char */
150      buffer += sprintf(buffer, "<(%02d/%02d) >=", (x >> 5) & 0x1f, x & 0x1f);   /* 10+1 chars */
159      buffer += sprintf(buffer, "<%03X(%02d/%02d) >=", x<<2, (x >> 5) & 0x1f, x & 0x1f);   /* 10+1 chars */
151160      break;
152161
153162   case multiply:
154163   case swap:
155      buffer += sprintf(buffer, "(%02d)      ", (x >> 5) & 0x1f);   /* 10 chars */
164      buffer += sprintf(buffer, "   (%02d)      ", (x >> 5) & 0x1f);   /* 10 chars */
156165      break;
157166
158167   case one_address:
159168   case shiftl:
160169   case shiftr:
161      buffer += sprintf(buffer, "          ");   /* 10 chars */
170      buffer += sprintf(buffer, "             ");   /* 10 chars */
162171      break;
163172
164173   case two_address:
165174   case store:
166      buffer += sprintf(buffer, "(%02d/%02d)   ", (x >> 5) & 0x1f, x & 0x1f);   /* 10 chars */
175      buffer += sprintf(buffer, "%03X(%02d/%02d)   ", x<<2, (x >> 5) & 0x1f, x & 0x1f);   /* 10 chars */
167176      break;
168177   }
169178
170179   /* print Y address */
171   buffer += sprintf(buffer, "(%02d/%02d)", (y >> 5) & 0x1f, y & 0x1f);   /* 7 chars */
180   buffer += sprintf(buffer, "%03X(%02d/%02d)", y<<2, (y >> 5) & 0x1f, y & 0x1f);   /* 7 chars */
172181
173182   return 4;
174183}
src/emu/cpu/apexc/apexc.h
r7205r7206
1313   APEXC_WS,      /* working store */
1414   APEXC_STATE,   /* whether CPU is running */
1515
16   APEXC_ML_FULL   /* read-only pseudo-register for exclusive use by the control panel code
16   APEXC_ML_FULL,   /* read-only pseudo-register for exclusive use by the control panel code
1717                    in the apexc driver : enables it to get the complete address computed
1818                    from the contents of ML and WS */
19   APEXC_PC   /* doesn't actually exist; is there for the disassembler */
1920};
2021
2122CPU_GET_INFO( apexc );

Previous 15994 Revisions Next


© 1998-2018 The MESS Team