FAME integration finished, some adjustments of CPU core stuff
authornotaz <notasas@gmail.com>
Mon, 22 Oct 2007 20:38:41 +0000 (20:38 +0000)
committernotaz <notasas@gmail.com>
Mon, 22 Oct 2007 20:38:41 +0000 (20:38 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@278 be3aeb3a-fb24-0410-a615-afba39da0efa

18 files changed:
Pico/Area.c
Pico/Memory.c
Pico/Pico.c
Pico/PicoInt.h
Pico/Sek.c
Pico/VideoPort.c
Pico/_cyclone_debug.c
Pico/cd/Area.c
Pico/cd/Memory.c
Pico/cd/Memory.s
Pico/cd/Pico.c
Pico/cd/Pico.s
Pico/cd/Sek.c
cpu/a68k/Makefile.win [deleted file]
cpu/a68k/cpuintrf.h [deleted file]
cpu/a68k/make68kd.c [deleted file]
cpu/fame/fame.h
cpu/fame/famec.c

index e62274a..41ee68b 100644 (file)
@@ -46,29 +46,17 @@ PICO_INTERNAL int PicoAreaPackCpu(unsigned char *cpu, int is_sub)
 {\r
   unsigned int pc=0;\r
 \r
-#ifdef EMU_A68K\r
-  memcpy(cpu,M68000_regs.d,0x40);\r
-  pc=M68000_regs.pc;\r
-  *(unsigned char *)(cpu+0x44)=(unsigned char)M68000_regs.ccr;\r
-  *(unsigned char *)(cpu+0x45)=(unsigned char)M68000_regs.srh;\r
-  *(unsigned int  *)(cpu+0x48)=M68000_regs.isp;\r
-  cpu[0x4c] = M68000_regs.irq;\r
-  // stop flag?\r
-#endif\r
-\r
-#ifdef EMU_C68K\r
-  struct Cyclone *context = is_sub ? &PicoCpuS68k : &PicoCpu;\r
+#if defined(EMU_C68K)\r
+  struct Cyclone *context = is_sub ? &PicoCpuCS68k : &PicoCpuCM68k;\r
   memcpy(cpu,context->d,0x40);\r
   pc=context->pc-context->membase;\r
   *(unsigned int *)(cpu+0x44)=CycloneGetSr(context);\r
   *(unsigned int *)(cpu+0x48)=context->osp;\r
   cpu[0x4c] = context->irq;\r
   cpu[0x4d] = context->state_flags & 1;\r
-#endif\r
-\r
-#ifdef EMU_M68K\r
+#elif defined(EMU_M68K)\r
   void *oldcontext = m68ki_cpu_p;\r
-  m68k_set_context(is_sub ? &PicoS68kCPU : &PicoM68kCPU);\r
+  m68k_set_context(is_sub ? &PicoCpuMS68k : &PicoCpuMM68k);\r
   memcpy(cpu,m68ki_cpu_p->dar,0x40);\r
   pc=m68ki_cpu_p->pc;\r
   *(unsigned int  *)(cpu+0x44)=m68k_get_reg(NULL, M68K_REG_SR);\r
@@ -76,6 +64,14 @@ PICO_INTERNAL int PicoAreaPackCpu(unsigned char *cpu, int is_sub)
   cpu[0x4c] = CPU_INT_LEVEL>>8;\r
   cpu[0x4d] = CPU_STOPPED;\r
   m68k_set_context(oldcontext);\r
+#elif defined(EMU_F68K)\r
+  M68K_CONTEXT *context = is_sub ? &PicoCpuFS68k : &PicoCpuFM68k;\r
+  memcpy(cpu,context->dreg,0x40);\r
+  pc=context->pc;\r
+  *(unsigned int  *)(cpu+0x44)=context->sr;\r
+  *(unsigned int  *)(cpu+0x48)=context->asp;\r
+  cpu[0x4c] = context->interrupts[0];\r
+  cpu[0x4d] = (context->execinfo & M68K_HALTED) ? 1 : 0;\r
 #endif\r
 \r
   *(unsigned int *)(cpu+0x40)=pc;\r
@@ -84,20 +80,10 @@ PICO_INTERNAL int PicoAreaPackCpu(unsigned char *cpu, int is_sub)
 \r
 PICO_INTERNAL int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub)\r
 {\r
-#ifdef EMU_A68K\r
-  memcpy(M68000_regs.d,cpu,0x40);\r
-  M68000_regs.pc=pc;\r
-  M68000_regs.ccr=*(unsigned char *)(cpu+0x44);\r
-  M68000_regs.srh=*(unsigned char *)(cpu+0x45);\r
-  M68000_regs.isp=*(unsigned int  *)(cpu+0x48);\r
-  M68000_regs.irq = cpu[0x4c];\r
-  // stop flag?\r
-#endif\r
-\r
-#ifdef EMU_C68K\r
-  struct Cyclone *context = is_sub ? &PicoCpuS68k : &PicoCpu;\r
-  CycloneSetSr(context, *(unsigned int  *)(cpu+0x44));\r
-  context->osp=*(unsigned int  *)(cpu+0x48);\r
+#if defined(EMU_C68K)\r
+  struct Cyclone *context = is_sub ? &PicoCpuCS68k : &PicoCpuCM68k;\r
+  CycloneSetSr(context, *(unsigned int *)(cpu+0x44));\r
+  context->osp=*(unsigned int *)(cpu+0x48);\r
   memcpy(context->d,cpu,0x40);\r
   context->membase=0;\r
   context->pc = context->checkpc(*(unsigned int *)(cpu+0x40)); // Base pc\r
@@ -105,11 +91,9 @@ PICO_INTERNAL int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub)
   context->state_flags = 0;\r
   if (cpu[0x4d])\r
     context->state_flags |= 1;\r
-#endif\r
-\r
-#ifdef EMU_M68K\r
+#elif defined(EMU_M68K)\r
   void *oldcontext = m68ki_cpu_p;\r
-  m68k_set_context(is_sub ? &PicoS68kCPU : &PicoM68kCPU);\r
+  m68k_set_context(is_sub ? &PicoCpuMS68k : &PicoCpuMM68k);\r
   memcpy(m68ki_cpu_p->dar,cpu,0x40);\r
   m68ki_cpu_p->pc=*(unsigned int *)(cpu+0x40);\r
   m68k_set_reg(M68K_REG_SR, *(unsigned int *)(cpu+0x44));\r
@@ -117,6 +101,15 @@ PICO_INTERNAL int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub)
   CPU_INT_LEVEL = cpu[0x4c] << 8;\r
   CPU_STOPPED = cpu[0x4d];\r
   m68k_set_context(oldcontext);\r
+#elif defined(EMU_F68K)\r
+  M68K_CONTEXT *context = is_sub ? &PicoCpuFS68k : &PicoCpuFM68k;\r
+  memcpy(context->dreg,cpu,0x40);\r
+  context->pc =*(unsigned int *)(cpu+0x40);\r
+  context->sr =*(unsigned int *)(cpu+0x44);\r
+  context->asp=*(unsigned int *)(cpu+0x48);\r
+  context->interrupts[0] = cpu[0x4c];\r
+  context->execinfo &= ~M68K_HALTED;\r
+  if (cpu[0x4d]&1) context->execinfo |= M68K_HALTED;\r
 #endif\r
   return 0;\r
 }\r
index b0aa7af..963d30b 100644 (file)
@@ -73,7 +73,7 @@ static u32 CPU_CALL PicoCheckPc(u32 pc)
 {\r
   u32 ret=0;\r
 #if defined(EMU_C68K)\r
-  pc-=PicoCpu.membase; // Get real pc\r
+  pc-=PicoCpuCM68k.membase; // Get real pc\r
 //  pc&=0xfffffe;\r
   pc&=~1;\r
   if ((pc<<8) == 0)\r
@@ -82,10 +82,10 @@ static u32 CPU_CALL PicoCheckPc(u32 pc)
     return (int)Pico.rom + Pico.romsize; // common crash condition, can happen if acc timing is off\r
   }\r
 \r
-  PicoCpu.membase=PicoMemBase(pc&0x00ffffff);\r
-  PicoCpu.membase-=pc&0xff000000;\r
+  PicoCpuCM68k.membase=PicoMemBase(pc&0x00ffffff);\r
+  PicoCpuCM68k.membase-=pc&0xff000000;\r
 \r
-  ret = PicoCpu.membase+pc;\r
+  ret = PicoCpuCM68k.membase+pc;\r
 #endif\r
   return ret;\r
 }\r
@@ -491,21 +491,35 @@ PICO_INTERNAL void PicoMemSetup(void)
 {\r
   // Setup memory callbacks:\r
 #ifdef EMU_C68K\r
-  PicoCpu.checkpc=PicoCheckPc;\r
-  PicoCpu.fetch8 =PicoCpu.read8 =PicoRead8;\r
-  PicoCpu.fetch16=PicoCpu.read16=PicoRead16;\r
-  PicoCpu.fetch32=PicoCpu.read32=PicoRead32;\r
-  PicoCpu.write8 =PicoWrite8;\r
-  PicoCpu.write16=PicoWrite16;\r
-  PicoCpu.write32=PicoWrite32;\r
+  PicoCpuCM68k.checkpc=PicoCheckPc;\r
+  PicoCpuCM68k.fetch8 =PicoCpuCM68k.read8 =PicoRead8;\r
+  PicoCpuCM68k.fetch16=PicoCpuCM68k.read16=PicoRead16;\r
+  PicoCpuCM68k.fetch32=PicoCpuCM68k.read32=PicoRead32;\r
+  PicoCpuCM68k.write8 =PicoWrite8;\r
+  PicoCpuCM68k.write16=PicoWrite16;\r
+  PicoCpuCM68k.write32=PicoWrite32;\r
 #endif\r
 #ifdef EMU_F68K\r
-  PicoCpuM68k.read_byte =PicoRead8;\r
-  PicoCpuM68k.read_word =PicoRead16;\r
-  PicoCpuM68k.read_long =PicoRead32;\r
-  PicoCpuM68k.write_byte=PicoWrite8;\r
-  PicoCpuM68k.write_word=PicoWrite16;\r
-  PicoCpuM68k.write_long=PicoWrite32;\r
+  PicoCpuFM68k.read_byte =PicoRead8;\r
+  PicoCpuFM68k.read_word =PicoRead16;\r
+  PicoCpuFM68k.read_long =PicoRead32;\r
+  PicoCpuFM68k.write_byte=PicoWrite8;\r
+  PicoCpuFM68k.write_word=PicoWrite16;\r
+  PicoCpuFM68k.write_long=PicoWrite32;\r
+\r
+  // setup FAME fetchmap\r
+  {\r
+    int i;\r
+    // by default, point everything to fitst 64k of ROM\r
+    for (i = 0; i < M68K_FETCHBANK1; i++)\r
+      PicoCpuFM68k.Fetch[i] = (unsigned int)Pico.rom - (i<<(24-FAMEC_FETCHBITS));\r
+    // now real ROM\r
+    for (i = 0; i < M68K_FETCHBANK1 && (i<<(24-FAMEC_FETCHBITS)) < Pico.romsize; i++)\r
+      PicoCpuFM68k.Fetch[i] = (unsigned int)Pico.rom;\r
+    // .. and RAM\r
+    for (i = M68K_FETCHBANK1*14/16; i < M68K_FETCHBANK1; i++)\r
+      PicoCpuFM68k.Fetch[i] = (unsigned int)Pico.ram - (i<<(24-FAMEC_FETCHBITS));\r
+  }\r
 #endif\r
 }\r
 \r
index b9fbfe6..ce3e340 100644 (file)
@@ -209,9 +209,9 @@ static __inline void SekRunM68k(int cyc)
   // this means we do run-compare Cyclone vs Musashi\r
   SekCycleCnt+=CM_compareRun(cyc_do);\r
 #elif defined(EMU_C68K)\r
-  PicoCpu.cycles=cyc_do;\r
-  CycloneRun(&PicoCpu);\r
-  SekCycleCnt+=cyc_do-PicoCpu.cycles;\r
+  PicoCpuCM68k.cycles=cyc_do;\r
+  CycloneRun(&PicoCpuCM68k);\r
+  SekCycleCnt+=cyc_do-PicoCpuCM68k.cycles;\r
 #elif defined(EMU_M68K)\r
   SekCycleCnt+=m68k_execute(cyc_do);\r
 #elif defined(EMU_F68K)\r
@@ -227,9 +227,9 @@ static __inline void SekStep(void)
   // this means we do run-compare Cyclone vs Musashi\r
   SekCycleCnt+=CM_compareRun(1);\r
 #elif defined(EMU_C68K)\r
-  PicoCpu.cycles=1;\r
-  CycloneRun(&PicoCpu);\r
-  SekCycleCnt+=1-PicoCpu.cycles;\r
+  PicoCpuCM68k.cycles=1;\r
+  CycloneRun(&PicoCpuCM68k);\r
+  SekCycleCnt+=1-PicoCpuCM68k.cycles;\r
 #elif defined(EMU_M68K)\r
   SekCycleCnt+=m68k_execute(1);\r
 #elif defined(EMU_F68K)\r
@@ -240,27 +240,16 @@ static __inline void SekStep(void)
 \r
 static int CheckIdle(void)\r
 {\r
-#if 1\r
-  unsigned char state[0x88];\r
-\r
-  memset(state,0,sizeof(state));\r
+  int i, state[0x22];\r
 \r
   // See if the state is the same after 2 steps:\r
-  SekState(state); SekStep(); SekStep(); SekState(state+0x44);\r
-  if (memcmp(state,state+0x44,0x44)==0) return 1;\r
-#else\r
-  unsigned char state[0x44];\r
-  static unsigned char oldstate[0x44];\r
+  SekState(state); SekStep(); SekStep(); SekState(state+0x11);\r
+  for (i = 0x10; i >= 0; i--)\r
+    if (state[i] != state[i+0x11]) return 0;\r
 \r
-  SekState(state);\r
-  if(memcmp(state,oldstate,0x40)==0) return 1;\r
-  memcpy(oldstate, state, 0x40);\r
-#endif\r
-\r
-  return 0;\r
+  return 1;\r
 }\r
 \r
-void lprintf_al(const char *fmt, ...);\r
 \r
 // to be called on 224 or line_sample scanlines only\r
 static __inline void getSamples(int y)\r
@@ -284,140 +273,7 @@ static __inline void getSamples(int y)
 }\r
 \r
 \r
-#if 1*0\r
-int vint_delay = 205/*68*/, as_delay = 18/*148*/;\r
-\r
-// Accurate but slower frame which does hints\r
-static int PicoFrameHints(void)\r
-{\r
-  struct PicoVideo *pv=&Pico.video;\r
-  int total_z80=0,lines,y,lines_vis = 224,z80CycleAim = 0,line_sample;\r
-  const int cycles_68k=488,cycles_z80=228; // both PAL and NTSC compile to same values\r
-  int skip=PicoSkipFrame || (PicoOpt&0x10);\r
-  int hint; // Hint counter\r
-\r
-  if(Pico.m.pal) { //\r
-    //cycles_68k = (int) ((double) OSC_PAL  /  7 / 50 / 312 + 0.4); // should compile to a constant (488)\r
-    //cycles_z80 = (int) ((double) OSC_PAL  / 15 / 50 / 312 + 0.4); // 228\r
-    lines  = 312;    // Steve Snake says there are 313 lines, but this seems to also work well\r
-    line_sample = 68;\r
-    if(pv->reg[1]&8) lines_vis = 240;\r
-  } else {\r
-    //cycles_68k = (int) ((double) OSC_NTSC /  7 / 60 / 262 + 0.4); // 488\r
-    //cycles_z80 = (int) ((double) OSC_NTSC / 15 / 60 / 262 + 0.4); // 228\r
-    lines  = 262;\r
-    line_sample = 93;\r
-  }\r
-\r
-  SekCyclesReset();\r
-  //z80ExtraCycles = 0;\r
-\r
-  if(PicoOpt&4)\r
-    z80CycleAim = 0;\r
-//    z80_resetCycles();\r
-\r
-  pv->status&=~0x88; // clear V-Int, come out of vblank\r
-\r
-  hint=pv->reg[10]; // Load H-Int counter\r
-  //dprintf("-hint: %i", hint);\r
-\r
-  //SekRun(as_delay);\r
-  SekRun(148);\r
-\r
-  for (y=0;y<lines;y++)\r
-  {\r
-    Pico.m.scanline=(short)y;\r
-\r
-    // VDP FIFO\r
-    pv->lwrite_cnt -= 12;\r
-    if (pv->lwrite_cnt <  0) pv->lwrite_cnt=0;\r
-    if (pv->lwrite_cnt == 0)\r
-      Pico.video.status|=0x200;\r
-\r
-    // pad delay (for 6 button pads)\r
-    if(PicoOpt&0x20) {\r
-      if(Pico.m.padDelay[0]++ > 25) Pico.m.padTHPhase[0]=0;\r
-      if(Pico.m.padDelay[1]++ > 25) Pico.m.padTHPhase[1]=0;\r
-    }\r
-\r
-    // H-Interrupts:\r
-    if(y <= lines_vis && --hint < 0) // y <= lines_vis: Comix Zone, Golden Axe\r
-    {\r
-      //dprintf("rhint:old @ %06x", SekPc);\r
-      hint=pv->reg[10]; // Reload H-Int counter\r
-      pv->pending_ints|=0x10;\r
-      if (pv->reg[0]&0x10) {\r
-        elprintf(EL_INTS, "hint: @ %06x [%i]", SekPc, SekCycleCnt);\r
-        SekInterrupt(4);\r
-      }\r
-      //dprintf("hint_routine: %x", (*(unsigned short*)(Pico.ram+0x0B84)<<16)|*(unsigned short*)(Pico.ram+0x0B86));\r
-    }\r
-\r
-    // V-Interrupt:\r
-    if (y == lines_vis)\r
-    {\r
-      pv->status|=0x08; // go into vblank\r
-      //pv->status|=0x80; // V-Int happened\r
-      //if(!Pico.m.dma_bytes||(Pico.video.reg[0x17]&0x80)) {\r
-        // there must be a gap between H and V ints, also after vblank bit set (Mazin Saga, Bram Stoker's Dracula)\r
-        SekRun(68); SekCycleAim-=68; // 128; ?\r
-        SekCycleAim-=148;\r
-//       SekRun(vint_delay); SekCycleAim-=vint_delay; // 128; ?\r
-//     SekCycleAim-=as_delay;\r
-      //}\r
-      pv->pending_ints|=0x20;\r
-      if(pv->reg[1]&0x20) {\r
-        elprintf(EL_INTS, "vint: @ %06x [%i]", SekPc, SekCycleCnt);\r
-        SekInterrupt(6);\r
-      }\r
-      if(Pico.m.z80Run && (PicoOpt&4)) // ?\r
-        z80_int();\r
-      //dprintf("zint: [%i|%i] zPC=%04x", Pico.m.scanline, SekCyclesDone(), mz80GetRegisterValue(NULL, 0));\r
-    }\r
-\r
-    // decide if we draw this line\r
-#if CAN_HANDLE_240_LINES\r
-    if(!skip && ((!(pv->reg[1]&8) && y<224) || ((pv->reg[1]&8) && y<240)) )\r
-#else\r
-    if(!skip && y<224)\r
-#endif\r
-      PicoLine(y);\r
-\r
-    if(PicoOpt&1)\r
-      sound_timers_and_dac(y);\r
-\r
-    // get samples from sound chips\r
-    if(y == 32 && PsndOut)\r
-      emustatus &= ~1;\r
-    else if((y == 224 || y == line_sample) && PsndOut)\r
-      getSamples(y);\r
-\r
-    // Run scanline:\r
-    if (Pico.m.dma_xfers) SekCyclesBurn(CheckDMA());\r
-    SekRun(cycles_68k);\r
-    if ((PicoOpt&4) && Pico.m.z80Run) {\r
-      if (Pico.m.z80Run & 2) z80CycleAim+=cycles_z80;\r
-      else {\r
-        int cnt = SekCyclesDone() - z80startCycle;\r
-        cnt = (cnt>>1)-(cnt>>5);\r
-        //if (cnt > cycles_z80) printf("FIXME: z80 cycles: %i\n", cnt);\r
-        if (cnt > cycles_z80) cnt = cycles_z80;\r
-        Pico.m.z80Run |= 2;\r
-        z80CycleAim+=cnt;\r
-      }\r
-      total_z80+=z80_run(z80CycleAim-total_z80);\r
-    }\r
-  }\r
-\r
-  // draw a frame just after vblank in alternative render mode\r
-  if(!PicoSkipFrame && (PicoOpt&0x10))\r
-    PicoFrameFull();\r
-\r
-  return 0;\r
-}\r
-#else\r
 #include "PicoFrameHints.c"\r
-#endif\r
 \r
 // helper z80 runner. Runs only if z80 is enabled at this point\r
 // (z80WriteBusReq will handle the rest)\r
@@ -664,17 +520,17 @@ char *debugString(void)
   sprintf(dstrp, "pend int: v:%i, h:%i, vdp status: %04x\n", bit(pv->pending_ints,5), bit(pv->pending_ints,4), pv->status);\r
   dstrp+=strlen(dstrp);\r
 #if defined(EMU_C68K)\r
-  sprintf(dstrp, "M68k: PC: %06x, st_flg: %x, cycles: %u\n", SekPc, PicoCpu.state_flags, SekCyclesDoneT());\r
+  sprintf(dstrp, "M68k: PC: %06x, st_flg: %x, cycles: %u\n", SekPc, PicoCpuCM68k.state_flags, SekCyclesDoneT());\r
   dstrp+=strlen(dstrp);\r
-  sprintf(dstrp, "d0=%08x, a0=%08x, osp=%08x, irql=%i\n", PicoCpu.d[0], PicoCpu.a[0], PicoCpu.osp, PicoCpu.irq); dstrp+=strlen(dstrp);\r
-  sprintf(dstrp, "d1=%08x, a1=%08x,  sr=%04x\n", PicoCpu.d[1], PicoCpu.a[1], CycloneGetSr(&PicoCpu)); dstrp+=strlen(dstrp);\r
+  sprintf(dstrp, "d0=%08x, a0=%08x, osp=%08x, irql=%i\n", PicoCpuCM68k.d[0], PicoCpuCM68k.a[0], PicoCpuCM68k.osp, PicoCpuCM68k.irq); dstrp+=strlen(dstrp);\r
+  sprintf(dstrp, "d1=%08x, a1=%08x,  sr=%04x\n", PicoCpuCM68k.d[1], PicoCpuCM68k.a[1], CycloneGetSr(&PicoCpuCM68k)); dstrp+=strlen(dstrp);\r
   for(r=2; r < 8; r++) {\r
-    sprintf(dstrp, "d%i=%08x, a%i=%08x\n", r, PicoCpu.d[r], r, PicoCpu.a[r]); dstrp+=strlen(dstrp);\r
+    sprintf(dstrp, "d%i=%08x, a%i=%08x\n", r, PicoCpuCM68k.d[r], r, PicoCpuCM68k.a[r]); dstrp+=strlen(dstrp);\r
   }\r
 #elif defined(EMU_M68K)\r
-  sprintf(dstrp, "M68k: PC: %06x, cycles: %u, irql: %i\n", SekPc, SekCyclesDoneT(), PicoM68kCPU.int_level>>8); dstrp+=strlen(dstrp);\r
+  sprintf(dstrp, "M68k: PC: %06x, cycles: %u, irql: %i\n", SekPc, SekCyclesDoneT(), PicoCpuMM68k.int_level>>8); dstrp+=strlen(dstrp);\r
 #elif defined(EMU_F68K)\r
-  sprintf(dstrp, "M68k: PC: %06x, cycles: %u, irql: %i\n", SekPc, SekCyclesDoneT(), PicoCpuM68k.interrupts[0]); dstrp+=strlen(dstrp);\r
+  sprintf(dstrp, "M68k: PC: %06x, cycles: %u, irql: %i\n", SekPc, SekCyclesDoneT(), PicoCpuFM68k.interrupts[0]); dstrp+=strlen(dstrp);\r
 #endif\r
   sprintf(dstrp, "z80Run: %i, pal: %i, frame#: %i\n", Pico.m.z80Run, Pico.m.pal, Pico.m.frame_count); dstrp+=strlen(dstrp);\r
   z80_debug(dstrp); dstrp+=strlen(dstrp);\r
index a6fceff..a9720c8 100644 (file)
@@ -34,69 +34,68 @@ extern "C" {
 // ----------------------- 68000 CPU -----------------------\r
 #ifdef EMU_C68K\r
 #include "../cpu/Cyclone/Cyclone.h"\r
-extern struct Cyclone PicoCpu, PicoCpuS68k;\r
-#define SekCyclesLeftNoMCD PicoCpu.cycles // cycles left for this run\r
+extern struct Cyclone PicoCpuCM68k, PicoCpuCS68k;\r
+#define SekCyclesLeftNoMCD PicoCpuCM68k.cycles // cycles left for this run\r
 #define SekCyclesLeft \\r
        (((PicoMCD&1) && (PicoOpt & 0x2000)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)\r
 #define SekCyclesLeftS68k \\r
-       ((PicoOpt & 0x2000) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuS68k.cycles)\r
-#define SekSetCyclesLeftNoMCD(c) PicoCpu.cycles=c\r
+       ((PicoOpt & 0x2000) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuCS68k.cycles)\r
+#define SekSetCyclesLeftNoMCD(c) PicoCpuCM68k.cycles=c\r
 #define SekSetCyclesLeft(c) { \\r
        if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCycleCnt=SekCycleAim-(c); else SekSetCyclesLeftNoMCD(c); \\r
 }\r
-#define SekPc (PicoCpu.pc-PicoCpu.membase)\r
-#define SekPcS68k (PicoCpuS68k.pc-PicoCpuS68k.membase)\r
-#define SekSetStop(x) { PicoCpu.state_flags&=~1; if (x) { PicoCpu.state_flags|=1; PicoCpu.cycles=0; } }\r
-#define SekSetStopS68k(x) { PicoCpuS68k.state_flags&=~1; if (x) { PicoCpuS68k.state_flags|=1; PicoCpuS68k.cycles=0; } }\r
+#define SekPc (PicoCpuCM68k.pc-PicoCpuCM68k.membase)\r
+#define SekPcS68k (PicoCpuCS68k.pc-PicoCpuCS68k.membase)\r
+#define SekSetStop(x) { PicoCpuCM68k.state_flags&=~1; if (x) { PicoCpuCM68k.state_flags|=1; PicoCpuCM68k.cycles=0; } }\r
+#define SekSetStopS68k(x) { PicoCpuCS68k.state_flags&=~1; if (x) { PicoCpuCS68k.state_flags|=1; PicoCpuCS68k.cycles=0; } }\r
 #endif\r
 \r
 #ifdef EMU_F68K\r
 #include "../cpu/fame/fame.h"\r
-M68K_CONTEXT PicoCpuM68k, PicoCpuS68k;\r
-#define SekCyclesLeftNoMCD PicoCpuM68k.io_cycle_counter\r
+M68K_CONTEXT PicoCpuFM68k, PicoCpuFS68k;\r
+#define SekCyclesLeftNoMCD PicoCpuFM68k.io_cycle_counter\r
 #define SekCyclesLeft \\r
        (((PicoMCD&1) && (PicoOpt & 0x2000)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)\r
 #define SekCyclesLeftS68k \\r
-       ((PicoOpt & 0x2000) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuS68k.io_cycle_counter)\r
-#define SekSetCyclesLeftNoMCD(c) PicoCpuM68k.io_cycle_counter=c\r
+       ((PicoOpt & 0x2000) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuFS68k.io_cycle_counter)\r
+#define SekSetCyclesLeftNoMCD(c) PicoCpuFM68k.io_cycle_counter=c\r
 #define SekSetCyclesLeft(c) { \\r
        if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCycleCnt=SekCycleAim-(c); else SekSetCyclesLeftNoMCD(c); \\r
 }\r
-#define SekPc     m68k_get_pc(&PicoCpuM68k)\r
-#define SekPcS68k m68k_get_pc(&PicoCpuS68k)\r
+#define SekPc     m68k_get_pc(&PicoCpuFM68k)\r
+#define SekPcS68k m68k_get_pc(&PicoCpuFS68k)\r
 #define SekSetStop(x) { \\r
-       PicoCpuM68k.execinfo &= ~M68K_HALTED; \\r
-       if (x) { PicoCpuM68k.execinfo |= M68K_HALTED; PicoCpuM68k.io_cycle_counter = 0; } \\r
+       PicoCpuFM68k.execinfo &= ~M68K_HALTED; \\r
+       if (x) { PicoCpuFM68k.execinfo |= M68K_HALTED; PicoCpuFM68k.io_cycle_counter = 0; } \\r
 }\r
 #define SekSetStopS68k(x) { \\r
-       PicoCpuS68k.execinfo &= ~M68K_HALTED; \\r
-       if (x) { PicoCpuS68k.execinfo |= M68K_HALTED; PicoCpuS68k.io_cycle_counter = 0; } \\r
+       PicoCpuFS68k.execinfo &= ~M68K_HALTED; \\r
+       if (x) { PicoCpuFS68k.execinfo |= M68K_HALTED; PicoCpuFS68k.io_cycle_counter = 0; } \\r
 }\r
 #endif\r
 \r
 #ifdef EMU_M68K\r
 #include "../cpu/musashi/m68kcpu.h"\r
-extern m68ki_cpu_core PicoM68kCPU; // MD's CPU\r
-extern m68ki_cpu_core PicoS68kCPU; // Mega CD's CPU\r
+extern m68ki_cpu_core PicoCpuMM68k, PicoCpuMS68k;\r
 #ifndef SekCyclesLeft\r
-#define SekCyclesLeftNoMCD PicoM68kCPU.cyc_remaining_cycles\r
+#define SekCyclesLeftNoMCD PicoCpuMM68k.cyc_remaining_cycles\r
 #define SekCyclesLeft \\r
        (((PicoMCD&1) && (PicoOpt & 0x2000)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)\r
 #define SekCyclesLeftS68k \\r
-       ((PicoOpt & 0x2000) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoS68kCPU.cyc_remaining_cycles)\r
+       ((PicoOpt & 0x2000) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuMS68k.cyc_remaining_cycles)\r
 #define SekSetCyclesLeftNoMCD(c) SET_CYCLES(c)\r
 #define SekSetCyclesLeft(c) { \\r
        if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCycleCnt=SekCycleAim-(c); else SET_CYCLES(c); \\r
 }\r
-#define SekPc m68k_get_reg(&PicoM68kCPU, M68K_REG_PC)\r
-#define SekPcS68k m68k_get_reg(&PicoS68kCPU, M68K_REG_PC)\r
+#define SekPc m68k_get_reg(&PicoCpuMM68k, M68K_REG_PC)\r
+#define SekPcS68k m68k_get_reg(&PicoCpuMS68k, M68K_REG_PC)\r
 #define SekSetStop(x) { \\r
-       if(x) { SET_CYCLES(0); PicoM68kCPU.stopped=STOP_LEVEL_STOP; } \\r
-       else PicoM68kCPU.stopped=0; \\r
+       if(x) { SET_CYCLES(0); PicoCpuMM68k.stopped=STOP_LEVEL_STOP; } \\r
+       else PicoCpuMM68k.stopped=0; \\r
 }\r
 #define SekSetStopS68k(x) { \\r
-       if(x) { SET_CYCLES(0); PicoS68kCPU.stopped=STOP_LEVEL_STOP; } \\r
-       else PicoS68kCPU.stopped=0; \\r
+       if(x) { SET_CYCLES(0); PicoCpuMS68k.stopped=STOP_LEVEL_STOP; } \\r
+       else PicoCpuMS68k.stopped=0; \\r
 }\r
 #endif\r
 #endif\r
@@ -345,7 +344,7 @@ PICO_INTERNAL int PicoFrameMCD(void);
 PICO_INTERNAL int SekInit(void);\r
 PICO_INTERNAL int SekReset(void);\r
 PICO_INTERNAL int SekInterrupt(int irq);\r
-PICO_INTERNAL void SekState(unsigned char *data);\r
+PICO_INTERNAL void SekState(int *data);\r
 PICO_INTERNAL void SekSetRealTAS(int use_real);\r
 \r
 // cd/Sek.c\r
index f3af531..449a4d7 100644 (file)
@@ -18,15 +18,15 @@ unsigned int SekCycleCntT=0;
 /* context */\r
 // Cyclone 68000\r
 #ifdef EMU_C68K\r
-struct Cyclone PicoCpu;\r
+struct Cyclone PicoCpuCM68k;\r
 #endif\r
 // MUSASHI 68000\r
 #ifdef EMU_M68K\r
-m68ki_cpu_core PicoM68kCPU;\r
+m68ki_cpu_core PicoCpuMM68k;\r
 #endif\r
 // FAME 68000\r
 #ifdef EMU_F68K\r
-M68K_CONTEXT PicoCpuM68k;\r
+M68K_CONTEXT PicoCpuFM68k;\r
 #endif\r
 \r
 \r
@@ -38,7 +38,7 @@ static int SekIntAck(int level)
   // try to emulate VDP's reaction to 68000 int ack\r
   if     (level == 4) { Pico.video.pending_ints  =  0;    elprintf(EL_INTS, "hack: @ %06x [%i]", SekPc, SekCycleCnt); }\r
   else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%i]", SekPc, SekCycleCnt); }\r
-  PicoCpu.irq = 0;\r
+  PicoCpuCM68k.irq = 0;\r
   return CYCLONE_INT_ACK_AUTOVECTOR;\r
 }\r
 \r
@@ -51,12 +51,12 @@ static int SekUnrecognizedOpcode()
 {\r
   unsigned int pc, op;\r
   pc = SekPc;\r
-  op = PicoCpu.read16(pc);\r
+  op = PicoCpuCM68k.read16(pc);\r
   elprintf(EL_ANOMALY, "Unrecognized Opcode %04x @ %06x", op, pc);\r
   // see if we are not executing trash\r
   if (pc < 0x200 || (pc > Pico.romsize+4 && (pc&0xe00000)!=0xe00000)) {\r
-    PicoCpu.cycles = 0;\r
-    PicoCpu.state_flags |= 1;\r
+    PicoCpuCM68k.cycles = 0;\r
+    PicoCpuCM68k.state_flags |= 1;\r
     return 1;\r
   }\r
 #ifdef EMU_M68K // debugging cyclone\r
@@ -87,31 +87,11 @@ static int SekTasCallback(void)
 \r
 \r
 #ifdef EMU_F68K\r
-static void setup_fame_fetchmap(void)\r
-{\r
-  int i;\r
-\r
-  // be default, point everything to fitst 64k of ROM\r
-  for (i = 0; i < M68K_FETCHBANK1; i++)\r
-    PicoCpuM68k.Fetch[i] = (unsigned int)Pico.rom - (i<<(24-FAMEC_FETCHBITS));\r
-  // now real ROM\r
-  for (i = 0; i < M68K_FETCHBANK1 && (i<<(24-FAMEC_FETCHBITS)) < Pico.romsize; i++)\r
-    PicoCpuM68k.Fetch[i] = (unsigned int)Pico.rom;\r
-  elprintf(EL_ANOMALY, "ROM end @ #%i %06x", i, (i<<(24-FAMEC_FETCHBITS)));\r
-  // .. and RAM (TODO)\r
-  for (i = M68K_FETCHBANK1*14/16; i < M68K_FETCHBANK1; i++)\r
-    PicoCpuM68k.Fetch[i] = (unsigned int)Pico.ram - (i<<(24-FAMEC_FETCHBITS));\r
-\r
-  elprintf(EL_ANOMALY, "rom = %p, ram = %p", Pico.rom, Pico.ram);\r
-  for (i = 0; i < M68K_FETCHBANK1; i++)\r
-    elprintf(EL_ANOMALY, "Fetch[%i] = %p", i, PicoCpuM68k.Fetch[i]);\r
-}\r
-\r
-void SekIntAckF68K(unsigned level)\r
+static void SekIntAckF68K(unsigned level)\r
 {\r
   if     (level == 4) { Pico.video.pending_ints  =  0;    elprintf(EL_INTS, "hack: @ %06x [%i]", SekPc, SekCycleCnt); }\r
   else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%i]", SekPc, SekCycleCnt); }\r
-  PicoCpuM68k.interrupts[0] = 0;\r
+  PicoCpuFM68k.interrupts[0] = 0;\r
 }\r
 #endif\r
 \r
@@ -120,15 +100,15 @@ PICO_INTERNAL int SekInit()
 {\r
 #ifdef EMU_C68K\r
   CycloneInit();\r
-  memset(&PicoCpu,0,sizeof(PicoCpu));\r
-  PicoCpu.IrqCallback=SekIntAck;\r
-  PicoCpu.ResetCallback=SekResetAck;\r
-  PicoCpu.UnrecognizedCallback=SekUnrecognizedOpcode;\r
+  memset(&PicoCpuCM68k,0,sizeof(PicoCpuCM68k));\r
+  PicoCpuCM68k.IrqCallback=SekIntAck;\r
+  PicoCpuCM68k.ResetCallback=SekResetAck;\r
+  PicoCpuCM68k.UnrecognizedCallback=SekUnrecognizedOpcode;\r
 #endif\r
 #ifdef EMU_M68K\r
   {\r
     void *oldcontext = m68ki_cpu_p;\r
-    m68k_set_context(&PicoM68kCPU);\r
+    m68k_set_context(&PicoCpuMM68k);\r
     m68k_set_cpu_type(M68K_CPU_TYPE_68000);\r
     m68k_init();\r
     m68k_set_int_ack_callback(SekIntAckM68K);\r
@@ -140,10 +120,10 @@ PICO_INTERNAL int SekInit()
 #ifdef EMU_F68K\r
   {\r
     void *oldcontext = g_m68kcontext;\r
-    g_m68kcontext = &PicoCpuM68k;\r
-    memset(&PicoCpuM68k, 0, sizeof(PicoCpuM68k));\r
+    g_m68kcontext = &PicoCpuFM68k;\r
+    memset(&PicoCpuFM68k, 0, sizeof(PicoCpuFM68k));\r
     m68k_init();\r
-    PicoCpuM68k.iack_handler = SekIntAckF68K;\r
+    PicoCpuFM68k.iack_handler = SekIntAckF68K;\r
     g_m68kcontext = oldcontext;\r
   }\r
 #endif\r
@@ -158,28 +138,25 @@ PICO_INTERNAL int SekReset()
   if (Pico.rom==NULL) return 1;\r
 \r
 #ifdef EMU_C68K\r
-  PicoCpu.state_flags=0;\r
-  PicoCpu.osp=0;\r
-  PicoCpu.srh =0x27; // Supervisor mode\r
-  PicoCpu.flags=4;   // Z set\r
-  PicoCpu.irq=0;\r
-  PicoCpu.a[7]=PicoCpu.read32(0); // Stack Pointer\r
-  PicoCpu.membase=0;\r
-  PicoCpu.pc=PicoCpu.checkpc(PicoCpu.read32(4)); // Program Counter\r
+  PicoCpuCM68k.state_flags=0;\r
+  PicoCpuCM68k.osp=0;\r
+  PicoCpuCM68k.srh =0x27; // Supervisor mode\r
+  PicoCpuCM68k.flags=4;   // Z set\r
+  PicoCpuCM68k.irq=0;\r
+  PicoCpuCM68k.a[7]=PicoCpuCM68k.read32(0); // Stack Pointer\r
+  PicoCpuCM68k.membase=0;\r
+  PicoCpuCM68k.pc=PicoCpuCM68k.checkpc(PicoCpuCM68k.read32(4)); // Program Counter\r
 #endif\r
 #ifdef EMU_M68K\r
-  m68k_set_context(&PicoM68kCPU); // if we ever reset m68k, we always need it's context to be set\r
+  m68k_set_context(&PicoCpuMM68k); // if we ever reset m68k, we always need it's context to be set\r
   m68ki_cpu.sp[0]=0;\r
   m68k_set_irq(0);\r
   m68k_pulse_reset();\r
 #endif\r
 #ifdef EMU_F68K\r
   {\r
-    unsigned ret;\r
-    g_m68kcontext = &PicoCpuM68k;\r
-    setup_fame_fetchmap();\r
-    ret = m68k_reset();\r
-    /*if (ret)*/ elprintf(EL_ANOMALY, "m68k_reset returned %u", ret);\r
+    g_m68kcontext = &PicoCpuFM68k;\r
+    m68k_reset();\r
   }\r
 #endif\r
 \r
@@ -197,33 +174,34 @@ PICO_INTERNAL int SekInterrupt(int irq)
   }\r
 #endif\r
 #ifdef EMU_C68K\r
-  PicoCpu.irq=irq;\r
+  PicoCpuCM68k.irq=irq;\r
 #endif\r
 #ifdef EMU_M68K\r
   {\r
     void *oldcontext = m68ki_cpu_p;\r
-    m68k_set_context(&PicoM68kCPU);\r
+    m68k_set_context(&PicoCpuMM68k);\r
     m68k_set_irq(irq); // raise irq (gets lowered after taken or must be done in ack)\r
     m68k_set_context(oldcontext);\r
   }\r
 #endif\r
 #ifdef EMU_F68K\r
-  PicoCpuM68k.interrupts[0]=irq;\r
+  PicoCpuFM68k.interrupts[0]=irq;\r
 #endif\r
 \r
   return 0;\r
 }\r
 \r
-PICO_INTERNAL void SekState(unsigned char *data)\r
+// data must be word aligned\r
+PICO_INTERNAL void SekState(int *data)\r
 {\r
 #ifdef EMU_C68K\r
-  memcpy(data,PicoCpu.d,0x44);\r
+  memcpy32(data,PicoCpuCM68k.d,0x44/4);\r
 #elif defined(EMU_M68K)\r
-  memcpy(data, PicoM68kCPU.dar, 0x40);\r
-  *(int *)(data+0x40) = PicoM68kCPU.pc;\r
+  memcpy32(data, PicoCpuMM68k.dar, 0x40/4);\r
+  data[0x10] = PicoCpuMM68k.pc;\r
 #elif defined(EMU_F68K)\r
-  memcpy(data, PicoCpuM68k.dreg, 0x40);\r
-  *(int *)(data+0x40) = PicoCpuM68k.pc;\r
+  memcpy32(data, (int *)PicoCpuFM68k.dreg, 0x40/4);\r
+  data[0x10] = PicoCpuFM68k.pc;\r
 #endif\r
 }\r
 \r
index 6f41dfa..ffbda06 100644 (file)
@@ -382,7 +382,7 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d)
         if(num < 2) {\r
 #ifdef EMU_C68K\r
           // hack: make sure we do not touch the irq line if Cyclone is just about to take the IRQ\r
-          if (PicoCpu.irq <= (PicoCpu.srh&7)) {\r
+          if (PicoCpuCM68k.irq <= (PicoCpuCM68k.srh&7)) {\r
 #endif\r
             int lines, pints;\r
             lines = (pvid->reg[1] & 0x20) | (pvid->reg[0] & 0x10);\r
@@ -392,7 +392,7 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d)
             else SekInterrupt(0);\r
 #ifdef EMU_C68K\r
             // adjust cycles for Cyclone so it would take the int "in time"\r
-            if(PicoCpu.irq) {\r
+            if(PicoCpuCM68k.irq) {\r
               SekEndRun(24);\r
             }\r
           }\r
index a15f85b..854bb74 100644 (file)
@@ -22,8 +22,8 @@ void dumpPCandExit()
   dprintf("PC: %06x: %04x: %s", pppc, ppop, buff);\r
   dprintf("                    this | prev");\r
   for(i=0; i < 8; i++)\r
-    dprintf("d%i=%08x, a%i=%08x | d%i=%08x, a%i=%08x", i, PicoCpu.d[i], i, PicoCpu.a[i], i, old_regs[i], i, old_regs[i+8]);\r
-  dprintf("SR:                 %04x | %04x (??s? 0iii 000x nzvc)", CycloneGetSr(&PicoCpu), old_sr);\r
+    dprintf("d%i=%08x, a%i=%08x | d%i=%08x, a%i=%08x", i, PicoCpuCM68k.d[i], i, PicoCpuCM68k.a[i], i, old_regs[i], i, old_regs[i+8]);\r
+  dprintf("SR:                 %04x | %04x (??s? 0iii 000x nzvc)", CycloneGetSr(&PicoCpuCM68k), old_sr);\r
   dprintf("last_read: %08x @ %06x", lastread_d[--lrp_cyc&15], lastread_a);\r
   dprintf("ops done: %i", ops);\r
   exit(1);\r
@@ -43,7 +43,7 @@ int CM_compareRun(int cyc)
     {\r
       have_illegal = 0;\r
       m68ki_cpu.pc += 2;\r
-      PicoCpu.pc=PicoCpu.checkpc(PicoCpu.pc + 2);\r
+      PicoCpuCM68k.pc=PicoCpuCM68k.checkpc(PicoCpuCM68k.pc + 2);\r
     }\r
     // hacks for test_misc2\r
     if (m68ki_cpu.pc == 0x0002e0 && m68k_read_disassembler_16(m68ki_cpu.pc) == 0x4e73)\r
@@ -51,13 +51,13 @@ int CM_compareRun(int cyc)
       // get out of "priviledge violation" loop\r
       have_illegal = 1;\r
       //m68ki_cpu.s_flag = SFLAG_SET;\r
-      //PicoCpu.srh|=0x20;\r
+      //PicoCpuCM68k.srh|=0x20;\r
     }\r
 \r
     pppc = SekPc;\r
     ppop = m68k_read_disassembler_16(pppc);\r
-    memcpy(old_regs, PicoCpu.d, 4*16);\r
-    old_sr = CycloneGetSr(&PicoCpu);\r
+    memcpy(old_regs, PicoCpuCM68k.d, 4*16);\r
+    old_sr = CycloneGetSr(&PicoCpuCM68k);\r
 \r
 #if 0\r
     {\r
@@ -65,20 +65,20 @@ int CM_compareRun(int cyc)
       dprintf("---");\r
       m68k_disassemble(buff, pppc, M68K_CPU_TYPE_68000);\r
       dprintf("PC: %06x: %04x: %s", pppc, ppop, buff);\r
-      //dprintf("A7: %08x", PicoCpu.a[7]);\r
+      //dprintf("A7: %08x", PicoCpuCM68k.a[7]);\r
     }\r
 #endif\r
 \r
     if (dbg_irq_level)\r
     {\r
-      PicoCpu.irq=dbg_irq_level;\r
+      PicoCpuCM68k.irq=dbg_irq_level;\r
       m68k_set_irq(dbg_irq_level);\r
       dbg_irq_level=0;\r
     }\r
 \r
-    PicoCpu.cycles=1;\r
-    CycloneRun(&PicoCpu);\r
-    cyc_cyclone=1-PicoCpu.cycles;\r
+    PicoCpuCM68k.cycles=1;\r
+    CycloneRun(&PicoCpuCM68k);\r
+    cyc_cyclone=1-PicoCpuCM68k.cycles;\r
     cyc_musashi=m68k_execute(1);\r
 \r
     if(cyc_cyclone != cyc_musashi) {\r
@@ -120,57 +120,57 @@ int CM_compareRun(int cyc)
 \r
     // compare regs\r
     for(i=0; i < 16; i++) {\r
-      if(PicoCpu.d[i] != m68ki_cpu.dar[i]) {\r
+      if(PicoCpuCM68k.d[i] != m68ki_cpu.dar[i]) {\r
         str = (i < 8) ? "d" : "a";\r
-        dprintf("reg: %s%i: %08x vs %08x", str, i&7, PicoCpu.d[i], m68ki_cpu.dar[i]);\r
+        dprintf("reg: %s%i: %08x vs %08x", str, i&7, PicoCpuCM68k.d[i], m68ki_cpu.dar[i]);\r
         err=1;\r
       }\r
     }\r
 \r
     // SR\r
-    if((CycloneGetSr(&PicoCpu)) != (mu_sr = m68k_get_reg(NULL, M68K_REG_SR))) {\r
-      dprintf("SR: %04x vs %04x (??s? 0iii 000x nzvc)", CycloneGetSr(&PicoCpu), mu_sr);\r
+    if((CycloneGetSr(&PicoCpuCM68k)) != (mu_sr = m68k_get_reg(NULL, M68K_REG_SR))) {\r
+      dprintf("SR: %04x vs %04x (??s? 0iii 000x nzvc)", CycloneGetSr(&PicoCpuCM68k), mu_sr);\r
       err=1;\r
     }\r
 \r
     // IRQl\r
-    if(PicoCpu.irq != (m68ki_cpu.int_level>>8)) {\r
-      dprintf("IRQ: %i vs %i", PicoCpu.irq, (m68ki_cpu.int_level>>8));\r
+    if(PicoCpuCM68k.irq != (m68ki_cpu.int_level>>8)) {\r
+      dprintf("IRQ: %i vs %i", PicoCpuCM68k.irq, (m68ki_cpu.int_level>>8));\r
       err=1;\r
     }\r
 \r
     // OSP/USP\r
-    if(PicoCpu.osp != m68ki_cpu.sp[((mu_sr>>11)&4)^4]) {\r
-      dprintf("OSP: %06x vs %06x", PicoCpu.osp, m68ki_cpu.sp[((mu_sr>>11)&4)^4]);\r
+    if(PicoCpuCM68k.osp != m68ki_cpu.sp[((mu_sr>>11)&4)^4]) {\r
+      dprintf("OSP: %06x vs %06x", PicoCpuCM68k.osp, m68ki_cpu.sp[((mu_sr>>11)&4)^4]);\r
       err=1;\r
     }\r
 \r
     // stopped\r
-    if(((PicoCpu.state_flags&1) && !m68ki_cpu.stopped) || (!(PicoCpu.state_flags&1) && m68ki_cpu.stopped)) {\r
-      dprintf("stopped: %i vs %i", PicoCpu.state_flags&1, m68ki_cpu.stopped);\r
+    if(((PicoCpuCM68k.state_flags&1) && !m68ki_cpu.stopped) || (!(PicoCpuCM68k.state_flags&1) && m68ki_cpu.stopped)) {\r
+      dprintf("stopped: %i vs %i", PicoCpuCM68k.state_flags&1, m68ki_cpu.stopped);\r
       err=1;\r
     }\r
 \r
     // tracing\r
-    if(((PicoCpu.state_flags&2) && !m68ki_tracing) || (!(PicoCpu.state_flags&2) && m68ki_tracing)) {\r
-      dprintf("tracing: %i vs %i", PicoCpu.state_flags&2, m68ki_tracing);\r
+    if(((PicoCpuCM68k.state_flags&2) && !m68ki_tracing) || (!(PicoCpuCM68k.state_flags&2) && m68ki_tracing)) {\r
+      dprintf("tracing: %i vs %i", PicoCpuCM68k.state_flags&2, m68ki_tracing);\r
       err=1;\r
     }\r
 \r
     if(err) dumpPCandExit();\r
 \r
 #if 0\r
-    if (PicoCpu.a[7] < 0x00ff0000 || PicoCpu.a[7] >= 0x01000000)\r
+    if (PicoCpuCM68k.a[7] < 0x00ff0000 || PicoCpuCM68k.a[7] >= 0x01000000)\r
     {\r
-      PicoCpu.a[7] = m68ki_cpu.dar[15] = 0xff8000;\r
+      PicoCpuCM68k.a[7] = m68ki_cpu.dar[15] = 0xff8000;\r
     }\r
 #endif\r
 #if 0\r
     m68k_set_reg(M68K_REG_SR, ((mu_sr-1)&~0x2000)|(mu_sr&0x2000)); // broken\r
-    CycloneSetSr(&PicoCpu, ((mu_sr-1)&~0x2000)|(mu_sr&0x2000));\r
-    PicoCpu.stopped = m68ki_cpu.stopped = 0;\r
-    if(SekPc > 0x400 && (PicoCpu.a[7] < 0xff0000 || PicoCpu.a[7] > 0xffffff))\r
-    PicoCpu.a[7] = m68ki_cpu.dar[15] = 0xff8000;\r
+    CycloneSetSr(&PicoCpuCM68k, ((mu_sr-1)&~0x2000)|(mu_sr&0x2000));\r
+    PicoCpuCM68k.stopped = m68ki_cpu.stopped = 0;\r
+    if(SekPc > 0x400 && (PicoCpuCM68k.a[7] < 0xff0000 || PicoCpuCM68k.a[7] > 0xffffff))\r
+    PicoCpuCM68k.a[7] = m68ki_cpu.dar[15] = 0xff8000;\r
 #endif\r
 \r
     cyc_done += cyc_cyclone;\r
index dbd66cb..1dd6fc4 100644 (file)
@@ -240,8 +240,8 @@ PICO_INTERNAL int PicoCdLoadState(void *file)
        /* after load events */
        if (Pico_mcd->s68k_regs[3]&4) // 1M mode?
                wram_2M_to_1M(Pico_mcd->word_ram2M);
-#ifdef _ASM_CD_MEMORY_C
        PicoMemResetCD(Pico_mcd->s68k_regs[3]);
+#ifdef _ASM_CD_MEMORY_C
        if (Pico_mcd->s68k_regs[3]&4)
                PicoMemResetCDdecode(Pico_mcd->s68k_regs[3]);
 #endif
index 92c6060..1be1823 100644 (file)
@@ -293,9 +293,7 @@ void s68k_reg_write8(u32 a, u32 d)
       if (d&4) {\r
         if ((d ^ dold) & 5) {\r
           d &= ~2; // in case of mode or bank change we clear DMNA (m68k req) bit\r
-#ifdef _ASM_CD_MEMORY_C\r
           PicoMemResetCD(d);\r
-#endif\r
         }\r
 #ifdef _ASM_CD_MEMORY_C\r
         if ((d ^ dold) & 0x1d)\r
@@ -313,9 +311,7 @@ void s68k_reg_write8(u32 a, u32 d)
             d |= (dold&1) ? 2 : 1; // then give it to the one which had bank0 in 1M mode\r
           }\r
           wram_1M_to_2M(Pico_mcd->word_ram2M);\r
-#ifdef _ASM_CD_MEMORY_C\r
           PicoMemResetCD(d);\r
-#endif\r
         }\r
         else\r
           d |= dold&1;\r
@@ -817,7 +813,7 @@ static u32 PicoReadS68k8(u32 a)
     // test: batman returns\r
     wrdprintf("s68k_wram2M r8: [%06x] @%06x", a, SekPcS68k);\r
     if (Pico_mcd->s68k_regs[3]&4) { // 1M decode mode?\r
-      int bank = !(Pico_mcd->s68k_regs[3]&1);\r
+      int bank = (Pico_mcd->s68k_regs[3]&1)^1;\r
       d = Pico_mcd->word_ram1M[bank][((a>>1)^1)&0x1ffff];\r
       if (a&1) d &= 0x0f;\r
       else d >>= 4;\r
@@ -836,7 +832,7 @@ static u32 PicoReadS68k8(u32 a)
     wrdprintf("s68k_wram1M r8: [%06x] @%06x", a, SekPcS68k);\r
 //    if (!(Pico_mcd->s68k_regs[3]&4))\r
 //      dprintf("s68k_wram1M FIXME: wrong mode");\r
-    bank = !(Pico_mcd->s68k_regs[3]&1);\r
+    bank = (Pico_mcd->s68k_regs[3]&1)^1;\r
     d = Pico_mcd->word_ram1M[bank][(a^1)&0x1ffff];\r
     wrdprintf("ret = %02x", (u8)d);\r
     goto end;\r
@@ -907,7 +903,7 @@ static u32 PicoReadS68k16(u32 a)
   if ((a&0xfc0000)==0x080000) { // 080000-0bffff\r
     wrdprintf("s68k_wram2M r16: [%06x] @%06x", a, SekPcS68k);\r
     if (Pico_mcd->s68k_regs[3]&4) { // 1M decode mode?\r
-      int bank = !(Pico_mcd->s68k_regs[3]&1);\r
+      int bank = (Pico_mcd->s68k_regs[3]&1)^1;\r
       d = Pico_mcd->word_ram1M[bank][((a>>1)^1)&0x1ffff];\r
       d |= d << 4; d &= ~0xf0;\r
       dprintf("FIXME: decode");\r
@@ -925,7 +921,7 @@ static u32 PicoReadS68k16(u32 a)
     wrdprintf("s68k_wram1M r16: [%06x] @%06x", a, SekPcS68k);\r
 //    if (!(Pico_mcd->s68k_regs[3]&4))\r
 //      dprintf("s68k_wram1M FIXME: wrong mode");\r
-    bank = !(Pico_mcd->s68k_regs[3]&1);\r
+    bank = (Pico_mcd->s68k_regs[3]&1)^1;\r
     d = *(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe));\r
     wrdprintf("ret = %04x", d);\r
     goto end;\r
@@ -999,7 +995,7 @@ static u32 PicoReadS68k32(u32 a)
   if ((a&0xfc0000)==0x080000) { // 080000-0bffff\r
     wrdprintf("s68k_wram2M r32: [%06x] @%06x", a, SekPcS68k);\r
     if (Pico_mcd->s68k_regs[3]&4) { // 1M decode mode?\r
-      int bank = !(Pico_mcd->s68k_regs[3]&1);\r
+      int bank = (Pico_mcd->s68k_regs[3]&1)^1;\r
       a >>= 1;\r
       d  = Pico_mcd->word_ram1M[bank][((a+0)^1)&0x1ffff] << 16;\r
       d |= Pico_mcd->word_ram1M[bank][((a+1)^1)&0x1ffff];\r
@@ -1018,7 +1014,7 @@ static u32 PicoReadS68k32(u32 a)
     wrdprintf("s68k_wram1M r32: [%06x] @%06x", a, SekPcS68k);\r
 //    if (!(Pico_mcd->s68k_regs[3]&4))\r
 //      dprintf("s68k_wram1M FIXME: wrong mode");\r
-    bank = !(Pico_mcd->s68k_regs[3]&1);\r
+    bank = (Pico_mcd->s68k_regs[3]&1)^1;\r
     u16 *pm=(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe)); d = (pm[0]<<16)|pm[1];\r
     wrdprintf("ret = %08x", d);\r
     goto end;\r
@@ -1075,7 +1071,7 @@ static u32 PicoReadS68k32(u32 a)
 /* check: jaguar xj 220 (draws entire world using decode) */\r
 static void decode_write8(u32 a, u8 d, int r3)\r
 {\r
-  u8 *pd = Pico_mcd->word_ram1M[!(r3 & 1)] + (((a>>1)^1)&0x1ffff);\r
+  u8 *pd = Pico_mcd->word_ram1M[(r3 & 1)^1] + (((a>>1)^1)&0x1ffff);\r
   u8 oldmask = (a&1) ? 0xf0 : 0x0f;\r
 \r
   r3 &= 0x18;\r
@@ -1098,7 +1094,7 @@ do_it:
 \r
 static void decode_write16(u32 a, u16 d, int r3)\r
 {\r
-  u8 *pd = Pico_mcd->word_ram1M[!(r3 & 1)] + (((a>>1)^1)&0x1ffff);\r
+  u8 *pd = Pico_mcd->word_ram1M[(r3 & 1)^1] + (((a>>1)^1)&0x1ffff);\r
 \r
   //if ((a & 0x3ffff) < 0x28000) return;\r
 \r
@@ -1173,7 +1169,7 @@ static void PicoWriteS68k8(u32 a,u8 d)
       wrdprintf("s68k_wram1M w8: [%06x] %02x @%06x", a, d, SekPcS68k);\r
 //    if (!(Pico_mcd->s68k_regs[3]&4))\r
 //      dprintf("s68k_wram1M FIXME: wrong mode");\r
-    bank = !(Pico_mcd->s68k_regs[3]&1);\r
+    bank = (Pico_mcd->s68k_regs[3]&1)^1;\r
     *(u8 *)(Pico_mcd->word_ram1M[bank]+((a^1)&0x1ffff))=d;\r
     return;\r
   }\r
@@ -1256,7 +1252,7 @@ static void PicoWriteS68k16(u32 a,u16 d)
       wrdprintf("s68k_wram1M w16: [%06x] %04x @%06x", a, d, SekPcS68k);\r
 //    if (!(Pico_mcd->s68k_regs[3]&4))\r
 //      dprintf("s68k_wram1M FIXME: wrong mode");\r
-    bank = !(Pico_mcd->s68k_regs[3]&1);\r
+    bank = (Pico_mcd->s68k_regs[3]&1)^1;\r
     *(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe))=d;\r
     return;\r
   }\r
@@ -1346,7 +1342,7 @@ static void PicoWriteS68k32(u32 a,u32 d)
       wrdprintf("s68k_wram1M w32: [%06x] %08x @%06x", a, d, SekPcS68k);\r
 //    if (!(Pico_mcd->s68k_regs[3]&4))\r
 //      dprintf("s68k_wram1M FIXME: wrong mode");\r
-    bank = !(Pico_mcd->s68k_regs[3]&1);\r
+    bank = (Pico_mcd->s68k_regs[3]&1)^1;\r
     pm=(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe));\r
     pm[0]=(u16)(d>>16); pm[1]=(u16)d;\r
     return;\r
@@ -1387,7 +1383,7 @@ static void PicoWriteS68k32(u32 a,u32 d)
 // -----------------------------------------------------------------\r
 \r
 \r
-#if defined(EMU_C68K)\r
+#ifdef EMU_C68K\r
 static __inline int PicoMemBaseM68k(u32 pc)\r
 {\r
   if ((pc&0xe00000)==0xe00000)\r
@@ -1401,7 +1397,7 @@ static __inline int PicoMemBaseM68k(u32 pc)
     if (!(Pico_mcd->s68k_regs[3]&4))\r
       return (int)Pico_mcd->word_ram2M - 0x200000; // Program Counter in Word Ram\r
     if (pc < 0x220000) {\r
-      int bank = (Pico_mcd->s68k_regs[3]&1);\r
+      int bank = Pico_mcd->s68k_regs[3]&1;\r
       return (int)Pico_mcd->word_ram1M[bank] - 0x200000;\r
     }\r
   }\r
@@ -1415,12 +1411,12 @@ static __inline int PicoMemBaseM68k(u32 pc)
 \r
 static u32 PicoCheckPcM68k(u32 pc)\r
 {\r
-  pc-=PicoCpu.membase; // Get real pc\r
+  pc-=PicoCpuCM68k.membase; // Get real pc\r
   pc&=0xfffffe;\r
 \r
-  PicoCpu.membase=PicoMemBaseM68k(pc);\r
+  PicoCpuCM68k.membase=PicoMemBaseM68k(pc);\r
 \r
-  return PicoCpu.membase+pc;\r
+  return PicoCpuCM68k.membase+pc;\r
 }\r
 \r
 \r
@@ -1433,7 +1429,7 @@ static __inline int PicoMemBaseS68k(u32 pc)
     return (int)Pico_mcd->word_ram2M - 0x080000;\r
 \r
   if ((pc&0xfe0000)==0x0c0000) {        // word RAM 1M area\r
-    int bank = !(Pico_mcd->s68k_regs[3]&1);\r
+    int bank = (Pico_mcd->s68k_regs[3]&1)^1;\r
     return (int)Pico_mcd->word_ram1M[bank] - 0x0c0000;\r
   }\r
 \r
@@ -1446,37 +1442,101 @@ static __inline int PicoMemBaseS68k(u32 pc)
 \r
 static u32 PicoCheckPcS68k(u32 pc)\r
 {\r
-  pc-=PicoCpuS68k.membase; // Get real pc\r
+  pc-=PicoCpuCS68k.membase; // Get real pc\r
   pc&=0xfffffe;\r
 \r
-  PicoCpuS68k.membase=PicoMemBaseS68k(pc);\r
+  PicoCpuCS68k.membase=PicoMemBaseS68k(pc);\r
 \r
-  return PicoCpuS68k.membase+pc;\r
+  return PicoCpuCS68k.membase+pc;\r
 }\r
 #endif\r
 \r
+#ifndef _ASM_CD_MEMORY_C\r
+void PicoMemResetCD(int r3)\r
+{\r
+#ifdef EMU_F68K\r
+  // update fetchmap..\r
+  int i;\r
+  if (!(r3 & 4))\r
+  {\r
+    for (i = M68K_FETCHBANK1*2/16; (i<<(24-FAMEC_FETCHBITS)) < 0x240000; i++)\r
+      PicoCpuFM68k.Fetch[i] = (unsigned int)Pico_mcd->word_ram2M - 0x200000;\r
+  }\r
+  else\r
+  {\r
+    for (i = M68K_FETCHBANK1*2/16; (i<<(24-FAMEC_FETCHBITS)) < 0x220000; i++)\r
+      PicoCpuFM68k.Fetch[i] = (unsigned int)Pico_mcd->word_ram1M[r3 & 1] - 0x200000;\r
+    for (i = M68K_FETCHBANK1*0x0c/0x100; (i<<(24-FAMEC_FETCHBITS)) < 0x0e0000; i++)\r
+      PicoCpuFS68k.Fetch[i] = (unsigned int)Pico_mcd->word_ram1M[(r3&1)^1] - 0x0c0000;\r
+  }\r
+#endif\r
+}\r
+#endif\r
 \r
 PICO_INTERNAL void PicoMemSetupCD(void)\r
 {\r
   dprintf("PicoMemSetupCD()");\r
 #ifdef EMU_C68K\r
   // Setup m68k memory callbacks:\r
-  PicoCpu.checkpc=PicoCheckPcM68k;\r
-  PicoCpu.fetch8 =PicoCpu.read8 =PicoReadM68k8;\r
-  PicoCpu.fetch16=PicoCpu.read16=PicoReadM68k16;\r
-  PicoCpu.fetch32=PicoCpu.read32=PicoReadM68k32;\r
-  PicoCpu.write8 =PicoWriteM68k8;\r
-  PicoCpu.write16=PicoWriteM68k16;\r
-  PicoCpu.write32=PicoWriteM68k32;\r
+  PicoCpuCM68k.checkpc=PicoCheckPcM68k;\r
+  PicoCpuCM68k.fetch8 =PicoCpuCM68k.read8 =PicoReadM68k8;\r
+  PicoCpuCM68k.fetch16=PicoCpuCM68k.read16=PicoReadM68k16;\r
+  PicoCpuCM68k.fetch32=PicoCpuCM68k.read32=PicoReadM68k32;\r
+  PicoCpuCM68k.write8 =PicoWriteM68k8;\r
+  PicoCpuCM68k.write16=PicoWriteM68k16;\r
+  PicoCpuCM68k.write32=PicoWriteM68k32;\r
   // s68k\r
-  PicoCpuS68k.checkpc=PicoCheckPcS68k;\r
-  PicoCpuS68k.fetch8 =PicoCpuS68k.read8 =PicoReadS68k8;\r
-  PicoCpuS68k.fetch16=PicoCpuS68k.read16=PicoReadS68k16;\r
-  PicoCpuS68k.fetch32=PicoCpuS68k.read32=PicoReadS68k32;\r
-  PicoCpuS68k.write8 =PicoWriteS68k8;\r
-  PicoCpuS68k.write16=PicoWriteS68k16;\r
-  PicoCpuS68k.write32=PicoWriteS68k32;\r
+  PicoCpuCS68k.checkpc=PicoCheckPcS68k;\r
+  PicoCpuCS68k.fetch8 =PicoCpuCS68k.read8 =PicoReadS68k8;\r
+  PicoCpuCS68k.fetch16=PicoCpuCS68k.read16=PicoReadS68k16;\r
+  PicoCpuCS68k.fetch32=PicoCpuCS68k.read32=PicoReadS68k32;\r
+  PicoCpuCS68k.write8 =PicoWriteS68k8;\r
+  PicoCpuCS68k.write16=PicoWriteS68k16;\r
+  PicoCpuCS68k.write32=PicoWriteS68k32;\r
 #endif\r
+#ifdef EMU_F68K\r
+  // m68k\r
+  PicoCpuFM68k.read_byte =PicoReadM68k8;\r
+  PicoCpuFM68k.read_word =PicoReadM68k16;\r
+  PicoCpuFM68k.read_long =PicoReadM68k32;\r
+  PicoCpuFM68k.write_byte=PicoWriteM68k8;\r
+  PicoCpuFM68k.write_word=PicoWriteM68k16;\r
+  PicoCpuFM68k.write_long=PicoWriteM68k32;\r
+  // s68k\r
+  PicoCpuFS68k.read_byte =PicoReadS68k8;\r
+  PicoCpuFS68k.read_word =PicoReadS68k16;\r
+  PicoCpuFS68k.read_long =PicoReadS68k32;\r
+  PicoCpuFS68k.write_byte=PicoWriteS68k8;\r
+  PicoCpuFS68k.write_word=PicoWriteS68k16;\r
+  PicoCpuFS68k.write_long=PicoWriteS68k32;\r
+\r
+  // setup FAME fetchmap\r
+  {\r
+    int i;\r
+    // M68k\r
+    // by default, point everything to fitst 64k of ROM (BIOS)\r
+    for (i = 0; i < M68K_FETCHBANK1; i++)\r
+      PicoCpuFM68k.Fetch[i] = (unsigned int)Pico.rom - (i<<(24-FAMEC_FETCHBITS));\r
+    // now real ROM (BIOS)\r
+    for (i = 0; i < M68K_FETCHBANK1 && (i<<(24-FAMEC_FETCHBITS)) < Pico.romsize; i++)\r
+      PicoCpuFM68k.Fetch[i] = (unsigned int)Pico.rom;\r
+    // .. and RAM\r
+    for (i = M68K_FETCHBANK1*14/16; i < M68K_FETCHBANK1; i++)\r
+      PicoCpuFM68k.Fetch[i] = (unsigned int)Pico.ram - (i<<(24-FAMEC_FETCHBITS));\r
+    // S68k\r
+    // PRG RAM is default\r
+    for (i = 0; i < M68K_FETCHBANK1; i++)\r
+      PicoCpuFS68k.Fetch[i] = (unsigned int)Pico_mcd->prg_ram - (i<<(24-FAMEC_FETCHBITS));\r
+    // real PRG RAM\r
+    for (i = 0; i < M68K_FETCHBANK1 && (i<<(24-FAMEC_FETCHBITS)) < 0x80000; i++)\r
+      PicoCpuFS68k.Fetch[i] = (unsigned int)Pico_mcd->prg_ram;\r
+    // WORD RAM 2M area\r
+    for (i = M68K_FETCHBANK1*0x08/0x100; i < M68K_FETCHBANK1 && (i<<(24-FAMEC_FETCHBITS)) < 0xc0000; i++)\r
+      PicoCpuFS68k.Fetch[i] = (unsigned int)Pico_mcd->word_ram2M - 0x80000;\r
+    // PicoMemResetCD() will setup word ram for both\r
+  }\r
+#endif\r
+\r
   // m68k_poll_addr = m68k_poll_cnt = 0;\r
   s68k_poll_adclk = s68k_poll_cnt = 0;\r
 }\r
@@ -1484,33 +1544,33 @@ PICO_INTERNAL void PicoMemSetupCD(void)
 \r
 #ifdef EMU_M68K\r
 unsigned char  PicoReadCD8w (unsigned int a) {\r
-       return m68ki_cpu_p == &PicoS68kCPU ? PicoReadS68k8(a) : PicoReadM68k8(a);\r
+       return m68ki_cpu_p == &PicoCpuMS68k ? PicoReadS68k8(a) : PicoReadM68k8(a);\r
 }\r
 unsigned short PicoReadCD16w(unsigned int a) {\r
-       return m68ki_cpu_p == &PicoS68kCPU ? PicoReadS68k16(a) : PicoReadM68k16(a);\r
+       return m68ki_cpu_p == &PicoCpuMS68k ? PicoReadS68k16(a) : PicoReadM68k16(a);\r
 }\r
 unsigned int   PicoReadCD32w(unsigned int a) {\r
-       return m68ki_cpu_p == &PicoS68kCPU ? PicoReadS68k32(a) : PicoReadM68k32(a);\r
+       return m68ki_cpu_p == &PicoCpuMS68k ? PicoReadS68k32(a) : PicoReadM68k32(a);\r
 }\r
 void PicoWriteCD8w (unsigned int a, unsigned char d) {\r
-       if (m68ki_cpu_p == &PicoS68kCPU) PicoWriteS68k8(a, d); else PicoWriteM68k8(a, d);\r
+       if (m68ki_cpu_p == &PicoCpuMS68k) PicoWriteS68k8(a, d); else PicoWriteM68k8(a, d);\r
 }\r
 void PicoWriteCD16w(unsigned int a, unsigned short d) {\r
-       if (m68ki_cpu_p == &PicoS68kCPU) PicoWriteS68k16(a, d); else PicoWriteM68k16(a, d);\r
+       if (m68ki_cpu_p == &PicoCpuMS68k) PicoWriteS68k16(a, d); else PicoWriteM68k16(a, d);\r
 }\r
 void PicoWriteCD32w(unsigned int a, unsigned int d) {\r
-       if (m68ki_cpu_p == &PicoS68kCPU) PicoWriteS68k32(a, d); else PicoWriteM68k32(a, d);\r
+       if (m68ki_cpu_p == &PicoCpuMS68k) PicoWriteS68k32(a, d); else PicoWriteM68k32(a, d);\r
 }\r
 \r
 // these are allowed to access RAM\r
 unsigned int  m68k_read_pcrelative_CD8 (unsigned int a) {\r
   a&=0xffffff;\r
-  if(m68ki_cpu_p == &PicoS68kCPU) {\r
+  if(m68ki_cpu_p == &PicoCpuMS68k) {\r
     if (a < 0x80000) return *(u8 *)(Pico_mcd->prg_ram+(a^1)); // PRG Ram\r
     if ((a&0xfc0000)==0x080000 && !(Pico_mcd->s68k_regs[3]&4)) // word RAM (2M area: 080000-0bffff)\r
       return *(u8 *)(Pico_mcd->word_ram2M+((a^1)&0x3ffff));\r
     if ((a&0xfe0000)==0x0c0000 &&  (Pico_mcd->s68k_regs[3]&4)) { // word RAM (1M area: 0c0000-0dffff)\r
-      int bank = !(Pico_mcd->s68k_regs[3]&1);\r
+      int bank = (Pico_mcd->s68k_regs[3]&1)^1;\r
       return *(u8 *)(Pico_mcd->word_ram1M[bank]+((a^1)&0x1ffff));\r
     }\r
     dprintf("s68k_read_pcrelative_CD8 FIXME: can't handle %06x", a);\r
@@ -1531,12 +1591,12 @@ unsigned int  m68k_read_pcrelative_CD8 (unsigned int a) {
 }\r
 unsigned int  m68k_read_pcrelative_CD16(unsigned int a) {\r
   a&=0xffffff;\r
-  if(m68ki_cpu_p == &PicoS68kCPU) {\r
+  if(m68ki_cpu_p == &PicoCpuMS68k) {\r
     if (a < 0x80000) return *(u16 *)(Pico_mcd->prg_ram+(a&~1)); // PRG Ram\r
     if ((a&0xfc0000)==0x080000 && !(Pico_mcd->s68k_regs[3]&4)) // word RAM (2M area: 080000-0bffff)\r
       return *(u16 *)(Pico_mcd->word_ram2M+(a&0x3fffe));\r
     if ((a&0xfe0000)==0x0c0000 &&  (Pico_mcd->s68k_regs[3]&4)) { // word RAM (1M area: 0c0000-0dffff)\r
-      int bank = !(Pico_mcd->s68k_regs[3]&1);\r
+      int bank = (Pico_mcd->s68k_regs[3]&1)^1;\r
       return *(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe));\r
     }\r
     dprintf("s68k_read_pcrelative_CD16 FIXME: can't handle %06x", a);\r
@@ -1558,12 +1618,12 @@ unsigned int  m68k_read_pcrelative_CD16(unsigned int a) {
 unsigned int  m68k_read_pcrelative_CD32(unsigned int a) {\r
   u16 *pm;\r
   a&=0xffffff;\r
-  if(m68ki_cpu_p == &PicoS68kCPU) {\r
+  if(m68ki_cpu_p == &PicoCpuMS68k) {\r
     if (a < 0x80000) { u16 *pm=(u16 *)(Pico_mcd->prg_ram+(a&~1)); return (pm[0]<<16)|pm[1]; } // PRG Ram\r
     if ((a&0xfc0000)==0x080000 && !(Pico_mcd->s68k_regs[3]&4)) // word RAM (2M area: 080000-0bffff)\r
       { pm=(u16 *)(Pico_mcd->word_ram2M+(a&0x3fffe)); return (pm[0]<<16)|pm[1]; }\r
     if ((a&0xfe0000)==0x0c0000 &&  (Pico_mcd->s68k_regs[3]&4)) { // word RAM (1M area: 0c0000-0dffff)\r
-      int bank = !(Pico_mcd->s68k_regs[3]&1);\r
+      int bank = (Pico_mcd->s68k_regs[3]&1)^1;\r
       pm=(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe));\r
       return (pm[0]<<16)|pm[1];\r
     }\r
index 7b19e61..3b49cac 100644 (file)
@@ -136,7 +136,7 @@ m_s68k_decode_write_table:
 .extern gfx_cd_write16
 .extern s68k_reg_write8
 .extern s68k_poll_adclk
-.extern PicoCpuS68k
+.extern PicoCpuMS68k
 .extern s68k_poll_detect
 .extern SN76496Write
 .extern m_m68k_read8_misc
@@ -1259,7 +1259,7 @@ m_m68k_write16_regs_spec:               @ special case
     and     r2, r2, #0xfe
     cmp     r2, #0x0e
     bxne    lr
-    ldr     r0, =PicoCpuS68k
+    ldr     r0, =PicoCpuCS68k
     str     r1, [r0, #0x58]             @ push s68k out of stopped state
     str     r1, [r3]
     bx      lr
@@ -1450,7 +1450,7 @@ m_m68k_write32_regs_comm:             @ Handle the 0x10-0x1f range
     strneh  r1, [r2, #2]
     cmp     r0, #0x10
     bxlt    lr
-    ldr     r0, =PicoCpuS68k          @ remove poll detected state for s68k
+    ldr     r0, =PicoCpuCS68k         @ remove poll detected state for s68k
     mov     r1, #0
     str     r1, [r0, #0x58]
     str     r1, [r3]
index 16a25da..2550c3d 100644 (file)
@@ -69,8 +69,8 @@ PICO_INTERNAL int PicoResetMCD(int hard)
   Reset_CD();
   LC89510_Reset();
   gfx_cd_reset();
-#ifdef _ASM_CD_MEMORY_C
   PicoMemResetCD(1);
+#ifdef _ASM_CD_MEMORY_C
   //PicoMemResetCDdecode(1); // don't have to call this in 2M mode
 #endif
 
@@ -89,12 +89,15 @@ static __inline void SekRunM68k(int cyc)
   SekCycleAim+=cyc;
   if((cyc_do=SekCycleAim-SekCycleCnt) < 0) return;
 #if defined(EMU_C68K)
-  PicoCpu.cycles=cyc_do;
-  CycloneRun(&PicoCpu);
-  SekCycleCnt+=cyc_do-PicoCpu.cycles;
+  PicoCpuCM68k.cycles=cyc_do;
+  CycloneRun(&PicoCpuCM68k);
+  SekCycleCnt+=cyc_do-PicoCpuCM68k.cycles;
 #elif defined(EMU_M68K)
-  m68k_set_context(&PicoM68kCPU);
+  m68k_set_context(&PicoCpuMM68k);
   SekCycleCnt+=m68k_execute(cyc_do);
+#elif defined(EMU_F68K)
+  g_m68kcontext=&PicoCpuFM68k;
+  SekCycleCnt+=m68k_emulate(cyc_do);
 #endif
 }
 
@@ -104,12 +107,15 @@ static __inline void SekRunS68k(int cyc)
   SekCycleAimS68k+=cyc;
   if((cyc_do=SekCycleAimS68k-SekCycleCntS68k) < 0) return;
 #if defined(EMU_C68K)
-  PicoCpuS68k.cycles=cyc_do;
-  CycloneRun(&PicoCpuS68k);
-  SekCycleCntS68k+=cyc_do-PicoCpuS68k.cycles;
+  PicoCpuCS68k.cycles=cyc_do;
+  CycloneRun(&PicoCpuCS68k);
+  SekCycleCntS68k+=cyc_do-PicoCpuCS68k.cycles;
 #elif defined(EMU_M68K)
-  m68k_set_context(&PicoS68kCPU);
+  m68k_set_context(&PicoCpuMS68k);
   SekCycleCntS68k+=m68k_execute(cyc_do);
+#elif defined(EMU_F68K)
+  g_m68kcontext=&PicoCpuFS68k;
+  SekCycleCntS68k+=m68k_emulate(cyc_do);
 #endif
 }
 
@@ -122,7 +128,6 @@ void SekRunPS(int cyc_m68k, int cyc_s68k);
 static __inline void SekRunPS(int cyc_m68k, int cyc_s68k)
 {
   int cycn, cycn_s68k, cyc_do;
-  int ex;
   SekCycleAim+=cyc_m68k;
   SekCycleAimS68k+=cyc_s68k;
 
@@ -132,26 +137,31 @@ static __inline void SekRunPS(int cyc_m68k, int cyc_s68k)
   /* loop 488 downto 0 in steps of PS_STEP */
   for (cycn = (488<<16)-PS_STEP_M68K; cycn >= 0; cycn -= PS_STEP_M68K)
   {
-    ex = 0;
     cycn_s68k = (cycn + cycn/2 + cycn/8) >> 16;
     if ((cyc_do = SekCycleAim-SekCycleCnt-(cycn>>16)) > 0) {
 #if defined(EMU_C68K)
-      PicoCpu.cycles = cyc_do;
-      CycloneRun(&PicoCpu);
-      SekCycleCnt += cyc_do - PicoCpu.cycles;
+      PicoCpuCM68k.cycles = cyc_do;
+      CycloneRun(&PicoCpuCM68k);
+      SekCycleCnt += cyc_do - PicoCpuCM68k.cycles;
 #elif defined(EMU_M68K)
-      m68k_set_context(&PicoM68kCPU);
-      SekCycleCnt += (ex = m68k_execute(cyc_do));
+      m68k_set_context(&PicoCpuMM68k);
+      SekCycleCnt += m68k_execute(cyc_do);
+#elif defined(EMU_F68K)
+      g_m68kcontext = &PicoCpuFM68k;
+      SekCycleCnt += m68k_emulate(cyc_do);
 #endif
     }
     if ((cyc_do = SekCycleAimS68k-SekCycleCntS68k-cycn_s68k) > 0) {
 #if defined(EMU_C68K)
-      PicoCpuS68k.cycles = cyc_do;
-      CycloneRun(&PicoCpuS68k);
-      SekCycleCntS68k += cyc_do - PicoCpuS68k.cycles;
+      PicoCpuCS68k.cycles = cyc_do;
+      CycloneRun(&PicoCpuCS68k);
+      SekCycleCntS68k += cyc_do - PicoCpuCS68k.cycles;
 #elif defined(EMU_M68K)
-      m68k_set_context(&PicoS68kCPU);
-      SekCycleCntS68k += (ex = m68k_execute(cyc_do));
+      m68k_set_context(&PicoCpuMS68k);
+      SekCycleCntS68k += m68k_execute(cyc_do);
+#elif defined(EMU_F68K)
+      g_m68kcontext = &PicoCpuFS68k;
+      SekCycleCntS68k += m68k_emulate(cyc_do);
 #endif
     }
   }
index b1f554c..87e8554 100644 (file)
@@ -1,6 +1,6 @@
 @ vim:filetype=armasm
 
-@ SekRunPS runs PicoCpu and PicoCpuS68k interleaved in steps of PS_STEP_M68K
+@ SekRunPS runs PicoCpuCM68k and PicoCpuCS68k interleaved in steps of PS_STEP_M68K
 @ cycles. This is done without calling CycloneRun and jumping directly to
 @ Cyclone code to avoid pushing/popping all the registers every time.
 
@@ -13,8 +13,8 @@
 @ .extern is ignored by gas, we add these here just to see what we depend on.
 .extern CycloneJumpTab
 .extern CycloneDoInterrupt
-.extern PicoCpu
-.extern PicoCpuS68k
+.extern PicoCpuCM68k
+.extern PicoCpuCS68k
 .extern SekCycleAim
 .extern SekCycleCnt
 .extern SekCycleAimS68k
@@ -32,8 +32,8 @@ SekRunPS:
     sub     sp, sp, #2*4          @ sp[0] = main_cycle_cnt, sp[4] = run_cycle_cnt
 
     @ override CycloneEnd for both contexts
-    ldr     r7, =PicoCpu
-    ldr     lr, =PicoCpuS68k
+    ldr     r7, =PicoCpuCM68k
+    ldr     lr, =PicoCpuCS68k
     ldr     r2, =CycloneEnd_M68k
     ldr     r3, =CycloneEnd_S68k
     str     r2, [r7,#0x98]
@@ -90,7 +90,7 @@ schedule_s68k:
     subs    r5, r0, r3, asr #16
     ble     schedule_m68k             @ s68k has not enough cycles
 
-    ldr     r7, =PicoCpuS68k
+    ldr     r7, =PicoCpuCS68k
     str     r5, [sp,#4]               @ run_cycle_cnt
     b       CycloneRunLocal
 
@@ -122,15 +122,15 @@ schedule_m68k:
     subs    r5, r0, r3, asr #16
     ble     schedule_s68k             @ m68k has not enough cycles
 
-    ldr     r7, =PicoCpu
+    ldr     r7, =PicoCpuCM68k
     str     r5, [sp,#4]               @ run_cycle_cnt
     b       CycloneRunLocal
 
 
 
 SekRunPS_end:
-    ldr     r7, =PicoCpu
-    ldr     lr, =PicoCpuS68k
+    ldr     r7, =PicoCpuCM68k
+    ldr     lr, =PicoCpuCS68k
     mov     r0, #0
     str     r0, [r7,#0x98]            @ remove CycloneEnd handler
     str     r0, [lr,#0x98]
index 6295af5..6005f59 100644 (file)
@@ -7,16 +7,22 @@
 int SekCycleCntS68k=0; // cycles done in this frame
 int SekCycleAimS68k=0; // cycle aim
 
+
+/* context */
+// Cyclone 68000
 #ifdef EMU_C68K
-// ---------------------- Cyclone 68000 ----------------------
-struct Cyclone PicoCpuS68k;
+struct Cyclone PicoCpuCS68k;
 #endif
-
+// MUSASHI 68000
 #ifdef EMU_M68K
-// ---------------------- MUSASHI 68000 ----------------------
-m68ki_cpu_core PicoS68kCPU; // Mega CD's CPU
+m68ki_cpu_core PicoCpuMS68k;
+#endif
+// FAME 68000
+#ifdef EMU_F68K
+M68K_CONTEXT PicoCpuFS68k;
 #endif
 
+
 static int new_irq_level(int level)
 {
   int level_new = 0, irqs;
@@ -28,16 +34,6 @@ static int new_irq_level(int level)
   return level_new;
 }
 
-#ifdef EMU_M68K
-static int SekIntAckS68kM(int level)
-{
-  int level_new = new_irq_level(level);
-  dprintf("s68kACK %i -> %i", level, level_new);
-  CPU_INT_LEVEL = level_new << 8;
-  return M68K_INT_ACK_AUTOVECTOR;
-}
-#endif
-
 #ifdef EMU_C68K
 // interrupt acknowledgement
 static int SekIntAckS68k(int level)
@@ -45,7 +41,7 @@ static int SekIntAckS68k(int level)
   int level_new = new_irq_level(level);
 
   dprintf("s68kACK %i -> %i", level, level_new);
-  PicoCpuS68k.irq = level_new;
+  PicoCpuCS68k.irq = level_new;
   return CYCLONE_INT_ACK_AUTOVECTOR;
 }
 
@@ -58,36 +54,64 @@ static int SekUnrecognizedOpcodeS68k(void)
 {
   unsigned int pc, op;
   pc = SekPcS68k;
-  op = PicoCpuS68k.read16(pc);
+  op = PicoCpuCS68k.read16(pc);
   dprintf("Unrecognized Opcode %04x @ %06x", op, pc);
   //exit(1);
   return 0;
 }
 #endif
 
+#ifdef EMU_M68K
+static int SekIntAckMS68k(int level)
+{
+  int level_new = new_irq_level(level);
+  dprintf("s68kACK %i -> %i", level, level_new);
+  CPU_INT_LEVEL = level_new << 8;
+  return M68K_INT_ACK_AUTOVECTOR;
+}
+#endif
+
+#ifdef EMU_F68K
+static void SekIntAckFS68k(unsigned level)
+{
+  int level_new = new_irq_level(level);
+  dprintf("s68kACK %i -> %i", level, level_new);
+  PicoCpuFS68k.interrupts[0] = level_new;
+}
+#endif
 
 
 PICO_INTERNAL int SekInitS68k()
 {
 #ifdef EMU_C68K
 //  CycloneInit();
-  memset(&PicoCpuS68k,0,sizeof(PicoCpuS68k));
-  PicoCpuS68k.IrqCallback=SekIntAckS68k;
-  PicoCpuS68k.ResetCallback=SekResetAckS68k;
-  PicoCpuS68k.UnrecognizedCallback=SekUnrecognizedOpcodeS68k;
+  memset(&PicoCpuCS68k,0,sizeof(PicoCpuCS68k));
+  PicoCpuCS68k.IrqCallback=SekIntAckS68k;
+  PicoCpuCS68k.ResetCallback=SekResetAckS68k;
+  PicoCpuCS68k.UnrecognizedCallback=SekUnrecognizedOpcodeS68k;
 #endif
 #ifdef EMU_M68K
   {
     // Musashi is not very context friendly..
     void *oldcontext = m68ki_cpu_p;
-    m68k_set_context(&PicoS68kCPU);
+    m68k_set_context(&PicoCpuMS68k);
     m68k_set_cpu_type(M68K_CPU_TYPE_68000);
     m68k_init();
-    m68k_set_int_ack_callback(SekIntAckS68kM);
+    m68k_set_int_ack_callback(SekIntAckMS68k);
 //  m68k_pulse_reset(); // not yet, memmap is not set up
     m68k_set_context(oldcontext);
   }
 #endif
+#ifdef EMU_F68K
+  {
+    void *oldcontext = g_m68kcontext;
+    g_m68kcontext = &PicoCpuFS68k;
+    memset(&PicoCpuFS68k, 0, sizeof(PicoCpuFS68k));
+    m68k_init();
+    PicoCpuFS68k.iack_handler = SekIntAckFS68k;
+    g_m68kcontext = oldcontext;
+  }
+#endif
 
   return 0;
 }
@@ -98,26 +122,34 @@ PICO_INTERNAL int SekResetS68k()
   if (Pico.rom==NULL) return 1;
 
 #ifdef EMU_C68K
-  PicoCpuS68k.state_flags=0;
-  PicoCpuS68k.osp=0;
-  PicoCpuS68k.srh =0x27; // Supervisor mode
-  PicoCpuS68k.flags=4;   // Z set
-  PicoCpuS68k.irq=0;
-  PicoCpuS68k.a[7]=PicoCpuS68k.read32(0); // Stack Pointer
-  PicoCpuS68k.membase=0;
-  PicoCpuS68k.pc=PicoCpuS68k.checkpc(PicoCpuS68k.read32(4)); // Program Counter
+  PicoCpuCS68k.state_flags=0;
+  PicoCpuCS68k.osp=0;
+  PicoCpuCS68k.srh =0x27; // Supervisor mode
+  PicoCpuCS68k.flags=4;   // Z set
+  PicoCpuCS68k.irq=0;
+  PicoCpuCS68k.a[7]=PicoCpuCS68k.read32(0); // Stack Pointer
+  PicoCpuCS68k.membase=0;
+  PicoCpuCS68k.pc=PicoCpuCS68k.checkpc(PicoCpuCS68k.read32(4)); // Program Counter
 #endif
 #ifdef EMU_M68K
   {
     void *oldcontext = m68ki_cpu_p;
 
-    m68k_set_context(&PicoS68kCPU);
+    m68k_set_context(&PicoCpuMS68k);
     m68ki_cpu.sp[0]=0;
     m68k_set_irq(0);
     m68k_pulse_reset();
     m68k_set_context(oldcontext);
   }
 #endif
+#ifdef EMU_F68K
+  {
+    void *oldcontext = g_m68kcontext;
+    g_m68kcontext = &PicoCpuFS68k;
+    m68k_reset();
+    g_m68kcontext = oldcontext;
+  }
+#endif
 
   return 0;
 }
@@ -127,16 +159,19 @@ PICO_INTERNAL int SekInterruptS68k(int irq)
   int irqs, real_irq = 1;
   Pico_mcd->m.s68k_pend_ints |= 1 << irq;
   irqs = Pico_mcd->m.s68k_pend_ints >> 1;
-  while ((irqs >>= 1)) real_irq++; // this is probably only needed for Cyclone
+  while ((irqs >>= 1)) real_irq++;
 
 #ifdef EMU_C68K
-  PicoCpuS68k.irq=real_irq;
+  PicoCpuCS68k.irq=real_irq;
 #endif
 #ifdef EMU_M68K
   void *oldcontext = m68ki_cpu_p;
-  m68k_set_context(&PicoS68kCPU);
-  m68k_set_irq(real_irq); // raise irq (gets lowered after taken or must be done in ack)
+  m68k_set_context(&PicoCpuMS68k);
+  m68k_set_irq(real_irq);
   m68k_set_context(oldcontext);
+#endif
+#ifdef EMU_F68K
+  PicoCpuFS68k.interrupts[0]=real_irq;
 #endif
   return 0;
 }
diff --git a/cpu/a68k/Makefile.win b/cpu/a68k/Makefile.win
deleted file mode 100644 (file)
index 5777884..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-all : a68k.obj\r
-\r
-a68k.obj :\r
-       cl /DWIN32 /DFASTCALL make68kd.c\r
-       make68kd a68k.asm a68k_jmp.asm 00\r
-       nasm -f win32 a68k.asm\r
-\r
-\r
-clean : tidy\r
-       del a68k.obj\r
-\r
-tidy :\r
-       del a68k.asm\r
-       del a68k_jmp.asm\r
-       del make68kd.exe\r
-       del make68kd.obj\r
diff --git a/cpu/a68k/cpuintrf.h b/cpu/a68k/cpuintrf.h
deleted file mode 100644 (file)
index c38055f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-// dave filler file
\ No newline at end of file
diff --git a/cpu/a68k/make68kd.c b/cpu/a68k/make68kd.c
deleted file mode 100644 (file)
index 9f64748..0000000
+++ /dev/null
@@ -1,8192 +0,0 @@
-/*---------------------------------------------------------------\r
- * Motorola 68000 32 Bit emulator\r
- *\r
- * Copyright 1998-2001 Mike Coates,    All rights reserved\r
- *                                                     Darren Olafson\r
- *---------------------------------------------------------------\r
- *\r
- * Thanks to ...\r
- *\r
- * Neil Bradley         (lots of optimisation help & ideas)\r
- *\r
- *---------------------------------------------------------------\r
- * History (so we know what bugs have been fixed)\r
- *\r
- * 02.11.98 MJC        - CMPM bug, overwriting first value\r
- * 04.11.98 MJC        - Debug timing - same as C core\r
- *                                             save PC on calls to C memory routines\r
- * 05.11.98 NS  - Re-insert changes to make work on OS/2\r
- * 06.11.98 MJC        - Flags saved on ADDA commands\r
- *                                             X set on ADD commands\r
- * 23.11.98 MJC        - Alternate Memory Read/Write for non DOS ports\r
- * 24.11.98 CK  - Add WIN32 specific stuff\r
- * 25.11.98 DEO        - ABCD Size not initialised\r
- * 21.12.98 MJC        - Change register saving on Memory Banking\r
- * 13.01.99 M/D        - Change to new C core disassembler\r
- * 19.01.99 MJC        - Proper? support for new Interrupt System\r
- * 17.02.99 MJC        - TRACE68K define added\r
- *                ABCD,SBCD not keeping Z flag\r
- *                JMP, JSR for some EA combo's damaging flags\r
- *                DIVU - Overflow not being set correctly\r
- *                ASL/ASR - Flag Handling now correct\r
- *                some minor optimisations\r
- * 13.03.99 DEO        - Added new cycle timing\r
- * 24.03.99 MJC        - TRACE68K define removed\r
- *                NEW INTERRUPT SYSTEM only\r
- *                interrupt check sped up (when not taken)\r
- *                STOP checks for interrupt\r
- * 01.04.99 MJC        - OS2 specifics added\r
- *                MOVEM reference point moved\r
- *                Data and Address register mode combined for :-\r
- *                                             movecodes\r
- *                dumpx\r
- * 04.05.99 MJC        - Add Previous PC support to MOVE.B #X,XXXXXX.L (F1 Dream)\r
- *                ABCD/SBCD could corrupt zero flag\r
- *                DIVS/DIVU overflow should not update register\r
- * 22.05.99 MJC        - Complete support of Previous PC on C calls\r
- *                Some optional bits now selected by DEFINES\r
- * 27.05.99 MJC        - Interrupt system changed\r
- * 28.05.99 MJC        - Use DEFINES in more places\r
- *                Interrupt check running one opcode when taken\r
- * 16.07.99 MJC        - Reset - Preload next opcode / external call\r
- *                68010 commands almost complete\r
- *                more compression on jump table (16k smaller)\r
- *                Some optimising\r
- *                                               shl reg,1 -> add reg,reg\r
- *                  or ecx,ecx:jz -> jecxz\r
- * 22.08.99 DEO        - SBCD/ABCD sets N flag same as carry\r
- * 19.10.99 MJC        - Change DOS memory routines\r
- *                Change DOS Clobber flags (ESI no longer safe)\r
- *                Save EAX around memory write where needed\r
- *                bit commands optimised\r
- * 25.10.99  MJC  - Was keeping masked register on read/write\r
- *                if register was preserved over call\r
- *                ESI assumed 'safe' again\r
- * 25.10.99  MJC  - Bank ID moved to CPU context\r
- * 03.11.99 KENJO - VC++6.0 seems not to preserve EDI. Fixed "ABCD -(A0), -(A0)" crash / "roxr (A0)"-type shift crash\r
- * 13.11.99 KENJO - Fixed "NABC"\r
- *                Now Win32 uses FASTCALL type call for interrupt callback\r
- * 09.02.00  MJC  - Check CPU type before allowing 68010/68020 instructions\r
- *                remove routines for 5 non existant opcodes\r
- * 05.03.00  MJC  - not command decrement A7 by 1 for bytes\r
- * 10.03.00  MJC  - as did btst,cmpm and nbcd\r
- * 22.03.00  MJC  - Divide by zero should not decrement PC by 2 before push\r
- *                Move memory banking into exception routine\r
- * 14.04.00 Dave  - BTST missing Opcode\r
- *                ASL.L > 31 shift\r
- * 20.04.00  MJC  - TST.B Also missing A7 specific routine\r
- *                - Extra Define A7ROUTINE to switch between having seperate\r
- *                routines for +-(A7) address modes.\r
- * 24.06.00  MJC  - ADDX/SUBX +-(A7) routines added.\r
- *                TAS should not touch X flag\r
- *                LSL/LSR EA not clearing V flag\r
- *                CHK not all opcodes in jump table\r
- *                Add define to mask status register\r
- * 04.07.00  MJC  - Keep high byte of Program Counter on Bxx and Jxx\r
- *                Fix flag handling on NEGX\r
- *                Really fix ADDX/SUBX +-(A7)\r
- *                PC could be set wrong after CHK.W instruction\r
- *                DIVS/DIVU always clear C flag\r
- *                ABCD/SBCD missing +-(A7) Routine\r
- *                TAS missing +-(A7) Routine\r
- *                Bitwise Static missing +-(A7) Routine\r
- *                CMPM missing +-(A7) Routine\r
- * 30.09.00 DEO        - added mull, divl, bfextu\r
- *                added '020 addressing modes\r
- *                fixed $6xff branching\r
- * 23.01.01 MJC        - Spits out seperate code for 68000 & 68020\r
- *                allows seperate optimising!\r
- * 17.02.01 MJC        - Support for encrypted PC relative fetch calls\r
- * 11.03.01 GUTI  - change some cmp reg,0 and or reg,reg with test\r
- * 13.03.01 MJC        - Single Icount for Asm & C cores\r
- * 16.05.01 ASG        - use push/pop around mem calls instead of store to safe_REG\r
- *                optimized a bit the 020 extension word decoder\r
- *                removed lots of unnecessary code in branches\r
- *---------------------------------------------------------------\r
- * Known Problems / Bugs\r
- *\r
- * 68000\r
- * None - Let us know if you find any!\r
- *\r
- * 68010\r
- * Instructions that are supervisor only as per 68000 spec.\r
- * move address space not implemented.\r
- *\r
- * 68020\r
- * only long Bcc instruction implemented.\r
- *---------------------------------------------------------------\r
- * Notes\r
- *\r
- * STALLCHECK should be defined for Pentium Class\r
- *                                                      undefined for P2/Celerons\r
- *\r
- * ALIGNMENT is normally 4, but seems faster on my P2 as 0 !\r
- *\r
- *---------------------------------------------------------------\r
- *\r
- * Future Changes\r
- *\r
- * 68020 instructions to be completed\r
- * assembler memory routines                                                                                           +\r
- *\r
- * and anything else that takes our fancy!\r
- *---------------------------------------------------------------*/\r
-\r
-/* Specials - Switch what program allows/disallows */\r
-\r
-#undef  STALLCHECK             /* Affects fetching of Opcode */\r
-#undef  SAVEPPC     /* Save Previous PC */ // dave \r
-#define ENCRYPTED              /* PC relative = decrypted */\r
-#define ASMBANK     /* Memory banking algorithm to use */ // dave\r
-#define A7ROUTINE              /* Define to use separate routines for -(a7)/(a7)+ */\r
-#define ALIGNMENT 4            /* Alignment to use for branches */\r
-#undef  MASKCCR                        /* Mask the status register to filter out unused bits */\r
-#define KEEPHIGHPC             /* Keep or Ignore bits 24-31 */\r
-#define QUICKZERO              /* selects XOR r,r or MOV r,0 */\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include <assert.h>\r
-\r
-/* New Disassembler */\r
-\r
-char * codebuf;\r
-int            DisOp;\r
-\r
-#define cpu_readmem24bew(addr)                 (0)\r
-#define cpu_readmem24bew_word(addr)            (DisOp)\r
-\r
-#define MEMORY_H       /* so memory.h will not be included... */\r
-/*\r
-#include "d68k.c"\r
-*/\r
-#undef MEMORY_H\r
-\r
-#undef cpu_readmem24bew\r
-#undef cpu_readmem24bew_word\r
-\r
-#include "cpuintrf.h"\r
-\r
-/*\r
- * Defines used by Program\r
- *\r
- */\r
-\r
-#define VERSION         "0.30"\r
-\r
-#define TRUE -1\r
-#define FALSE 0\r
-\r
-#define EAX 0\r
-#define EBX 1\r
-#define ECX 2\r
-#define EDX 3\r
-#define ESI 4\r
-#define PC  ESI\r
-#define EDI 5\r
-#define EBP 6\r
-\r
-\r
-#define NORMAL 0\r
-#define PCREL  1\r
-\r
-/* Register Location Offsets */\r
-\r
-#define ICOUNT                         "_m68k_ICount"\r
-\r
-#define REG_DAT                                "R_D0"\r
-#define REG_DAT_EBX                    "[R_D0+ebx*4]"\r
-#define REG_ADD                                "R_A0"\r
-#define REG_A7                         "R_A7"\r
-#define REG_USP                                "R_USP"\r
-#define REG_ISP                                "R_ISP"\r
-#define REG_SRH                                "R_SR_H"\r
-#define REG_CCR                                "R_CCR"\r
-#define REG_X                          "R_XC"\r
-#define REG_PC                         "R_PC"\r
-#define REG_IRQ                                "R_IRQ"\r
-#define REG_S                          "R_SR"\r
-#define REG_IRQ_CALLBACK       "R_IRQ_CALLBACK"\r
-#define REG_RESET_CALLBACK     "R_RESET_CALLBACK"\r
-\r
-\r
-/* 68010 Regs */\r
-\r
-#define REG_VBR                                "R_VBR"\r
-#define REG_SFC                                "R_SFC"\r
-#define REG_DFC                                "R_DFC"\r
-\r
-#define FASTCALL_FIRST_REG     "ecx"\r
-#define FASTCALL_SECOND_REG    "edx"\r
-\r
-\r
-\r
-/*\r
- * Global Variables\r
- *\r
- */\r
-\r
-FILE *fp                       = NULL;\r
-\r
-char *comptab          = NULL;\r
-char *CPUtype          = NULL;\r
-\r
-int  CPU                       = 0;\r
-int  FlagProcess       = 0;\r
-int  CheckInterrupt = 0;\r
-int  ExternalIO                = 0;\r
-int  Opcount           = 0;\r
-int  TimingCycles      = 0;\r
-int  AddEACycles       = 0;\r
-int  AccessType                = NORMAL;\r
-int  ppro                      = 0;\r
-\r
-\r
-\r
-/* External register preservation */\r
-\r
-#ifdef DOS\r
-\r
-/* Registers normally saved around C routines anyway */\r
-/* GCC 2.9.1 (dos) seems to preserve EBX,EDI and EBP */\r
-static char SavedRegs[] = "-B--SDB";\r
-\r
-#elif defined(WIN32)\r
-\r
-/* visual C++, win32, says it preserves ebx, edi, esi, and ebp */\r
-/* ---------- VC++ deosn't preserve EDI? (Kenjo, 110399) ---------- */\r
-static char SavedRegs[] = "-B--S-B";\r
-\r
-#else\r
-\r
-/* Assume nothing preserved */\r
-static char SavedRegs[] = "-------";\r
-\r
-#endif\r
-\r
-\r
-\r
-/* Jump Table */\r
-\r
-int OpcodeArray[65536];\r
-\r
-/* Lookup Arrays */\r
-\r
-static char* regnameslong[] =\r
-{ "EAX","EBX","ECX","EDX","ESI","EDI","EBP"};\r
-\r
-static char* regnamesword[] =\r
-{ "AX","BX","CX","DX", "SI", "DI", "BP"};\r
-\r
-static char* regnamesshort[] =\r
-{ "AL","BL","CL","DL"};\r
-\r
-\r
-\r
-/*********************************/\r
-/* Conversion / Utility Routines */\r
-/*********************************/\r
-\r
-/* Convert EA to Address Mode Number\r
- *\r
- * 0   Dn\r
- * 1   An\r
- * 2   (An)\r
- * 3   (An)+\r
- * 4   -(An)\r
- * 5   x(An)\r
- * 6   x(An,xr.s)\r
- * 7   x.w\r
- * 8   x.l\r
- * 9   x(PC)\r
- * 10  x(PC,xr.s)\r
- * 11  #x,SR,CCR               Read = Immediate, Write = SR or CCR\r
- *                                                      in order to read SR to AX, use READCCR\r
- * 12-15  INVALID\r
- *\r
- * 19  (A7)+\r
- * 20  -(A7)\r
- *\r
- */\r
-\r
-int EAtoAMN(int EA, int Way)\r
-{\r
-       int Work;\r
-\r
-       if (Way)\r
-       {\r
-               Work = (EA & 0x7);\r
-\r
-               if (Work == 7) Work += ((EA & 0x38) >> 3);\r
-\r
-               if (((Work == 3) || (Work == 4)) && (((EA & 0x38) >> 3) == 7))\r
-               {\r
-                       Work += 16;\r
-               }\r
-       }\r
-       else\r
-       {\r
-               Work = (EA & 0x38) >> 3;\r
-\r
-               if (Work == 7) Work += (EA & 7);\r
-\r
-               if (((Work == 3) || (Work == 4)) && ((EA & 7) == 7))\r
-               {\r
-                       Work += 16;\r
-               }\r
-       }\r
-\r
-       return Work;\r
-}\r
-\r
-/*\r
- * Generate Main or Sub label\r
- */\r
-\r
-char *GenerateLabel(int ID,int Type)\r
-{\r
-       static int LabID,LabNum;\r
-/*\r
-       static char disasm[80];\r
-       char    *dis = disasm;\r
-*/\r
-       if (Type == 0)\r
-       {\r
-               CheckInterrupt=0;                        /* No need to check for Interrupts */\r
-               ExternalIO=0;                             /* Not left Assembler Yet */\r
-               TimingCycles=0;                         /* No timing info for this command */\r
-               AddEACycles=1;                           /* default to add in EA timing */\r
-               Opcount++;                                        /* for screen display */\r
-\r
-               DisOp = ID;\r
-/*\r
-               m68k_disassemble(dis,0);\r
-               sprintf(codebuf, "OP%d_%4.4x:\t\t\t\t; %s", CPU,ID, dis);\r
-*/\r
-               sprintf(codebuf, "OP%d_%4.4x:\t\t\t\t;", CPU,ID);\r
-\r
-               LabID  = ID;\r
-               LabNum = 0;\r
-       }\r
-       else\r
-       {\r
-               LabNum++;\r
-               sprintf(codebuf, "OP%d_%4.4x_%1x", CPU,LabID, LabNum);\r
-       }\r
-\r
-       return codebuf;\r
-}\r
-\r
-/*\r
- * Generate Alignment Line\r
- */\r
-\r
-void Align(void)\r
-{\r
-       fprintf(fp, "\t\t ALIGN %d\n\n",ALIGNMENT);\r
-}\r
-\r
-/*\r
- * Copy X into Carry\r
- *\r
- * There are several ways this could be done, this allows\r
- * us to easily change the way we are doing it!\r
- */\r
-\r
-void CopyX(void)\r
-{\r
-       /* Copy bit 0 from X flag store into Carry */\r
-\r
-       fprintf(fp, "\t\t bt    dword [%s],0\n",REG_X);\r
-}\r
-\r
-/*\r
- * Immediate 3 bit data\r
- *\r
- * 0=8, anything else is itself\r
- *\r
- * Again, several ways to achieve this\r
- *\r
- * ECX contains data as 3 lowest bits\r
- *\r
- */\r
-\r
-void ClearRegister(int regno)\r
-{\r
-#ifdef QUICKZERO\r
-       fprintf(fp, "\t\t mov   %s,0\n",regnameslong[regno]);\r
-#else\r
-       fprintf(fp, "\t\t xor   %s,%s\n",regnameslong[regno],regnameslong[regno]);\r
-#endif\r
-}\r
-\r
-void Immediate8(void)\r
-{\r
-       /* This takes 3 cycles, 5 bytes, no memory reads */\r
-\r
-       fprintf(fp, "\t\t dec   ecx          ; Move range down\n");\r
-       fprintf(fp, "\t\t and   ecx,byte 7   ; Mask out lower bits\n");\r
-       fprintf(fp, "\t\t inc   ecx          ; correct range\n");\r
-\r
-\r
-       /* This takes 2 cycles, 10 bytes but has a memory read */\r
-       /* I don't know timing for the mov command - assumed 1 */\r
-\r
-#if 0\r
-       fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-       fprintf(fp, "\t\t mov   ecx,[ImmTable+ECX*4]\n");\r
-#endif\r
-}\r
-\r
-/*\r
- * This will check for bank changes before\r
- * resorting to calling the C bank select code\r
- *\r
- * Most of the time it does not change!\r
- *\r
- */\r
-\r
-/* forward used by MemoryBanking */\r
-void Exception(int Number, int BaseCode) ;\r
-\r
-void MemoryBanking(int BaseCode)\r
-{\r
-       /* check for odd address */\r
-       fprintf(fp, "\t\t test  esi, dword 1\n");\r
-       fprintf(fp, "\t\t jz    near OP%d_%5.5x\n",CPU,BaseCode);\r
-\r
-       /* trying to run at an odd address */\r
-       Exception(3,BaseCode);\r
-\r
-       /* Keep Whole PC */\r
-\r
-       fprintf(fp, "OP%d_%5.5x:\n",CPU,BaseCode);\r
-\r
-/* ASG - always call to the changepc subroutine now, since the number of */\r
-/* bits varies based on the memory model */\r
-#ifdef KEEPHIGHPC\r
-       fprintf(fp, "\t\t mov   [FullPC],ESI\n");\r
-#endif\r
-\r
-       /* Mask to n bits */\r
-       fprintf(fp, "\t\t and   esi,[_mem_amask]\n");\r
-\r
-#if 0\r
-#ifdef KEEPHIGHPC\r
-       fprintf(fp, "\t\t mov   [FullPC],ESI\n");\r
-#endif\r
-\r
-       /* Mask to 24 bits */\r
-//     fprintf(fp, "\t\t and   esi,0ffffffh\n");\r
-\r
-#ifdef ASMBANK\r
-       /* Assembler bank switch - 64k granularity */\r
-\r
-       fprintf(fp, "\t\t mov   eax,esi\n");\r
-       fprintf(fp, "\t\t shr   eax,16\n");\r
-       fprintf(fp, "\t\t cmp   [asmbank],eax\n");\r
-       fprintf(fp, "\t\t je    OP%d_%5.5x_Bank\n",CPU,BaseCode);\r
-\r
-       fprintf(fp, "\t\t mov   [asmbank],eax\n");\r
-#else\r
-       /* This code is same as macro used by C core */\r
-\r
-       fprintf(fp, "\t\t mov   ecx,esi\n");\r
-       fprintf(fp, "\t\t mov   ebx,[_cur_mrhard]\n");\r
-       fprintf(fp, "\t\t shr   ecx,9\n");\r
-       fprintf(fp, "\t\t mov   al,byte [_opcode_entry]\n");\r
-       fprintf(fp, "\t\t cmp   al,[ecx+ebx]\n");\r
-       fprintf(fp, "\t\t je    OP%d_%5.5x_Bank\n",CPU,BaseCode);\r
-#endif\r
-#endif\r
-\r
-       /* Call Banking Routine */\r
-\r
-       if (SavedRegs[ESI] == '-')\r
-       {\r
-               fprintf(fp, "\t\t mov   [%s],ESI\n",REG_PC);\r
-       }\r
-\r
-       if (SavedRegs[EDX] == '-')\r
-       {\r
-               fprintf(fp, "\t\t mov   [%s],edx\n",REG_CCR);\r
-       }\r
-\r
-#ifdef FASTCALL\r
-       fprintf(fp, "\t\t mov   %s,esi\n",FASTCALL_FIRST_REG);\r
-#else\r
-       fprintf(fp, "\t\t push  esi\n");\r
-#endif\r
-\r
-       fprintf(fp, "\t\t call  [_a68k_memory_intf+28]\n");\r
-\r
-#ifndef FASTCALL\r
-       fprintf(fp, "\t\t lea   esp,[esp+4]\n");\r
-#endif\r
-\r
-       if (SavedRegs[EDX] == '-')\r
-       {\r
-               fprintf(fp, "\t\t mov   edx,[%s]\n",REG_CCR);\r
-       }\r
-\r
-       if (SavedRegs[ESI] == '-')\r
-       {\r
-               fprintf(fp, "\t\t mov   esi,[%s]\n",REG_PC);\r
-       }\r
-\r
-       /* Update our copy */\r
-\r
-       fprintf(fp, "\t\t mov   ebp,dword [_OP_ROM]\n");\r
-\r
-       fprintf(fp, "OP%d_%5.5x_Bank:\n",CPU,BaseCode);\r
-}\r
-\r
-/*\r
- * Update Previous PC value\r
- *\r
- */\r
-\r
-void SavePreviousPC(void)\r
-{\r
-#ifdef SAVEPPC\r
-       fprintf(fp, "\t\t mov   [R_PPC],esi\t\t\t ; Keep Previous PC\n");\r
-#endif\r
-}\r
-\r
-/*\r
- * Complete Opcode handling\r
- *\r
- * Any tidying up, end code\r
- *\r
- */\r
-\r
-void Completed(void)\r
-{\r
-\r
-       /* Flag Processing to be finished off ? */\r
-\r
-       AccessType = NORMAL;\r
-\r
-       /* Use assembler timing routines */\r
-\r
-       if (TimingCycles != 0)\r
-       {\r
-               if (TimingCycles > 127)\r
-                       fprintf(fp, "\t\t sub   dword [%s],%d\n",ICOUNT,TimingCycles);\r
-               else\r
-               {\r
-                       if (TimingCycles != -1)\r
-                               fprintf(fp, "\t\t sub   dword [%s],byte %d\n",ICOUNT,TimingCycles);\r
-               }\r
-               \r
-               if (FlagProcess > 0)\r
-                       fprintf(fp, "\t\t pop   EDX\n");\r
-               if (FlagProcess == 2)\r
-                       fprintf(fp, "\t\t mov   [%s],edx\n",REG_X);\r
-\r
-               fprintf(fp, "\t\t js    near MainExit\n\n");\r
-       }\r
-       else\r
-       {\r
-               fprintf(fp, "\t\t test  dword [%s],0xffffffff\n",ICOUNT);\r
-               \r
-               if (FlagProcess > 0)\r
-                       fprintf(fp, "\t\t pop   EDX\n");\r
-               if (FlagProcess == 2)\r
-                       fprintf(fp, "\t\t mov   [%s],edx\n",REG_X);\r
-\r
-               fprintf(fp, "\t\t jle   near MainExit\n\n");\r
-       }\r
-       FlagProcess = 0;\r
-\r
-#ifdef MAME_DEBUG\r
-\r
-       /* Check for Debug Active */\r
-\r
-       fprintf(fp, "\n\t\t test    byte [_mame_debug],byte 0xff\n");\r
-       fprintf(fp, "\t\t jnz   near MainExit\n\n");\r
-\r
-#endif\r
-\r
-       if (CheckInterrupt)\r
-       {\r
-               fprintf(fp,"; Check for Interrupt waiting\n\n");\r
-               fprintf(fp,"\t\t test  byte [%s],07H\n",REG_IRQ);\r
-               fprintf(fp,"\t\t jne   near interrupt\n\n");\r
-       }\r
-\r
-       if(CPU==2)\r
-       {\r
-               /* 32 bit memory version */\r
-                 fprintf(fp, "\t\t mov   eax,2\n");    /* ASG */\r
-               fprintf(fp, "\t\t xor   eax,esi\n");    /* ASG */\r
-\r
-#ifdef STALLCHECK\r
-         ClearRegister(ECX);\r
-               fprintf(fp, "\t\t mov   cx,[eax+ebp]\n");\r
-#else\r
-               fprintf(fp, "\t\t movzx ecx,word [eax+ebp]\n");\r
-#endif\r
-       }\r
-       else\r
-       {\r
-               /* 16 bit memory */\r
-#ifdef STALLCHECK\r
-         ClearRegister(ECX);\r
-               fprintf(fp, "\t\t mov   cx,[esi+ebp]\n");\r
-#else\r
-               fprintf(fp, "\t\t movzx ecx,word [esi+ebp]\n");\r
-#endif\r
-       }\r
-\r
-       fprintf(fp, "\t\t jmp   [%s_OPCODETABLE+ecx*4]\n\n", CPUtype);\r
-}\r
-\r
-/*\r
- * Flag Routines\r
- *\r
- * Size          = B,W or L\r
- * Sreg          = Register to Test\r
- * TestReg  = Need to test register (false if flags already set up)\r
- * SetX          = if C needs to be copied across to X register\r
- * Delayed  = Delays final processing to end of routine (Completed())\r
- *\r
- */\r
-\r
-void TestFlags(char Size,int Sreg)\r
-{\r
-       char* Regname="";\r
-\r
-       switch (Size)\r
-       {\r
-               case 66:\r
-                       Regname = regnamesshort[Sreg];\r
-                       break;\r
-\r
-               case 87:\r
-                       Regname = regnamesword[Sreg];\r
-                       break;\r
-\r
-               case 76:\r
-                       Regname = regnameslong[Sreg];\r
-                       break;\r
-       }\r
-\r
-       /* Test does not update register         */\r
-       /* so cannot generate partial stall */\r
-\r
-       fprintf(fp, "\t\t test  %s,%s\n",Regname,Regname);\r
-}\r
-\r
-void SetFlags(char Size,int Sreg,int Testreg,int SetX,int Delayed)\r
-{\r
-       if (Testreg) TestFlags(Size,Sreg);\r
-\r
-       fprintf(fp, "\t\t pushfd\n");\r
-\r
-       if (Delayed)\r
-       {\r
-               /* Rest of code done by Completed routine */\r
-\r
-               if (SetX) FlagProcess = 2;\r
-               else FlagProcess = 1;\r
-       }\r
-       else\r
-       {\r
-               fprintf(fp, "\t\t pop   EDX\n");\r
-\r
-               if (SetX) fprintf(fp, "\t\t mov   [%s],edx\n",REG_X);\r
-       }\r
-}\r
-\r
-/******************/\r
-/* Check CPU Type */\r
-/******************/\r
-\r
-void CheckCPUtype(int Minimum)\r
-{\r
-       if(CPU==2)\r
-       {\r
-               /* Only check for > 020 */\r
-\r
-               if(Minimum>2)\r
-               {\r
-                       fprintf(fp, "\t\t mov   eax,[CPUversion]\n");\r
-\r
-                       fprintf(fp, "\t\t cmp   al,%d\n",Minimum);\r
-                       fprintf(fp, "\t\t jb    near ILLEGAL\n\n");\r
-               }\r
-       }\r
-       else\r
-       {\r
-               fprintf(fp, "\t\t mov   eax,[CPUversion]\n");\r
-\r
-               if (Minimum == 1)\r
-               {\r
-                       fprintf(fp, "\t\t test  eax,eax\n");\r
-                       fprintf(fp, "\t\t jz    near ILLEGAL\n\n");\r
-               }\r
-               else\r
-               {\r
-                       fprintf(fp, "\t\t cmp   al,%d\n",Minimum);\r
-                       fprintf(fp, "\t\t jb    near ILLEGAL\n\n");\r
-               }\r
-       }\r
-}\r
-\r
-/************************************/\r
-/* Pre-increment and Post-Decrement */\r
-/************************************/\r
-\r
-void IncrementEDI(int Size,int Rreg)\r
-{\r
-       switch (Size)\r
-       {\r
-               case 66:\r
-\r
-#ifdef  A7ROUTINE\r
-\r
-                       /* Always does Byte Increment - A7 uses special routine */\r
-\r
-                       fprintf(fp, "\t\t inc   dword [%s+%s*4]\n",REG_ADD,regnameslong[Rreg]);\r
-\r
-#else\r
-\r
-                       /* A7 uses same routines, so inc by 2 if A7 */\r
-\r
-                       fprintf(fp, "\t\t cmp   %s,7\n",regnamesshort[Rreg]);\r
-                       fprintf(fp, "\t\t cmc\n");\r
-                       fprintf(fp, "\t\t adc   dword [%s+%s*4],byte 1\n",REG_ADD,regnameslong[Rreg]);\r
-\r
-#endif\r
-                       break;\r
-\r
-               case 87:\r
-\r
-                       fprintf(fp, "\t\t add   dword [%s+%s*4],byte 2\n",REG_ADD,regnameslong[Rreg]);\r
-                       break;\r
-\r
-               case 76:\r
-\r
-                       fprintf(fp, "\t\t add   dword [%s+%s*4],byte 4\n",REG_ADD,regnameslong[Rreg]);\r
-                       break;\r
-       }\r
-}\r
-\r
-void DecrementEDI(int Size,int Rreg)\r
-{\r
-       switch (Size)\r
-       {\r
-               case 66:\r
-\r
-#ifdef  A7ROUTINE\r
-\r
-                       /* Always does Byte Increment - A7 uses special routine */\r
-\r
-                       fprintf(fp, "\t\t dec   EDI\n");\r
-\r
-#else\r
-\r
-                       /* A7 uses same routines, so dec by 2 if A7 */\r
-\r
-                       fprintf(fp, "\t\t cmp   %s,7\n",regnamesshort[Rreg]);\r
-                       fprintf(fp, "\t\t cmc\n");\r
-                       fprintf(fp, "\t\t sbb   dword edi,byte 1\n");\r
-\r
-#endif\r
-                       break;\r
-\r
-               case 87:\r
-\r
-                       fprintf(fp, "\t\t sub   EDI,byte 2\n");\r
-                       break;\r
-\r
-               case 76:\r
-                       fprintf(fp, "\t\t sub   EDI,byte 4\n");\r
-                       break;\r
-       }\r
-}\r
-\r
-/*\r
- * Generate an exception\r
- *\r
- * if Number = -1 then assume value in AL already\r
- *                                      code must continue running afterwards\r
- *\r
- */\r
-\r
-void Exception(int Number, int BaseCode)\r
-{\r
-       if (Number > -1)\r
-       {\r
-               fprintf(fp, "\t\t sub   esi,byte 2\n");\r
-               fprintf(fp, "\t\t mov   al,%d\n",Number);\r
-       }\r
-\r
-       fprintf(fp, "\t\t call  Exception\n\n");\r
-\r
-       if (Number > -1)\r
-               Completed();\r
-}\r
-\r
-\r
-/********************/\r
-/* Address Routines */\r
-/********************/\r
-\r
-/*\r
- * Decode Intel flags into AX as SR register\r
- *\r
- * Wreg = spare register to use (must not be EAX or EDX)\r
- */\r
-\r
-void ReadCCR(char Size, int Wreg)\r
-{\r
-       fprintf(fp, "\t\t mov   eax,edx\n");\r
-       fprintf(fp, "\t\t mov   ah,byte [%s]\n",REG_X);\r
-\r
-       /* Partial stall so .. switch to new bit of processing */\r
-\r
-       fprintf(fp, "\t\t mov   %s,edx\n",regnameslong[Wreg]);\r
-       fprintf(fp, "\t\t and   %s,byte 1\n",regnameslong[Wreg]);\r
-\r
-       /* Finish what we started */\r
-\r
-       fprintf(fp, "\t\t shr   eax,4\n");\r
-       fprintf(fp, "\t\t and   eax,byte 01Ch \t\t; X, N & Z\n\n");\r
-\r
-       /* and complete second task */\r
-\r
-       fprintf(fp, "\t\t or    eax,%s \t\t\t\t; C\n\n",regnameslong[Wreg]);\r
-\r
-       /* and Finally */\r
-\r
-       fprintf(fp, "\t\t mov   %s,edx\n",regnameslong[Wreg]);\r
-       fprintf(fp, "\t\t shr   %s,10\n",regnameslong[Wreg]);\r
-       fprintf(fp, "\t\t and   %s,byte 2\n",regnameslong[Wreg]);\r
-       fprintf(fp, "\t\t or    eax,%s\t\t\t\t; O\n\n",regnameslong[Wreg]);\r
-\r
-       if (Size == 'W')\r
-       {\r
-               fprintf(fp, "\t\t mov   ah,byte [%s] \t; T, S & I\n\n",REG_SRH);\r
-\r
-#ifdef MASKCCR\r
-               fprintf(fp, "\t\t and   ax,0A71Fh\t; Mask unused bits\n");\r
-#endif\r
-       }\r
-}\r
-\r
-/*\r
- * Convert SR into Intel flags\r
- *\r
- * Also handles change of mode from Supervisor to User\r
- *\r
- * n.b. This is also called by EffectiveAddressWrite\r
- */\r
-\r
-void WriteCCR(char Size)\r
-{\r
-       if (Size == 'W')\r
-       {\r
-               /* Did we change from Supervisor to User mode ? */\r
-\r
-               char *Label = GenerateLabel(0,1);\r
-\r
-               fprintf(fp, "\t\t test  ah,20h \t\t\t; User Mode ?\n");\r
-               fprintf(fp, "\t\t jne   short %s\n\n",Label);\r
-\r
-               /* Mode Switch - Update A7 */\r
-\r
-               fprintf(fp, "\t\t mov   edx,[%s]\n",REG_A7);\r
-               fprintf(fp, "\t\t mov   [%s],edx\n",REG_ISP);\r
-               fprintf(fp, "\t\t mov   edx,[%s]\n",REG_USP);\r
-               fprintf(fp, "\t\t mov   [%s],edx\n",REG_A7);\r
-\r
-               fprintf(fp, "%s:\n",Label);\r
-               fprintf(fp, "\t\t mov   byte [%s],ah \t;T, S & I\n",REG_SRH);\r
-\r
-               /* Mask may now allow Interrupt */\r
-\r
-               CheckInterrupt += 1;\r
-       }\r
-\r
-       /* Flags */\r
-\r
-       fprintf(fp, "\t\t and   eax,byte 1Fh\n");\r
-       fprintf(fp, "\t\t mov   edx,[IntelFlag+eax*4]\n");\r
-       fprintf(fp, "\t\t mov   [%s],dh\n",REG_X);\r
-       fprintf(fp, "\t\t and   edx,0EFFh\n");\r
-}\r
-\r
-\r
-/*\r
- * Interface to Mame memory commands\r
- *\r
- * Flags = "ABCDSDB" - set to '-' if not required to preserve\r
- *                     (order EAX,EBX,ECX,EDX,ESI,EDI,EBP)\r
- *\r
- * AReg        = Register containing Address\r
- *\r
- * Mask        0 : No Masking\r
- *               1 : Mask top byte, but preserve register\r
- *               2 : Mask top byte, preserve masked register\r
- */\r
-\r
-void Memory_Read(char Size,int AReg,char *Flags,int Mask)\r
-{\r
-       ExternalIO = 1;\r
-\r
-       /* Save PC */\r
-\r
-       fprintf(fp, "\t\t mov   [%s],ESI\n",REG_PC);\r
-\r
-       /* Check for special mask condition */\r
-\r
-       /* ASG - no longer need to mask addresses here */\r
-/*     if (Mask == 2)\r
-               fprintf(fp, "\t\t and   %s,0FFFFFFh\n",regnameslong[AReg]);*/\r
-\r
-       /* Check to see if registers need saving */\r
-\r
-       if ((Flags[EDX] != '-') && (SavedRegs[EDX] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t mov   [%s],edx\n",REG_CCR);\r
-       }\r
-\r
-       if ((Flags[EBX] != '-') && (SavedRegs[EBX] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t push  EBX\n");\r
-       }\r
-\r
-       if ((Flags[ECX] != '-') && (SavedRegs[ECX] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t push  ECX\n");\r
-       }\r
-\r
-       if ((Flags[EDI] != '-') && (SavedRegs[EDI] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t push  EDI\n");\r
-       }\r
-\r
-       /* Sort Address out */\r
-\r
-#ifdef FASTCALL\r
-\r
-       fprintf(fp, "\t\t mov   %s,%s\n",FASTCALL_FIRST_REG,regnameslong[AReg]);\r
-\r
-       /* ASG - no longer need to mask addresses here */\r
-/*     if (Mask == 1)\r
-               fprintf(fp, "\t\t and   %s,0FFFFFFh\n",FASTCALL_FIRST_REG);*/\r
-\r
-#else\r
-\r
-       if (Mask == 1)\r
-       {\r
-               if ((Flags[AReg] != '-') && (SavedRegs[AReg] != '-'))\r
-               {\r
-                       /* Don't trash a wanted safe register */\r
-\r
-                       fprintf(fp, "\t\t mov   EAX,%s\n",regnameslong[AReg]);\r
-       /* ASG - no longer need to mask addresses here */\r
-/*                     fprintf(fp, "\t\t and   EAX,0FFFFFFh\n");*/\r
-                       fprintf(fp, "\t\t push  EAX\n");\r
-               }\r
-               else\r
-               {\r
-       /* ASG - no longer need to mask addresses here */\r
-/*                     fprintf(fp, "\t\t and   %s,0FFFFFFh\n",regnameslong[AReg]);*/\r
-                       fprintf(fp, "\t\t push  %s\n",regnameslong[AReg]);\r
-               }\r
-       }\r
-       else\r
-               fprintf(fp, "\t\t push  %s\n",regnameslong[AReg]);\r
-\r
-#endif\r
-\r
-\r
-\r
-       /* Call Mame memory routine */\r
-\r
-       /* ASG - changed these to call through the function pointers */\r
-\r
-#ifdef ENCRYPTED\r
-       switch (AccessType)\r
-       {\r
-                 case NORMAL :\r
-                        switch (Size)\r
-                        {\r
-                                case 66 :\r
-                                       fprintf(fp, "\t\t call  [_a68k_memory_intf+4]\n");\r
-                                       break;\r
-\r
-                                case 87 :\r
-                                       fprintf(fp, "\t\t call  [_a68k_memory_intf+8]\n");\r
-                                       break;\r
-\r
-                                case 76 :\r
-                                       fprintf(fp, "\t\t call  [_a68k_memory_intf+12]\n");\r
-                                       break;\r
-                        }\r
-                        break;\r
-\r
-               case PCREL :\r
-\r
-                        switch (Size)\r
-                        {\r
-                                case 66 :\r
-                                        fprintf(fp, "\t\t call  [_a68k_memory_intf+32]\n");\r
-                                        break;\r
-\r
-                                case 87 :\r
-                                        fprintf(fp, "\t\t call  [_a68k_memory_intf+36]\n");\r
-                                        break;\r
-\r
-                                case 76 :\r
-                                        fprintf(fp, "\t\t call  [_a68k_memory_intf+40]\n");\r
-                                        break;\r
-                        }\r
-                        break;\r
-       }\r
-\r
-// AccessType = NORMAL;\r
-\r
-#else\r
-\r
-       switch (Size)\r
-       {\r
-               case 66 :\r
-                       fprintf(fp, "\t\t call  [_a68k_memory_intf+4]\n");\r
-                       break;\r
-\r
-               case 87 :\r
-                       fprintf(fp, "\t\t call  [_a68k_memory_intf+8]\n");\r
-                       break;\r
-\r
-               case 76 :\r
-                       fprintf(fp, "\t\t call  [_a68k_memory_intf+12]\n");\r
-                       break;\r
-       }\r
-#endif\r
-\r
-       /* Correct Stack */\r
-\r
-#ifndef FASTCALL\r
-       fprintf(fp, "\t\t lea   esp,[esp+4]\n");\r
-#endif\r
-\r
-\r
-\r
-       /* Restore registers */\r
-\r
-       /* Check to see if registers need restoring */\r
-\r
-       if ((Flags[EDI] != '-') && (SavedRegs[EDI] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t pop   EDI\n");\r
-       }\r
-\r
-       if ((Flags[ECX] != '-') && (SavedRegs[ECX] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t pop   ECX\n");\r
-       }\r
-\r
-       if ((Flags[EBX] != '-') && (SavedRegs[EBX] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t pop   EBX\n");\r
-       }\r
-\r
-       if ((Flags[ESI] != '-') && (SavedRegs[ESI] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t mov   ESI,[%s]\n",REG_PC);\r
-       }\r
-\r
-       if ((Flags[EDX] != '-') && (SavedRegs[EDX] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t mov   EDX,[%s]\n",REG_CCR);\r
-       }\r
-\r
-       if ((Flags[EBP] != '-') && (SavedRegs[EBP] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t mov   ebp,dword [_OP_ROM]\n");\r
-       }\r
-}\r
-\r
-void Memory_Write(char Size,int AReg,int DReg,char *Flags,int Mask)\r
-{\r
-       ExternalIO = 1;\r
-\r
-       /* Save PC */\r
-\r
-       fprintf(fp, "\t\t mov   [%s],ESI\n",REG_PC);\r
-\r
-       /* Check for special mask condition */\r
-\r
-       /* ASG - no longer need to mask addresses here */\r
-/*     if (Mask == 2)\r
-               fprintf(fp, "\t\t and   %s,0FFFFFFh\n",regnameslong[AReg]);*/\r
-\r
-       /* Check to see if registers need saving */\r
-\r
-       if ((Flags[EDX] != '-') && (SavedRegs[EDX] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t mov   [%s],edx\n",REG_CCR);\r
-       }\r
-\r
-       if ((Flags[EAX] != '-') && (SavedRegs[EAX] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t push  EAX\n");\r
-       }\r
-\r
-       if ((Flags[EBX] != '-') && (SavedRegs[EBX] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t push  EBX\n");\r
-       }\r
-\r
-       if ((Flags[ECX] != '-') && (SavedRegs[ECX] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t push  ECX\n");\r
-       }\r
-\r
-       if ((Flags[EDI] != '-') && (SavedRegs[EDI] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t push  EDI\n");\r
-       }\r
-\r
-#ifdef FASTCALL\r
-\r
-       fprintf(fp, "\t\t mov   %s,%s\n",FASTCALL_SECOND_REG,regnameslong[DReg]);\r
-       fprintf(fp, "\t\t mov   %s,%s\n",FASTCALL_FIRST_REG,regnameslong[AReg]);\r
-\r
-       /* ASG - no longer need to mask addresses here */\r
-/*     if (Mask == 1)\r
-               fprintf(fp, "\t\t and   %s,0FFFFFFh\n",FASTCALL_FIRST_REG);*/\r
-\r
-#else\r
-\r
-       fprintf(fp, "\t\t push  %s\n",regnameslong[DReg]);\r
-\r
-       if (Mask == 1)\r
-       {\r
-               if ((Flags[AReg] != '-') && (SavedRegs[AReg] != '-'))\r
-               {\r
-                       /* Don't trash a wanted safe register */\r
-\r
-                       fprintf(fp, "\t\t mov   EAX,%s\n",regnameslong[AReg]);\r
-       /* ASG - no longer need to mask addresses here */\r
-/*                     fprintf(fp, "\t\t and   EAX,0FFFFFFh\n");*/\r
-                       fprintf(fp, "\t\t push  EAX\n");\r
-               }\r
-               else\r
-               {\r
-       /* ASG - no longer need to mask addresses here */\r
-/*                     fprintf(fp, "\t\t and   %s,0FFFFFFh\n",regnameslong[AReg]);*/\r
-                       fprintf(fp, "\t\t push  %s\n",regnameslong[AReg]);\r
-               }\r
-       }\r
-       else\r
-               fprintf(fp, "\t\t push  %s\n",regnameslong[AReg]);\r
-\r
-#endif\r
-\r
-\r
-\r
-       /* Call Mame Routine */\r
-\r
-       /* ASG - changed these to call through the function pointers */\r
-       switch (Size)\r
-       {\r
-               case 66 :\r
-                       fprintf(fp, "\t\t call  [_a68k_memory_intf+16]\n");\r
-                       break;\r
-\r
-               case 87 :\r
-                       fprintf(fp, "\t\t call  [_a68k_memory_intf+20]\n");\r
-                       break;\r
-\r
-               case 76 :\r
-                       fprintf(fp, "\t\t call  [_a68k_memory_intf+24]\n");\r
-                       break;\r
-       }\r
-\r
-       /* Correct Stack */\r
-\r
-#ifndef FASTCALL\r
-       fprintf(fp, "\t\t lea   esp,[esp+8]\n");\r
-#endif\r
-\r
-\r
-\r
-       /* Restore registers */\r
-\r
-       /* Check to see if registers need restoring */\r
-\r
-       if ((Flags[EDI] != '-') && (SavedRegs[EDI] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t pop   EDI\n");\r
-       }\r
-\r
-       if ((Flags[ECX] != '-') && (SavedRegs[ECX] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t pop   ECX\n");\r
-       }\r
-\r
-       if ((Flags[EBX] != '-') && (SavedRegs[EBX] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t pop   EBX\n");\r
-       }\r
-\r
-       if ((Flags[EAX] != '-') && (SavedRegs[EAX] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t pop   EAX\n");\r
-       }\r
-\r
-       if ((Flags[EDX] != '-') && (SavedRegs[EDX] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t mov   EDX,[%s]\n",REG_CCR);\r
-       }\r
-\r
-       if ((Flags[ESI] != '-') && (SavedRegs[ESI] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t mov   ESI,[%s]\n",REG_PC);\r
-       }\r
-\r
-       if ((Flags[EBP] != '-') && (SavedRegs[EBP] == '-'))\r
-       {\r
-               fprintf(fp, "\t\t mov   ebp,dword [_OP_ROM]\n");\r
-       }\r
-}\r
-\r
-\r
-/*\r
- * Fetch data from Code area\r
- *\r
- * Dreg        = Destination Register\r
- * Extend = Sign Extend Word to Long\r
- *\r
- */\r
-\r
-void Memory_Fetch(char Size,int Dreg,int Extend)\r
-{\r
-       static int loopcount=0;\r
-\r
-       /* Always goes via OP_ROM */\r
-\r
-       if(CPU!=2)\r
-       {\r
-               /* 16 Bit version */\r
-\r
-               if ((Extend == TRUE) & (Size == 'W'))\r
-                 fprintf(fp, "\t\t movsx %s,word [esi+ebp]\n",regnameslong[Dreg]);\r
-               else if (Size == 'W')\r
-                 fprintf(fp, "\t\t movzx %s,word [esi+ebp]\n",regnameslong[Dreg]);\r
-               else\r
-                 fprintf(fp, "\t\t mov   %s,dword [esi+ebp]\n",regnameslong[Dreg]);\r
-\r
-               if (Size == 'L')\r
-                fprintf(fp, "\t\t rol   %s,16\n",regnameslong[Dreg]);\r
-       }\r
-       else\r
-       {\r
-               /* 32 Bit version */\r
-\r
-               if (Size == 'W')\r
-               {\r
-                       fprintf(fp, "\t\t mov   %s,esi\n",regnameslong[Dreg]);\r
-                       fprintf(fp, "\t\t xor   %s,byte 2\n",regnameslong[Dreg]);\r
-\r
-                       if (Extend == TRUE)\r
-                               fprintf(fp, "\t\t movsx %s,word [%s+ebp]\n",regnameslong[Dreg],regnameslong[Dreg]);\r
-                       else\r
-                               fprintf(fp, "\t\t movzx %s,word [%s+ebp]\n",regnameslong[Dreg],regnameslong[Dreg]);\r
-               }\r
-               else\r
-               {\r
-                        // if address is exact multiple of 4, long read will work\r
-                       // otherwise we need to get words address-2 and address+4\r
-\r
-                       // Always read long\r
-                fprintf(fp, "\t\t test  esi,2\n");\r
-#if (!ppro)\r
-                       fprintf(fp, "\t\t mov   %s,dword [esi+ebp]\n",regnameslong[Dreg]);\r
-\r
-                       // OK ?\r
-                       fprintf(fp, "\t\t jz    short FL%3.3d\n",loopcount+1);\r
-\r
-                       // no, so get high word\r
-                       fprintf(fp, "\t\t mov   %s,dword [esi+ebp-4]\n",regnameslong[Dreg]);\r
-                       // and get low word\r
-                       fprintf(fp, "\t\t mov   %s,word [esi+ebp+4]\n",regnamesword[Dreg]);\r
-\r
-                       fprintf(fp, "FL%3.3d:\n",++loopcount);\r
-#else\r
-                       fprintf(fp, "\t\t cmovnz %s,dword [esi+ebp-4]\n",regnameslong[Dreg]);\r
-                       fprintf(fp, "\t\t cmovz %s,dword [esi+ebp]\n",regnameslong[Dreg]);\r
-                       fprintf(fp, "\t\t cmovnz %s,word [esi+ebp+4]\n",regnamesword[Dreg]);\r
-#endif\r
-               }\r
-       }\r
-}\r
-\r
-/**********************/\r
-/* Push PC onto Stack */\r
-/**********************/\r
-\r
-void PushPC(int Wreg,int Wreg2,char *Flags, int Mask)\r
-{\r
-\r
-       /* Wreg2 is only used when high byte is kept  */\r
-       /* If it is EBP then the register is restored */\r
-\r
-       fprintf(fp, "\t\t mov   %s,[%s]\t ; Push onto Stack\n",regnameslong[Wreg],REG_A7);\r
-       fprintf(fp, "\t\t sub   %s,byte 4\n",regnameslong[Wreg]);\r
-       fprintf(fp, "\t\t mov   [%s],%s\n",REG_A7,regnameslong[Wreg]);\r
-\r
-#ifndef KEEPHIGHPC\r
-\r
-       Memory_Write('L',Wreg,ESI,Flags,Mask);\r
-\r
-#else\r
-\r
-       fprintf(fp, "\t\t mov   %s,[FullPC]\n",regnameslong[Wreg2]);\r
-       fprintf(fp, "\t\t and   %s,0xff000000\n",regnameslong[Wreg2]);\r
-       fprintf(fp, "\t\t or    %s,ESI\n",regnameslong[Wreg2]);\r
-\r
-       Memory_Write('L',Wreg,Wreg2,Flags,Mask);\r
-\r
-       if (Wreg2 == EBP)\r
-       {\r
-               fprintf(fp, "\t\t mov   ebp,dword [_OP_ROM]\n");\r
-       }\r
-\r
-#endif\r
-}\r
-\r
-void ExtensionDecode(int SaveEDX)\r
-{\r
-       char *Label = GenerateLabel(0,1);\r
-\r
-       if (SaveEDX)\r
-               fprintf(fp, "\t\t push  edx\n");\r
-\r
-       Memory_Fetch('W',EAX,FALSE);\r
-       fprintf(fp, "\t\t add   esi,byte 2\n");\r
-\r
-       if(CPU!=2)\r
-       {\r
-               /* 68000 Extension */\r
-\r
-               fprintf(fp, "\t\t mov   edx,eax\n");\r
-               fprintf(fp, "\t\t shr   eax,12\n");\r
-               fprintf(fp, "\t\t test  edx,0x0800\n");\r
-               fprintf(fp, "\t\t mov   eax,[%s+eax*4]\n",REG_DAT);\r
-               fprintf(fp, "\t\t jnz   short %s\n",Label);\r
-               fprintf(fp, "\t\t cwde\n");\r
-               fprintf(fp, "%s:\n",Label);\r
-               fprintf(fp, "\t\t lea   edi,[edi+eax]\n");\r
-               fprintf(fp, "\t\t movsx edx,dl\n");\r
-               fprintf(fp, "\t\t lea   edi,[edi+edx]\n");\r
-       }\r
-       else\r
-       {\r
-                 /* 68020 Extension */\r
-\r
-               // eax holds scaled index\r
-\r
-               // might be faster just to push all regs\r
-               fprintf(fp, "\t\t push  ebx\n");\r
-               fprintf(fp, "\t\t push  ecx\n");\r
-\r
-               // copies for later use\r
-               fprintf(fp, "\t\t mov   ecx,eax\n");\r
-               fprintf(fp, "\t\t mov   edx,eax\n");\r
-\r
-               // check E bit to see if displacement or full format\r
-               fprintf(fp, "\t\t test  edx,0x0100\n");\r
-               fprintf(fp, "\t\t jz   short %s_a\n",Label);\r
-               // full mode so check IS (index supress)\r
-               fprintf(fp, "\t\t test  edx,0x0040\n");\r
-               fprintf(fp, "\t\t jz   short %s_b\n",Label);\r
-               // set index to 0, it's not added\r
-               ClearRegister(EAX);\r
-               fprintf(fp, "\t\t jmp  short %s_d\n",Label);  // near\r
-\r
-               // add displacement\r
-  fprintf(fp, "%s_a:\n",Label);\r
-               fprintf(fp, "\t\t movsx eax,al\n");\r
-               fprintf(fp, "\t\t lea   edi,[edi+eax]\n");\r
-\r
-  fprintf(fp, "%s_b:\n",Label);\r
-               // calc index always scale (68k will scale by 1)\r
-               fprintf(fp, "\t\t mov   eax,edx\n");\r
-               fprintf(fp, "\t\t shr   eax,12\n");\r
-               fprintf(fp, "\t\t test  edx,0x0800\n");\r
-               fprintf(fp, "\t\t mov   eax,[%s+eax*4]\n",REG_DAT);\r
-               fprintf(fp, "\t\t jnz   short %s_c\n",Label);\r
-               fprintf(fp, "\t\t cwde\n");\r
-\r
-  fprintf(fp, "%s_c:\n",Label);\r
-               fprintf(fp, "\t\t shr   ecx,byte 9\n");\r
-               fprintf(fp, "\t\t and   ecx,byte 3\n");\r
-               fprintf(fp, "\t\t shl   eax,cl\n");\r
-\r
-               // if brief mode we can add index and exit\r
-               fprintf(fp, "\t\t test  edx,0x0100\n");\r
-               fprintf(fp, "\t\t jz    near %s_i2\n",Label);\r
-\r
-  fprintf(fp, "%s_d:\n",Label);\r
-               // check BS (base supress)\r
-               // if BS is 1 then set edi to 0\r
-               fprintf(fp, "\t\t test  edx,0x0080\n");\r
-               fprintf(fp, "\t\t jz    short %s_4a\n",Label);\r
-               ClearRegister(EDI);\r
-               // if null displacement skip over\r
-               fprintf(fp, "%s_4a:\n",Label);\r
-               fprintf(fp, "\t\t test  edx,0x0020\n");\r
-               fprintf(fp, "\t\t jz    short %s_f\n",Label);\r
-\r
-               // **** calc base displacement ****\r
-               // is it long\r
-               fprintf(fp, "\t\t test  edx,0x0010\n");\r
-               fprintf(fp, "\t\t jz    short %s_e\n",Label);\r
-               // fetch long base\r
-               Memory_Fetch('L',EBX,FALSE);\r
-               fprintf(fp, "\t\t lea   edi,[edi+ebx]\n");\r
-               fprintf(fp, "\t\t add   esi,byte 4\n");\r
-               fprintf(fp, "\t\t jmp   short %s_f\n",Label);\r
-\r
-               // fetch word base\r
-  fprintf(fp, "%s_e:\n",Label);\r
-               Memory_Fetch('W',EBX,TRUE);\r
-               fprintf(fp, "\t\t lea   edi,[edi+ebx]\n");\r
-               fprintf(fp, "\t\t add   esi,byte 2\n");\r
-\r
-               // **** indirect? ****\r
-  fprintf(fp, "%s_f:\n",Label);\r
-               fprintf(fp, "\t\t test  edx,0x0003\n");\r
-               fprintf(fp, "\t\t jz    near %s_7a\n",Label);\r
-               // pre or post indirect\r
-               fprintf(fp, "\t\t test  edx,0x0004\n");\r
-               fprintf(fp, "\t\t jnz   short %s_g\n",Label);\r
-               // do pre\r
-               fprintf(fp, "\t\t lea   edi,[edi+eax]\n");\r
-               Memory_Read('L',EDI,"ABCDSDB",2);\r
-               fprintf(fp, "\t\t mov   edi,eax\n");\r
-               fprintf(fp, "\t\t jmp   short %s_h\n",Label);\r
-\r
-               // do post\r
- fprintf(fp, "%s_g:\n",Label);\r
-               fprintf(fp, "\t\t push  eax\n");\r
-               Memory_Read('L',EDI,"-B-DS-B",2);\r
-               fprintf(fp, "\t\t pop   edi\n");\r
-\r
- fprintf(fp, "%s_7a:\n",Label);\r
-               fprintf(fp, "\t\t lea   edi,[edi+eax]\n");\r
-\r
-               // **** outer displacement ****\r
-               // if null displacement skip over\r
- fprintf(fp, "%s_h:\n",Label);\r
-               fprintf(fp, "\t\t test  edx,0x0002\n");\r
-               fprintf(fp, "\t\t jz    short %s_j\n",Label);\r
-               // word or long?\r
-               fprintf(fp, "\t\t test  edx,0x0001\n");\r
-               fprintf(fp, "\t\t jz    short %s_i\n",Label);\r
-               // fetch long\r
-               Memory_Fetch('L',EAX,FALSE);\r
-               fprintf(fp, "\t\t add   esi,byte 4\n");\r
-               fprintf(fp, "\t\t jmp   short %s_i2\n",Label);\r
-               // fetch word\r
-  fprintf(fp, "%s_i:\n",Label);\r
-               Memory_Fetch('W',EAX,TRUE);\r
-               fprintf(fp, "\t\t add   esi,byte 2\n");\r
-  fprintf(fp, "%s_i2:\n",Label);\r
-               fprintf(fp, "\t\t lea   edi,[edi+eax]\n");\r
-\r
-               // **** exit ****\r
-  fprintf(fp, "%s_j:\n",Label);\r
-               fprintf(fp, "\t\t pop   ecx\n");\r
-               fprintf(fp, "\t\t pop   ebx\n");\r
-       }\r
-\r
-       if (SaveEDX)\r
-               fprintf(fp, "\t\t pop   edx\n");\r
-}\r
-\r
-/* Calculate Effective Address - Return address in EDI\r
- *\r
- * mode = Effective Address from Instruction\r
- * Size = Byte,Word or Long\r
- * Rreg = Register with Register Number in\r
- *\r
- * Only for modes 2 - 10 (5-10 clobber EAX)\r
- */\r
-\r
-void EffectiveAddressCalculate(int mode,char Size,int Rreg,int SaveEDX)\r
-{\r
-       /* timing */\r
-\r
-       if ((TimingCycles > 0) && (AddEACycles!=0))\r
-       {\r
-               switch (mode)\r
-               {\r
-                       case 2:         /* (An) */\r
-                       case 3:         /* (An)+ */\r
-                       case 11:        /* #x,SR,CCR */\r
-                       case 19:        /* (A7)+ */\r
-                               TimingCycles += 4 ;\r
-                               break ;\r
-\r
-                       case 4:         /* -(An) */\r
-                       case 20:        /* -(A7) */\r
-                               TimingCycles += (CPU==2) ? 5 : 6 ;\r
-                               break ;\r
-\r
-                       case 5:         /* x(An) */\r
-                       case 9:         /* x(PC) */\r
-                               TimingCycles += (CPU==2) ? 5 : 8 ;\r
-                               break ;\r
-\r
-                       case 7:         /* x.w */\r
-                               TimingCycles += (CPU==2) ? 4 : 8 ;\r
-                               break ;\r
-\r
-                       case 6:         /* x(An,xr.s) */\r
-                       case 10:        /* x(PC,xr.s) */\r
-                               TimingCycles += (CPU==2) ? 7 : 10 ;\r
-                               break ;\r
-\r
-                       case 8:         /* x.l */\r
-                               TimingCycles += (CPU==2) ? 4 : 12 ;\r
-                               break ;\r
-               }\r
-\r
-               /* long w/r adds 4 cycles */\r
-\r
-               if ((mode>1) && (Size == 'L') && (CPU != 2))\r
-                       TimingCycles += 4 ;\r
-       }\r
-\r
-       AccessType = NORMAL;\r
-\r
-       switch (mode)\r
-       {\r
-\r
-               case 2:\r
-                       fprintf(fp, "\t\t mov   EDI,[%s+%s*4]\n",REG_ADD,regnameslong[Rreg]);\r
-                       break;\r
-\r
-               case 3:\r
-                       fprintf(fp, "\t\t mov   EDI,[%s+%s*4]\n",REG_ADD,regnameslong[Rreg]);\r
-                       IncrementEDI(Size,Rreg);\r
-                       break;\r
-\r
-               case 4:\r
-                       fprintf(fp, "\t\t mov   EDI,[%s+%s*4]\n",REG_ADD,regnameslong[Rreg]);\r
-                       DecrementEDI(Size,Rreg);\r
-                       fprintf(fp, "\t\t mov   [%s+%s*4],EDI\n",REG_ADD,regnameslong[Rreg]);\r
-                       break;\r
-\r
-               case 5:\r
-                       Memory_Fetch('W',EAX,TRUE);\r
-                       fprintf(fp, "\t\t mov   EDI,[%s+%s*4]\n",REG_ADD,regnameslong[Rreg]);\r
-                       fprintf(fp, "\t\t add   esi,byte 2\n");\r
-                       fprintf(fp, "\t\t add   edi,eax\n");\r
-                       break;\r
-\r
-               case 6:\r
-\r
-                       /* Get Address register Value */\r
-\r
-                       fprintf(fp, "\t\t mov   EDI,[%s+%s*4]\n",REG_ADD,regnameslong[Rreg]);\r
-\r
-                       /* Add Extension Details */\r
-\r
-                       ExtensionDecode(SaveEDX);\r
-                       break;\r
-\r
-               case 7:\r
-\r
-                       /* Get Word */\r
-\r
-                       Memory_Fetch('W',EDI,TRUE);\r
-//              fprintf(fp, "\t\t movsx edi,di\n");\r
-                       fprintf(fp, "\t\t add   esi,byte 2\n");\r
-                       break;\r
-\r
-               case 8:\r
-\r
-                       /* Get Long */\r
-\r
-                       Memory_Fetch('L',EDI,FALSE);\r
-                       fprintf(fp, "\t\t add   esi,byte 4\n");\r
-                       break;\r
-\r
-               case 9:\r
-\r
-                       AccessType = PCREL;\r
-\r
-                       Memory_Fetch('W',EAX,TRUE);\r
-//              fprintf(fp, "\t\t movsx eax,ax\n");\r
-                       fprintf(fp, "\t\t mov   EDI,ESI           ; Get PC\n");\r
-                       fprintf(fp, "\t\t add   esi,byte 2\n");\r
-                       fprintf(fp, "\t\t add   edi,eax         ; Add Offset to PC\n");\r
-                       break;\r
-\r
-               case 10:\r
-\r
-                       AccessType = PCREL;\r
-\r
-                       /* Get PC */\r
-\r
-                       fprintf(fp, "\t\t mov   edi,esi           ; Get PC\n");\r
-\r
-                       /* Add Extension Details */\r
-\r
-                       ExtensionDecode(SaveEDX);\r
-\r
-                       break;\r
-\r
-               case 19:\r
-\r
-                       /* (A7)+ */\r
-\r
-                       fprintf(fp, "\t\t mov   edi,[%s]    ; Get A7\n",REG_A7);\r
-                       fprintf(fp, "\t\t add   dword [%s],byte 2\n",REG_A7);\r
-                       break;\r
-\r
-               case 20:\r
-\r
-                       /* -(A7) */\r
-\r
-                       fprintf(fp, "\t\t mov   edi,[%s]    ; Get A7\n",REG_A7);\r
-                       fprintf(fp, "\t\t sub   edi,byte 2\n");\r
-                       fprintf(fp, "\t\t mov   [%s],edi\n",REG_A7);\r
-                       break;\r
-\r
-       }\r
-}\r
-\r
-/* Read from Effective Address\r
- *\r
- * mode = Effective Address from Instruction\r
- * Size = Byte,Word or Long\r
- * Rreg = Register with Register Number in\r
- * Flag = Registers to preserve (EDX is handled by SaveEDX)\r
- *\r
- * Return\r
- * Dreg = Register to return result in (EAX is usually most efficient)\r
- * (modes 5 to 10) EDI  = Address of data read (masked with FFFFFF)\r
- */\r
-\r
-void EffectiveAddressRead(int mode,char Size,int Rreg,int Dreg,const char *flags,int SaveEDX)\r
-{\r
-       char* Regname="";\r
-       int     MaskMode;\r
-       char Flags[8];\r
-\r
-       AccessType = NORMAL;\r
-\r
-       strcpy(Flags,flags);\r
-\r
-       /* Which Masking to Use */\r
-\r
-       if (Flags[5] != '-')\r
-               MaskMode = 2;\r
-       else\r
-               MaskMode = 1;\r
-\r
-       if (SaveEDX)\r
-               Flags[3] = 'D';\r
-       else\r
-               Flags[3] = '-';\r
-\r
-       switch (Size)\r
-       {\r
-               case 66:\r
-                       Regname = regnamesshort[Dreg];\r
-                       break;\r
-\r
-               case 87:\r
-                       Regname = regnamesword[Dreg];\r
-                       break;\r
-\r
-               case 76:\r
-                       Regname = regnameslong[Dreg];\r
-                       break;\r
-       }\r
-\r
-       switch (mode & 15)\r
-       {\r
-\r
-               case 0:\r
-\r
-                       /* Read 32 bits - No prefix */\r
-\r
-                       fprintf(fp, "\t\t mov   %s,[%s+%s*4]\n",regnameslong[Dreg],REG_DAT,regnameslong[Rreg]);\r
-                       break;\r
-\r
-               case 1:\r
-\r
-                       /* Read 32 bits - No prefix */\r
-\r
-                       fprintf(fp, "\t\t mov   %s,[%s+%s*4]\n",regnameslong[Dreg],REG_ADD,regnameslong[Rreg]);\r
-                       break;\r
-\r
-               case 2:\r
-                       EffectiveAddressCalculate(mode,Size,Rreg,SaveEDX);\r
-\r
-                       Memory_Read(Size,EDI,Flags,MaskMode);\r
-\r
-                       if (Dreg != EAX)\r
-                       {\r
-                               fprintf(fp, "\t\t mov   %s,EAX\n",regnameslong[Dreg]);\r
-                       }\r
-                       break;\r
-\r
-               case 3:\r
-                       EffectiveAddressCalculate(mode,Size,Rreg,SaveEDX);\r
-\r
-                       Memory_Read(Size,EDI,Flags,MaskMode);\r
-\r
-                       if (Dreg != EAX)\r
-                       {\r
-                               fprintf(fp, "\t\t mov   %s,EAX\n",regnameslong[Dreg]);\r
-                       }\r
-                       break;\r
-\r
-               case 4:\r
-                       EffectiveAddressCalculate(mode,Size,Rreg,SaveEDX);\r
-\r
-                       Memory_Read(Size,EDI,Flags,MaskMode);\r
-\r
-                       if (Dreg != EAX)\r
-                       {\r
-                               fprintf(fp, "\t\t mov   %s,EAX\n",regnameslong[Dreg]);\r
-                       }\r
-                       break;\r
-\r
-\r
-               case 5:\r
-                       EffectiveAddressCalculate(mode,Size,Rreg,SaveEDX);\r
-\r
-                       Memory_Read(Size,EDI,Flags,MaskMode);\r
-\r
-                       if (Dreg != EAX)\r
-                       {\r
-                               fprintf(fp, "\t\t mov   %s,EAX\n",regnameslong[Dreg]);\r
-                       }\r
-                       break;\r
-\r
-               case 6:\r
-                       EffectiveAddressCalculate(mode,Size,Rreg,SaveEDX);\r
-\r
-                       Memory_Read(Size,EDI,Flags,MaskMode);\r
-\r
-                       if (Dreg != EAX)\r
-                       {\r
-                               fprintf(fp, "\t\t mov   %s,EAX\n",regnameslong[Dreg]);\r
-                       }\r
-                       break;\r
-\r
-               case 7:\r
-                       EffectiveAddressCalculate(mode,Size,Rreg,SaveEDX);\r
-\r
-                       Memory_Read(Size,EDI,Flags,MaskMode);\r
-\r
-                       if (Dreg != EAX)\r
-                       {\r
-                               fprintf(fp, "\t\t mov   %s,EAX\n",regnameslong[Dreg]);\r
-                       }\r
-                       break;\r
-\r
-               case 8:\r
-                       EffectiveAddressCalculate(mode,Size,Rreg,SaveEDX);\r
-\r
-                       Memory_Read(Size,EDI,Flags,MaskMode);\r
-\r
-                       if (Dreg != EAX)\r
-                       {\r
-                               fprintf(fp, "\t\t mov   %s,EAX\n",regnameslong[Dreg]);\r
-                       }\r
-                       break;\r
-\r
-               case 9:\r
-                       EffectiveAddressCalculate(mode,Size,Rreg,SaveEDX);\r
-\r
-                       Memory_Read(Size,EDI,Flags,MaskMode);\r
-\r
-                       if (Dreg != EAX)\r
-                       {\r
-                               fprintf(fp, "\t\t mov   %s,EAX\n",regnameslong[Dreg]);\r
-                       }\r
-                       break;\r
-\r
-               case 10:\r
-                       EffectiveAddressCalculate(mode,Size,Rreg,SaveEDX);\r
-\r
-                       Memory_Read(Size,EDI,Flags,MaskMode);\r
-\r
-                       if (Dreg != EAX)\r
-                       {\r
-                               fprintf(fp, "\t\t mov   %s,EAX\n",regnameslong[Dreg]);\r
-                       }\r
-                       break;\r
-\r
-               case 11:\r
-\r
-                       /* Immediate - for SR or CCR see ReadCCR() */\r
-\r
-                       if (Size == 'L')\r
-                       {\r
-                               Memory_Fetch('L',Dreg,FALSE);\r
-                               fprintf(fp, "\t\t add   esi,byte 4\n");\r
-                       }\r
-                       else\r
-                       {\r
-                               Memory_Fetch('W',Dreg,FALSE);\r
-                               fprintf(fp, "\t\t add   esi,byte 2\n");\r
-                       };\r
-                       break;\r
-       }\r
-}\r
-\r
-/*\r
- * EA  = Effective Address from Instruction\r
- * Size = Byte,Word or Long\r
- * Rreg = Register with Register Number in\r
- *\r
- * Writes from EAX\r
- */\r
-\r
-void EffectiveAddressWrite(int mode,char Size,int Rreg,int CalcAddress,const char *flags,int SaveEDX)\r
-{\r
-       int     MaskMode;\r
-       char* Regname="";\r
-       char Flags[8];\r
-\r
-\r
-       strcpy(Flags,flags);\r
-\r
-       /* Which Masking to Use ? */\r
-\r
-       if (CalcAddress)\r
-       {\r
-               if (Flags[5] != '-')\r
-                       MaskMode = 2;\r
-               else\r
-                       MaskMode = 1;\r
-       }\r
-       else\r
-               MaskMode = 0;\r
-\r
-       if (SaveEDX)\r
-               Flags[3] = 'D';\r
-       else\r
-               Flags[3] = '-';\r
-\r
-       switch (Size)\r
-       {\r
-               case 66:\r
-                       Regname = regnamesshort[0];\r
-                       break;\r
-\r
-               case 87:\r
-                       Regname = regnamesword[0];\r
-                       break;\r
-\r
-               case 76:\r
-                       Regname = regnameslong[0];\r
-                       break;\r
-       }\r
-\r
-       switch (mode & 15)\r
-       {\r
-\r
-               case 0:\r
-                       fprintf(fp, "\t\t mov   [%s+%s*4],%s\n",REG_DAT,regnameslong[Rreg],Regname);\r
-                       break;\r
-\r
-               case 1:\r
-                       if (Size == 66)\r
-                       {\r
-                               /* Not Allowed */\r
-\r
-                               fprintf(fp, "DUFF CODE!\n");\r
-                       }\r
-                       else\r
-                       {\r
-                               if (Size == 87)\r
-                               {\r
-                                       fprintf(fp, "\t\t cwde\n");\r
-                               }\r
-\r
-                               fprintf(fp, "\t\t mov   [%s+%s*4],%s\n",REG_ADD,regnameslong[Rreg],regnameslong[0]);\r
-                       }\r
-                       break;\r
-\r
-               case 2:\r
-                       if (CalcAddress) EffectiveAddressCalculate(mode,Size,Rreg,SaveEDX);\r
-                       Memory_Write(Size,EDI,EAX,Flags,MaskMode);\r
-                       break;\r
-\r
-               case 3:\r
-                       if (CalcAddress) EffectiveAddressCalculate(mode,Size,Rreg,SaveEDX);\r
-                       Memory_Write(Size,EDI,EAX,Flags,MaskMode);\r
-                       break;\r
-\r
-               case 4:\r
-                       if (CalcAddress) EffectiveAddressCalculate(mode,Size,Rreg,SaveEDX);\r
-                       Memory_Write(Size,EDI,EAX,Flags,MaskMode);\r
-                       break;\r
-\r
-               case 5:\r
-                       if (CalcAddress)\r
-                       {\r
-                               fprintf(fp, "\t\t push  EAX\n");\r
-                               EffectiveAddressCalculate(mode,Size,Rreg,SaveEDX);\r
-                               fprintf(fp, "\t\t pop   EAX\n");\r
-                       }\r
-                       Memory_Write(Size,EDI,EAX,Flags,MaskMode);\r
-                       break;\r
-\r
-               case 6:\r
-                       if (CalcAddress)\r
-                       {\r
-                               fprintf(fp, "\t\t push  EAX\n");\r
-                               EffectiveAddressCalculate(mode,Size,Rreg,SaveEDX);\r
-                               fprintf(fp, "\t\t pop   EAX\n");\r
-                       }\r
-                       Memory_Write(Size,EDI,EAX,Flags,MaskMode);\r
-                       break;\r
-\r
-               case 7:\r
-                       if (CalcAddress)\r
-                       {\r
-                               fprintf(fp, "\t\t push  EAX\n");\r
-                               EffectiveAddressCalculate(mode,Size,Rreg,SaveEDX);\r
-                               fprintf(fp, "\t\t pop   EAX\n");\r
-                       }\r
-                       Memory_Write(Size,EDI,EAX,Flags,MaskMode);\r
-                       break;\r
-\r
-               case 8:\r
-                       if (CalcAddress)\r
-                       {\r
-                               fprintf(fp, "\t\t push  EAX\n");\r
-                               EffectiveAddressCalculate(mode,Size,Rreg,SaveEDX);\r
-                               fprintf(fp, "\t\t pop   EAX\n");\r
-                       }\r
-                       Memory_Write(Size,EDI,EAX,Flags,MaskMode);\r
-                       break;\r
-\r
-               case 9:\r
-                       if (CalcAddress)\r
-                       {\r
-                               fprintf(fp, "\t\t push  EAX\n");\r
-                               EffectiveAddressCalculate(mode,Size,Rreg,SaveEDX);\r
-                               fprintf(fp, "\t\t pop   EAX\n");\r
-                       }\r
-                       Memory_Write(Size,EDI,EAX,Flags,MaskMode);\r
-                       break;\r
-\r
-               case 10:\r
-                       if (CalcAddress)\r
-                       {\r
-                               fprintf(fp, "\t\t push  EAX\n");\r
-                               EffectiveAddressCalculate(mode,Size,Rreg,SaveEDX);\r
-                               fprintf(fp, "\t\t pop   EAX\n");\r
-                       }\r
-                       Memory_Write(Size,EDI,EAX,Flags,MaskMode);\r
-                       break;\r
-\r
-               case 11:\r
-\r
-                       /* SR, CCR - Chain to correct routine */\r
-\r
-                       WriteCCR(Size);\r
-       }\r
-}\r
-\r
-/* Condition Decode Routines */\r
-\r
-/*\r
- * mode = condition to check for\r
- *\r
- * Returns LABEL that is jumped to if condition is Condition\r
- *\r
- * Some conditions clobber AH\r
- */\r
-\r
-char *ConditionDecode(int mode, int Condition)\r
-{\r
-       char *Label = GenerateLabel(0,1);\r
-\r
-       switch (mode)\r
-       {\r
-\r
-               case 0: /* A - Always */\r
-                       if (Condition)\r
-                       {\r
-        fprintf(fp, "\t\t jmp   %s ;dave removed near\n",Label);\r
-                       }\r
-                       break;\r
-\r
-               case 1: /* F - Never */\r
-                       if (!Condition)\r
-                       {\r
-                               fprintf(fp, "\t\t jmp   near %s\n",Label);\r
-                       }\r
-                       break;\r
-\r
-               case 2: /* Hi */\r
-                       fprintf(fp, "\t\t mov   ah,dl\n");\r
-                       fprintf(fp, "\t\t sahf\n");\r
-\r
-                       if (Condition)\r
-                       {\r
-                               fprintf(fp, "\t\t ja    near %s\n",Label);\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(fp, "\t\t jbe   near %s\n",Label);\r
-                       }\r
-                       break;\r
-\r
-               case 3: /* Ls */\r
-                       fprintf(fp, "\t\t mov   ah,dl\n");\r
-                       fprintf(fp, "\t\t sahf\n");\r
-\r
-                       if (Condition)\r
-                       {\r
-                               fprintf(fp, "\t\t jbe   near %s\n",Label);\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(fp, "\t\t ja    near %s\n",Label);\r
-                       }\r
-                       break;\r
-\r
-               case 4: /* CC */\r
-                       fprintf(fp, "\t\t test  dl,1H\t\t;check carry\n");\r
-\r
-                       if (Condition)\r
-                       {\r
-                               fprintf(fp, "\t\t jz    near %s\n",Label);\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(fp, "\t\t jnz   near %s\n",Label);\r
-                       }\r
-                       break;\r
-\r
-               case 5: /* CS */\r
-                       fprintf(fp,  "\t\t test  dl,1H\t\t;check carry\n");\r
-                       if (Condition)\r
-                       {\r
-                               fprintf(fp, "\t\t jnz   near %s\n",Label);\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(fp, "\t\t jz    near %s\n",Label);\r
-                       }\r
-                       break;\r
-\r
-               case 6: /* NE */\r
-                       fprintf(fp, "\t\t test  dl,40H\t\t;Check zero\n");\r
-                       if (Condition)\r
-                       {\r
-                               fprintf(fp, "\t\t jz    near %s\n",Label);\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(fp, "\t\t jnz   near %s\n",Label);\r
-                       }\r
-                       break;\r
-\r
-               case 7: /* EQ */\r
-                       fprintf(fp, "\t\t test  dl,40H\t\t;Check zero\n");\r
-                       if (Condition)\r
-                       {\r
-                               fprintf(fp, "\t\t jnz   near %s\n",Label);\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(fp, "\t\t jz    near %s\n",Label);\r
-                       }\r
-                       break;\r
-\r
-               case 8: /* VC */\r
-                       fprintf(fp, "\t\t test  dh,8H\t\t;Check Overflow\n");\r
-                       if (Condition)\r
-                       {\r
-                               fprintf(fp, "\t\t jz    near %s\n", Label);\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(fp, "\t\t jnz   near %s\n", Label);\r
-                       }\r
-                       break;\r
-\r
-               case 9: /* VS */\r
-                       fprintf(fp, "\t\t test  dh,8H\t\t;Check Overflow\n");\r
-                       if (Condition)\r
-                       {\r
-                               fprintf(fp, "\t\t jnz   near %s\n", Label);\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(fp, "\t\t jz    near %s\n", Label);\r
-                       }\r
-                       break;\r
-\r
-               case 10:        /* PL */\r
-                       fprintf(fp,"\t\t test  dl,80H\t\t;Check Sign\n");\r
-                       if (Condition)\r
-                       {\r
-                               fprintf(fp, "\t\t jz    near %s\n", Label);\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(fp, "\t\t jnz   near %s\n", Label);\r
-                       }\r
-                       break;\r
-\r
-               case 11:        /* MI */\r
-                       fprintf(fp,"\t\t test  dl,80H\t\t;Check Sign\n");\r
-                       if (Condition)\r
-                       {\r
-                               fprintf(fp, "\t\t jnz   near %s\n", Label);\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(fp, "\t\t jz    near %s\n", Label);\r
-                       }\r
-                       break;\r
-\r
-               case 12:        /* GE */\r
-                       fprintf(fp, "\t\t or    edx,200h\n");\r
-                       fprintf(fp, "\t\t push  edx\n");\r
-                       fprintf(fp, "\t\t popf\n");\r
-                       if (Condition)\r
-                       {\r
-                               fprintf(fp, "\t\t jge   near %s\n",Label);\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(fp, "\t\t jl    near %s\n",Label);\r
-                       }\r
-                       break;\r
-\r
-               case 13:        /* LT */\r
-                       fprintf(fp, "\t\t or    edx,200h\n");\r
-                       fprintf(fp, "\t\t push  edx\n");\r
-                       fprintf(fp, "\t\t popf\n");\r
-                       if (Condition)\r
-                       {\r
-                               fprintf(fp, "\t\t jl    near %s\n",Label);\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(fp, "\t\t jge   near %s\n",Label);\r
-                       }\r
-                       break;\r
-\r
-               case 14:        /* GT */\r
-                       fprintf(fp, "\t\t or    edx,200h\n");\r
-                       fprintf(fp, "\t\t push  edx\n");\r
-                       fprintf(fp, "\t\t popf\n");\r
-                       if (Condition)\r
-                       {\r
-                               fprintf(fp, "\t\t jg    near %s\n",Label);\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(fp, "\t\t jle   near %s\n",Label);\r
-                       }\r
-                       break;\r
-\r
-               case 15:        /* LE */\r
-                       fprintf(fp, "\t\t or    edx,200h\n");\r
-                       fprintf(fp, "\t\t push  edx\n");\r
-                       fprintf(fp, "\t\t popf\n");\r
-                       if (Condition)\r
-                       {\r
-                               fprintf(fp, "\t\t jle   near %s\n",Label);\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(fp, "\t\t jg    near %s\n",Label);\r
-                       }\r
-                       break;\r
-       }\r
-\r
-       return Label;\r
-}\r
-\r
-/*\r
- * mode = condition to check for\r
- * SetWhat = text for assembler command (usually AL or address descriptor)\r
- *\r
- * Some conditions clobber AH\r
- */\r
-\r
-void ConditionCheck(int mode, char *SetWhat)\r
-{\r
-       switch (mode)\r
-       {\r
-\r
-               case 0: /* A - Always */\r
-                       fprintf(fp, "\t\t mov   %s,byte 0ffh\n",SetWhat);\r
-                       break;\r
-\r
-               case 1: /* F - Never */\r
-                       if (SetWhat[1] == 'L')\r
-                       {\r
-                               ClearRegister(EAX);\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(fp, "\t\t mov   %s,byte 0h\n",SetWhat);\r
-                       }\r
-                       break;\r
-\r
-               case 2: /* Hi */\r
-                       fprintf(fp, "\t\t mov   ah,dl\n");\r
-                       fprintf(fp, "\t\t sahf\n");\r
-                       fprintf(fp, "\t\t seta  %s\n",SetWhat);\r
-                       fprintf(fp, "\t\t neg   byte %s\n",SetWhat);\r
-                       break;\r
-\r
-               case 3: /* Ls */\r
-                       fprintf(fp, "\t\t mov   ah,dl\n");\r
-                       fprintf(fp, "\t\t sahf\n");\r
-                       fprintf(fp, "\t\t setbe %s\n",SetWhat);\r
-                       fprintf(fp, "\t\t neg   byte %s\n",SetWhat);\r
-                       break;\r
-\r
-               case 4: /* CC */\r
-                       fprintf(fp, "\t\t test  dl,1\t\t;Check Carry\n");\r
-                       fprintf(fp, "\t\t setz  %s\n",SetWhat);\r
-                       fprintf(fp, "\t\t neg   byte %s\n",SetWhat);\r
-                       break;\r
-\r
-               case 5: /* CS */\r
-                       fprintf(fp, "\t\t test  dl,1\t\t;Check Carry\n");\r
-                       fprintf(fp, "\t\t setnz %s\n",SetWhat);\r
-                       fprintf(fp, "\t\t neg   byte %s\n",SetWhat);\r
-                       break;\r
-\r
-               case 6: /* NE */\r
-                       fprintf(fp, "\t\t test  dl,40H\t\t;Check Zero\n");\r
-                       fprintf(fp, "\t\t setz  %s\n",SetWhat);\r
-                       fprintf(fp, "\t\t neg   byte %s\n",SetWhat);\r
-                       break;\r
-\r
-               case 7: /* EQ */\r
-                       fprintf(fp, "\t\t test  dl,40H\t\t;Check Zero\n");\r
-                       fprintf(fp, "\t\t setnz %s\n",SetWhat);\r
-                       fprintf(fp, "\t\t neg   byte %s\n",SetWhat);\r
-                       break;\r
-\r
-               case 8: /* VC */\r
-                       fprintf(fp, "\t\t test  dh,8H\t\t;Check Overflow\n");\r
-                       fprintf(fp, "\t\t setz  %s\n",SetWhat);\r
-                       fprintf(fp, "\t\t neg   byte %s\n",SetWhat);\r
-                       break;\r
-\r
-               case 9: /* VS */\r
-                       fprintf(fp, "\t\t test  dh,8H\t\t;Check Overflow\n");\r
-                       fprintf(fp, "\t\t setnz %s\n",SetWhat);\r
-                       fprintf(fp, "\t\t neg   byte %s\n",SetWhat);\r
-                       break;\r
-\r
-               case 10:        /* PL */\r
-                       fprintf(fp, "\t\t test  dl,80H\t\t;Check Sign\n");\r
-                       fprintf(fp, "\t\t setz  %s\n",SetWhat);\r
-                       fprintf(fp, "\t\t neg   byte %s\n",SetWhat);\r
-                       break;\r
-\r
-               case 11:        /* MI */\r
-                       fprintf(fp, "\t\t test  dl,80H\t\t;Check Sign\n");\r
-                       fprintf(fp, "\t\t setnz %s\n",SetWhat);\r
-                       fprintf(fp, "\t\t neg   byte %s\n",SetWhat);\r
-                       break;\r
-\r
-               case 12:        /* GE */\r
-                       fprintf(fp, "\t\t or    edx,200h\n");\r
-                       fprintf(fp, "\t\t push  edx\n");\r
-                       fprintf(fp, "\t\t popf\n");\r
-                       fprintf(fp, "\t\t setge %s\n",SetWhat);\r
-                       fprintf(fp, "\t\t neg   byte %s\n",SetWhat);\r
-                       break;\r
-\r
-               case 13:        /* LT */\r
-                       fprintf(fp, "\t\t or    edx,200h\n");\r
-                       fprintf(fp, "\t\t push  edx\n");\r
-                       fprintf(fp, "\t\t popf\n");\r
-                       fprintf(fp, "\t\t setl  %s\n",SetWhat);\r
-                       fprintf(fp, "\t\t neg   byte %s\n",SetWhat);\r
-                       break;\r
-\r
-               case 14:        /* GT */\r
-                       fprintf(fp, "\t\t or    edx,200h\n");\r
-                       fprintf(fp, "\t\t push  edx\n");\r
-                       fprintf(fp, "\t\t popf\n");\r
-                       fprintf(fp, "\t\t setg  %s\n",SetWhat);\r
-                       fprintf(fp, "\t\t neg   byte %s\n",SetWhat);\r
-                       break;\r
-\r
-               case 15:        /* LE */\r
-                       fprintf(fp, "\t\t or    edx,200h\n");\r
-                       fprintf(fp, "\t\t push  edx\n");\r
-                       fprintf(fp, "\t\t popf\n");\r
-                       fprintf(fp, "\t\t setle %s\n",SetWhat);\r
-                       fprintf(fp, "\t\t neg   byte %s\n",SetWhat);\r
-                       break;\r
-       }\r
-}\r
-\r
-\r
-/**********************************************************************/\r
-/* Instructions - Each routine generates a range of instruction codes */\r
-/**********************************************************************/\r
-\r
-/*\r
- * Immediate Commands\r
- *\r
- * ORI 00xx\r
- * ANDI        02xx\r
- * SUBI        04xx\r
- * ADDI        06xx\r
- * EORI        0axx\r
- * CMPI        0cxx\r
- *\r
- */\r
-\r
-void dump_imm( int type, int leng, int mode, int sreg )\r
-{\r
-       int Opcode,BaseCode ;\r
-       char Size=' ' ;\r
-       char * RegnameEBX="" ;\r
-       char * Regname="" ;\r
-       char * OpcodeName[16] = {"or ", "and", "sub", "add",0,"xor","cmp",0} ;\r
-       int allow[] = {1,0,1,1, 1,1,1,1, 1,0,0,0, 0,0,0,0, 0,0,0,1, 1} ;\r
-\r
-       Opcode = (type << 9) | ( leng << 6 ) | ( mode << 3 ) | sreg;\r
-\r
-       BaseCode = Opcode & 0xfff8;\r
-\r
-       if (mode == 7) BaseCode |= sreg ;\r
-\r
-#ifdef A7ROUTINE\r
-       if ((leng == 0) && (sreg == 7) && (mode > 2) && (mode < 5))\r
-       {\r
-               BaseCode |= sreg ;\r
-       }\r
-#endif\r
-\r
-       if (type != 4)  /* Not Valid (for this routine) */\r
-       {\r
-               int Dest = EAtoAMN(Opcode, FALSE);\r
-               int SetX;\r
-\r
-               /* ADDI & SUBI also set X flag */\r
-\r
-               SetX = ((type == 2) || (type == 3));\r
-\r
-               switch (leng)\r
-               {\r
-                       case 0:\r
-                               Size = 'B';\r
-                               Regname = regnamesshort[0];\r
-                               RegnameEBX = regnamesshort[EBX];\r
-                               break;\r
-                       case 1:\r
-                               Size = 'W';\r
-                               Regname = regnamesword[0];\r
-                               RegnameEBX = regnamesword[EBX];\r
-                               break;\r
-                       case 2:\r
-                               Size = 'L';\r
-                               Regname = regnameslong[0];\r
-                               RegnameEBX = regnameslong[EBX];\r
-                               break;\r
-               }\r
-\r
-               if (allow[Dest])\r
-               {\r
-                       if (OpcodeArray[BaseCode] == -2)\r
-                       {\r
-                               Align();\r
-                               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                               /* Save Previous PC if Memory Access */\r
-\r
-                               if ((Dest >= 2) && (Dest <=10))\r
-                                       SavePreviousPC();\r
-\r
-                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                               if (mode < 2)\r
-                               {\r
-                                       if (Size != 'L')\r
-                                               TimingCycles += (CPU==2) ? 4 : 8;\r
-                                       else\r
-                                       {\r
-                                               TimingCycles += (CPU==2) ? 8 : 14;\r
-                                               if ((type != 1) && (type!=6))\r
-                                                       TimingCycles += 2 ;\r
-                                       }\r
-                               }\r
-                               else\r
-                               {\r
-                                       if (type != 6)\r
-                                       {\r
-                                               if (Size != 'L')\r
-                                                       TimingCycles += (CPU==2) ? 4 : 12 ;\r
-                                               else\r
-                                                       TimingCycles += (CPU==2) ? 4 : 20 ;\r
-                                       }\r
-                                       else\r
-                                       {\r
-                                               if (Size != 'L')\r
-                                                       TimingCycles += (CPU==2) ? 4 : 8 ;\r
-                                               else\r
-                                                       TimingCycles += (CPU==2) ? 4 : 12 ;\r
-                                       }\r
-                               }\r
-\r
-                               fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-\r
-                               /* Immediate Mode Data */\r
-                               EffectiveAddressRead(11,Size,EBX,EBX,"--C-S-B",FALSE);\r
-\r
-                               /* Source Data */\r
-                               EffectiveAddressRead(Dest,Size,ECX,EAX,"-BC-SDB",FALSE);\r
-\r
-                               /* The actual work */\r
-                               fprintf(fp, "\t\t %s   %s,%s\n", OpcodeName[type], Regname, RegnameEBX );\r
-\r
-                               SetFlags(Size,EAX,FALSE,SetX,TRUE);\r
-\r
-                               if (type != 6) /* CMP no update */\r
-                                       EffectiveAddressWrite(Dest,Size,ECX,EAX,"---DS-B",FALSE);\r
-\r
-                               Completed();\r
-                       }\r
-               }\r
-               else\r
-               {\r
-                       /* Logicals are allowed to alter SR/CCR */\r
-\r
-                       if ((!SetX) && (Dest == 11) && (Size != 'L') && (type != 6))\r
-                       {\r
-                               Align();\r
-\r
-                               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-                               TimingCycles += 20 ;\r
-\r
-                               if (Size=='W')\r
-                               {\r
-                                       /* If SR then must be in Supervisor Mode */\r
-\r
-                                       char *Label = GenerateLabel(0,1);\r
-\r
-                                       fprintf(fp, "\t\t test  byte [%s],20h \t\t\t; Supervisor Mode ?\n",REG_SRH);\r
-                                       fprintf(fp, "\t\t jne   near %s\n\n",Label);\r
-\r
-                                       /* User Mode - Exception */\r
-\r
-                                       Exception(8,BaseCode);\r
-\r
-                                       fprintf(fp, "%s:\n",Label);\r
-                               }\r
-\r
-                               /* Immediate Mode Data */\r
-                               EffectiveAddressRead(11,Size,EBX,EBX,"---DS-B",TRUE);\r
-\r
-                               ReadCCR(Size,ECX);\r
-\r
-                               fprintf(fp, "\t\t %s   %s,%s\n", OpcodeName[type], Regname, RegnameEBX );\r
-\r
-                               WriteCCR(Size);\r
-\r
-                               Completed();\r
-                       }\r
-                       else\r
-                       {\r
-\r
-                               /* Illegal Opcode */\r
-\r
-                               OpcodeArray[BaseCode] = -1;\r
-                               BaseCode = -1;\r
-                       }\r
-               }\r
-       }\r
-       else\r
-       {\r
-               BaseCode = -2;\r
-       }\r
-\r
-       OpcodeArray[Opcode] = BaseCode;\r
-}\r
-\r
-void immediate(void)\r
-{\r
-       int type, size, mode, sreg ;\r
-\r
-       for (type = 0 ; type < 0x7; type++)\r
-               for (size = 0 ; size < 3 ; size++)\r
-                       for (mode = 0 ; mode < 8 ; mode++)\r
-                               for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                                       dump_imm( type, size, mode, sreg ) ;\r
-}\r
-\r
-\r
-/*\r
- * Bitwise Codes\r
- *\r
- */\r
-\r
-void dump_bit_dynamic( int sreg, int type, int mode, int dreg )\r
-{\r
-       int  Opcode, BaseCode ;\r
-       char Size ;\r
-       char *EAXReg,*ECXReg, *Label ;\r
-       char allow[] = "0-2345678-------" ;\r
-       int Dest ;\r
-\r
-       /* BTST allows x(PC) and x(PC,xr.s) - others do not */\r
-\r
-       if (type == 0)\r
-       {\r
-               allow[9]  = '9';\r
-               allow[10] = 'a';\r
-               allow[11] = 'b'; // dave fix to nhl\r
-       }\r
-\r
-       Opcode = 0x0100 | (sreg << 9) | (type<<6) | (mode<<3) | dreg ;\r
-\r
-       BaseCode = Opcode & 0x01f8 ;\r
-       if (mode == 7) BaseCode |= dreg ;\r
-\r
-\r
-       // A7+, A7-\r
-\r
-#ifdef  A7ROUTINE\r
-       if ((mode > 2) && (mode < 5))\r
-       {\r
-               if (dreg == 7) BaseCode |= dreg;\r
-       }\r
-#endif\r
-\r
-       Dest = EAtoAMN(Opcode, FALSE);\r
-\r
-       if (allow[Dest&0xf] != '-')\r
-       {\r
-               if (mode == 0) /* long*/\r
-               {\r
-                       /* Modify register memory directly */\r
-\r
-                       Size = 'L' ;\r
-                       EAXReg = REG_DAT_EBX;\r
-                       ECXReg = regnameslong[ECX];\r
-               }\r
-               else\r
-               {\r
-                       Size = 'B' ;\r
-                       EAXReg = regnamesshort[EAX];\r
-                       ECXReg = regnamesshort[ECX];\r
-               }\r
-\r
-               if (OpcodeArray[BaseCode] == -2)\r
-               {\r
-                       Align();\r
-                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                       /* Save Previous PC if Memory Access */\r
-\r
-                       if ((Dest >= 2) && (Dest <=10))\r
-                               SavePreviousPC();\r
-\r
-                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                       if (mode<2)\r
-                       {\r
-                               switch (type)\r
-                               {\r
-                                       case 0:\r
-                                               TimingCycles += 6 ;\r
-                                               break;\r
-                                       case 1:\r
-                                       case 3:\r
-                                               TimingCycles += 8 ;\r
-                                               break;\r
-                                       case 2:\r
-                                               TimingCycles += 10;\r
-                                               break;\r
-                               }\r
-                       }\r
-                       else\r
-                       {\r
-                               if (type==0)\r
-                                       TimingCycles += 4;\r
-                               else\r
-                                       TimingCycles += 8;\r
-                       }\r
-\r
-                       /* Only need this sorted out if a register is involved */\r
-\r
-                       if (Dest < 7)\r
-                       {\r
-                               fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-                               fprintf(fp, "\t\t and   ebx,byte 7\n");\r
-                       }\r
-\r
-                       /* Get bit number and create mask in ECX */\r
-\r
-                       fprintf(fp, "\t\t shr   ecx, byte 9\n");\r
-                       fprintf(fp, "\t\t and   ecx, byte 7\n");\r
-                       fprintf(fp, "\t\t mov   ecx, [%s+ECX*4]\n",REG_DAT);\r
-\r
-                       if (Size == 'L')\r
-                               fprintf(fp, "\t\t and   ecx, byte 31\n");\r
-                       else\r
-                               fprintf(fp, "\t\t and   ecx, byte 7\n");\r
-\r
-                #ifdef QUICKZERO\r
-                       fprintf(fp,"\t\t mov   eax,1\n");\r
-                #else\r
-                               fprintf(fp,"\t\t xor   eax,eax\n");\r
-                               fprintf(fp,"\t\t inc   eax\n");\r
-                #endif\r
-\r
-                       fprintf(fp,"\t\t shl   eax,cl\n");\r
-                       fprintf(fp,"\t\t mov   ecx,eax\n");\r
-\r
-                       if (mode != 0)\r
-                               EffectiveAddressRead(Dest,Size,EBX,EAX,"-BCDSDB",TRUE);\r
-\r
-\r
-                       /* All commands copy existing bit to Zero Flag */\r
-\r
-                       Label = GenerateLabel(0,1);\r
-\r
-                       fprintf(fp,"\t\t or    edx,byte 40h\t; Set Zero Flag\n");\r
-                       fprintf(fp,"\t\t test  %s,%s\n",EAXReg,ECXReg);\r
-                       fprintf(fp,"\t\t jz    short %s\n",Label);\r
-                       fprintf(fp,"\t\t xor   edx,byte 40h\t; Clear Zero Flag\n");\r
-                       fprintf(fp,"%s:\n",Label);\r
-\r
-                       /* Some then modify the data */\r
-\r
-                       switch (type)\r
-                       {\r
-                               case 0: /* btst*/\r
-                                       break;\r
-\r
-                               case 1: /* bchg*/\r
-                                       fprintf(fp,"\t\t xor   %s,%s\n",EAXReg,ECXReg);\r
-                                       break;\r
-\r
-                               case 2: /* bclr*/\r
-                                       fprintf(fp,"\t\t not   ecx\n");\r
-                                       fprintf(fp,"\t\t and   %s,%s\n",EAXReg,ECXReg);\r
-                                       break;\r
-\r
-                               case 3: /* bset*/\r
-                                       fprintf(fp,"\t\t or    %s,%s\n",EAXReg,ECXReg);\r
-                                       break;\r
-                       }\r
-\r
-                       if ((mode !=0) && (type != 0))\r
-                               EffectiveAddressWrite(Dest,Size,EBX,FALSE,"---DS-B",TRUE);\r
-\r
-                       Completed();\r
-               }\r
-\r
-               OpcodeArray[Opcode] = BaseCode ;\r
-       }\r
-}\r
-\r
-void bitdynamic(void) /* dynamic non-immediate bit operations*/\r
-{\r
-       int type, sreg, mode, dreg ;\r
-\r
-       for (sreg = 0 ; sreg < 8 ; sreg++)\r
-               for (type = 0 ; type < 4 ; type++)\r
-                       for (mode = 0 ; mode < 8 ;mode++)\r
-                               for (dreg = 0 ; dreg < 8 ;dreg++)\r
-                                       dump_bit_dynamic( sreg, type, mode, dreg ) ;\r
-}\r
-\r
-void dump_bit_static(int type, int mode, int dreg )\r
-{\r
-       int  Opcode, BaseCode ;\r
-       char Size ;\r
-       char *EAXReg,*ECXReg, *Label ;\r
-       char allow[] = "0-2345678-------" ;\r
-       int Dest ;\r
-\r
-       /* BTST allows x(PC) and x(PC,xr.s) - others do not */\r
-\r
-       if (type == 0)\r
-       {\r
-               allow[9] = '9';\r
-               allow[10] = 'a';\r
-       }\r
-\r
-       Opcode = 0x0800 | (type<<6) | (mode<<3) | dreg ;\r
-       BaseCode = Opcode & 0x08f8 ;\r
-       if (mode == 7) BaseCode |= dreg ;\r
-\r
-       // A7+, A7-\r
-\r
-#ifdef  A7ROUTINE\r
-       if ((mode > 2) && (mode < 5))\r
-       {\r
-               if (dreg == 7) BaseCode |= dreg;\r
-       }\r
-#endif\r
-\r
-       Dest = EAtoAMN(Opcode, FALSE);\r
-\r
-       if (allow[Dest&0xf] != '-')\r
-       {\r
-               if (mode == 0) /* long*/\r
-               {\r
-                       /* Modify register memory directly */\r
-\r
-                       Size = 'L' ;\r
-                       EAXReg = REG_DAT_EBX;\r
-                       ECXReg = regnameslong[ECX];\r
-               }\r
-               else\r
-               {\r
-                       Size = 'B' ;\r
-                       EAXReg = regnamesshort[EAX];\r
-                       ECXReg = regnamesshort[ECX];\r
-               }\r
-\r
-               if (OpcodeArray[BaseCode] == -2)\r
-               {\r
-                       Align();\r
-                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                       /* Save Previous PC if Memory Access */\r
-\r
-                       if ((Dest >= 2) && (Dest <=10))\r
-                               SavePreviousPC();\r
-\r
-                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                       if (mode<2)\r
-                       {\r
-                               switch (type)\r
-                               {\r
-                                       case 0:\r
-                                               TimingCycles += 10 ;\r
-                                               break ;\r
-                                       case 1:\r
-                                       case 3:\r
-                                               TimingCycles += 12 ;\r
-                                               break ;\r
-                                       case 2:\r
-                                               TimingCycles += 14 ;\r
-                                               break ;\r
-                               }\r
-                       }\r
-                       else\r
-                       {\r
-                               if (type != 0)\r
-                                       TimingCycles += 12 ;\r
-                               else\r
-                                       TimingCycles += 8 ;\r
-                       }\r
-\r
-                       /* Only need this sorted out if a register is involved */\r
-\r
-                       if (Dest < 7)\r
-                       {\r
-                               fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-                               fprintf(fp, "\t\t and   ebx, byte 7\n");\r
-                       }\r
-\r
-                       /* Get bit number and create mask in ECX */\r
-\r
-                       Memory_Fetch('W',ECX,FALSE);\r
-                       fprintf(fp, "\t\t add   esi,byte 2\n");\r
-\r
-                       if (Size == 'L')\r
-                               fprintf(fp, "\t\t and   ecx, byte 31\n");\r
-                       else\r
-                               fprintf(fp, "\t\t and   ecx, byte 7\n");\r
-\r
-                #ifdef QUICKZERO\r
-                       fprintf(fp,"\t\t mov   eax,1\n");\r
-                #else\r
-                               fprintf(fp,"\t\t xor   eax,eax\n");\r
-                               fprintf(fp,"\t\t inc   eax\n");\r
-                #endif\r
-\r
-                       fprintf(fp,"\t\t shl   eax,cl\n");\r
-                       fprintf(fp,"\t\t mov   ecx,eax\n");\r
-\r
-                       if (mode != 0)\r
-                               EffectiveAddressRead(Dest,Size,EBX,EAX,"-BCDSDB",TRUE);\r
-\r
-                       /* All commands copy existing bit to Zero Flag */\r
-\r
-                       Label = GenerateLabel(0,1);\r
-\r
-                       fprintf(fp,"\t\t or    edx,byte 40h\t; Set Zero Flag\n");\r
-                       fprintf(fp,"\t\t test  %s,%s\n",EAXReg,ECXReg);\r
-                       fprintf(fp,"\t\t jz    short %s\n",Label);\r
-                       fprintf(fp,"\t\t xor   edx,byte 40h\t; Clear Zero Flag\n");\r
-                       fprintf(fp,"%s:\n",Label);\r
-\r
-                       /* Some then modify the data */\r
-\r
-                       switch (type)\r
-                       {\r
-                               case 0: /* btst*/\r
-                                       break;\r
-\r
-                               case 1: /* bchg*/\r
-                                       fprintf(fp,"\t\t xor   %s,%s\n",EAXReg,ECXReg);\r
-                                       break;\r
-\r
-                               case 2: /* bclr*/\r
-                                       fprintf(fp,"\t\t not   ecx\n");\r
-                                       fprintf(fp,"\t\t and   %s,%s\n",EAXReg,ECXReg);\r
-                                       break;\r
-\r
-                               case 3: /* bset*/\r
-                                       fprintf(fp,"\t\t or    %s,%s\n",EAXReg,ECXReg);\r
-                                       break;\r
-                       }\r
-\r
-                       if ((mode !=0) && (type != 0))\r
-                               EffectiveAddressWrite(Dest,Size,EBX,FALSE,"---DS-B",TRUE);\r
-\r
-                       Completed();\r
-               }\r
-\r
-               OpcodeArray[Opcode] = BaseCode ;\r
-       }\r
-}\r
-\r
-\r
-void bitstatic(void) /* static non-immediate bit operations*/\r
-{\r
-       int type, mode, dreg ;\r
-\r
-       for (type = 0 ; type < 4 ; type++)\r
-               for (mode = 0 ; mode < 8 ;mode++)\r
-                       for (dreg = 0 ; dreg < 8 ;dreg++)\r
-                               dump_bit_static( type, mode, dreg ) ;\r
-}\r
-\r
-/*\r
- * Move Peripheral\r
- *\r
- */\r
-\r
-void movep(void)\r
-{\r
-       int sreg,dir,leng,dreg ;\r
-       int     Opcode, BaseCode ;\r
-\r
-       for (sreg = 0 ; sreg < 8 ; sreg++)\r
-       {\r
-               for (dir = 0 ; dir < 2 ; dir++)\r
-               {\r
-                       for (leng = 0 ; leng < 2 ; leng++)\r
-                       {\r
-                               for (dreg = 0 ; dreg < 8 ; dreg++)\r
-                               {\r
-                                       Opcode = 0x0108 | (sreg<<9) | (dir<<7) | (leng<<6) | dreg;\r
-                                       BaseCode = Opcode & 0x01c8 ;\r
-                                       if (OpcodeArray[BaseCode] == -2)\r
-                                       {\r
-                                               Align();\r
-                                               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-                                               SavePreviousPC();\r
-                                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                               if (leng == 0) /* word */\r
-                                                       TimingCycles += 16 ;\r
-                                               else\r
-                                                       TimingCycles += 24 ;\r
-\r
-                                               /* Save Flags Register (so we only do it once) */\r
-\r
-                                               fprintf(fp, "\t\t push  edx\n");\r
-\r
-                                               fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-                                               fprintf(fp, "\t\t and   ebx,byte 7\n");\r
-\r
-                                               /* Get Address to Read/Write in EDI */\r
-\r
-                                               EffectiveAddressCalculate(5,'L',EBX,FALSE);\r
-\r
-                                               fprintf(fp, "\t\t shr   ecx,byte 9\n");\r
-                                               fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-\r
-\r
-                                               if (dir == 0) /* from memory to register*/\r
-                                               {\r
-                                                       Memory_Read('B',EDI,"-BC-SDB",2);               /* mask first call */\r
-                                                       fprintf(fp,"\t\t mov   bh,al\n");\r
-                                                       fprintf(fp,"\t\t add   edi,byte 2\n");\r
-                                                       Memory_Read('B',EDI,"-BC-SDB",0);               /* not needed then */\r
-                                                       fprintf(fp,"\t\t mov   bl,al\n");\r
-\r
-                                                       if (leng == 0) /* word d(Ax) into Dx.W*/\r
-                                                       {\r
-                                                               fprintf(fp,"\t\t mov   [%s+ecx*4],bx\n",REG_DAT);\r
-                                                       }\r
-                                                       else /* long d(Ax) into Dx.L*/\r
-                                                       {\r
-                                                               fprintf(fp,"\t\t add   edi,byte 2\n");\r
-                                                               fprintf(fp,"\t\t shl   ebx,16\n");\r
-                                                               Memory_Read('B',EDI,"-BC-SDB",0);\r
-                                                               fprintf(fp,"\t\t mov   bh,al\n");\r
-                                                               fprintf(fp,"\t\t add   edi,byte 2\n");\r
-                                                               Memory_Read('B',EDI,"-BC-S-B",0);\r
-                                                               fprintf(fp,"\t\t mov   bl,al\n");\r
-                                                               fprintf(fp,"\t\t mov   [%s+ecx*4],ebx\n",REG_DAT);\r
-                                                       }\r
-                                               }\r
-                                               else /* Register to Memory*/\r
-                                               {\r
-                                                       fprintf(fp,"\t\t mov   eax,[%s+ecx*4]\n",REG_DAT);\r
-\r
-                                                       /* Move bytes into Line */\r
-\r
-                                                       if (leng == 1)\r
-                                                               fprintf(fp,"\t\t rol   eax,byte 8\n");\r
-                                                       else\r
-                                                               fprintf(fp,"\t\t rol   eax,byte 24\n");\r
-\r
-                                                       Memory_Write('B',EDI,EAX,"A---SDB",2); /* Mask First */\r
-                                                       fprintf(fp,"\t\t add   edi,byte 2\n");\r
-                                                       fprintf(fp,"\t\t rol   eax,byte 8\n");\r
-\r
-                                                       if (leng == 1) /* long*/\r
-                                                       {\r
-                                                               Memory_Write('B',EDI,EAX,"A---SDB",0);\r
-                                                               fprintf(fp,"\t\t add   edi,byte 2\n");\r
-                                                               fprintf(fp,"\t\t rol   eax,byte 8\n");\r
-                                                               Memory_Write('B',EDI,EAX,"A---SDB",0);\r
-                                                               fprintf(fp,"\t\t add   edi,byte 2\n");\r
-                                                               fprintf(fp,"\t\t rol   eax,byte 8\n");\r
-                                                       }\r
-                                                       Memory_Write('B',EDI,EAX,"A---S-B",0);\r
-                                               }\r
-\r
-                                               fprintf(fp, "\t\t pop   edx\n");\r
-                                               Completed();\r
-                                       }\r
-\r
-                                       OpcodeArray[Opcode] = BaseCode ;\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-}\r
-\r
-void movecodes(int allowfrom[],int allowto[],int Start,char Size) /* MJC */\r
-{\r
-       int Opcode;\r
-       int Src,Dest;\r
-       int SaveEDX;\r
-       int BaseCode;\r
-\r
-       for (Opcode=Start;Opcode<Start+0x1000;Opcode++)\r
-       {\r
-               /* Mask our Registers */\r
-\r
-               BaseCode = Opcode & (Start + 0x1f8);\r
-\r
-               /* Unless Mode = 7 */\r
-\r
-               if ((BaseCode & 0x38)  == 0x38)  BaseCode |= (Opcode & 7);\r
-               if ((BaseCode & 0x1c0) == 0x1c0) BaseCode |= (Opcode & 0xE00);\r
-\r
-               /* If mode = 3 or 4 and Size = byte and register = A7 */\r
-               /* then make it a separate code                                                   */\r
-\r
-#ifdef  A7ROUTINE\r
-               if (Size == 'B')\r
-               {\r
-                       if (((Opcode & 0x3F) == 0x1F) || ((Opcode & 0x3F) == 0x27))\r
-                       {\r
-                               BaseCode |= 0x07;\r
-                       }\r
-\r
-                       if (((Opcode & 0xFC0) == 0xEC0) || ((Opcode & 0xFC0) == 0xF00))\r
-                       {\r
-                               BaseCode |= 0x0E00;\r
-                       }\r
-               }\r
-#endif\r
-\r
-               /* If Source = Data or Address register - combine into same routine */\r
-\r
-               if (((Opcode & 0x38) == 0x08) && (allowfrom[1]))\r
-               {\r
-                       BaseCode &= 0xfff7;\r
-               }\r
-\r
-               if (OpcodeArray[BaseCode] == -2)\r
-               {\r
-                       Src  = EAtoAMN(Opcode, FALSE);\r
-                       Dest = EAtoAMN(Opcode >> 6, TRUE);\r
-\r
-                       if ((allowfrom[(Src & 15)]) && (allowto[(Dest & 15)]))\r
-                       {\r
-                               /* If we are not going to calculate the flags */\r
-                               /* we need to preserve the existing ones                */\r
-\r
-                               SaveEDX = (Dest == 1);\r
-\r
-                               Align();\r
-                               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                               if (((Src >= 2) && (Src <= 10)) || ((Dest >= 2) && (Dest <=10)))\r
-                                       SavePreviousPC();\r
-\r
-                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-\r
-                               TimingCycles += 4 ;\r
-\r
-                               if (Src < 7)\r
-                               {\r
-                                       if (Dest < 7)\r
-                                       {\r
-                                               fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-\r
-                                               if ((Src == 0) && allowfrom[1])\r
-                                                       fprintf(fp, "\t\t and   ebx,byte 15\n");\r
-                                               else\r
-                                                       fprintf(fp, "\t\t and   ebx,byte 7\n");\r
-\r
-                                               EffectiveAddressRead(Src,Size,EBX,EAX,"--CDS-B",SaveEDX);\r
-                                       }\r
-                                       else\r
-                                       {\r
-                                               if ((Src == 0) && allowfrom[1])\r
-                                                       fprintf(fp, "\t\t and   ecx,byte 15\n");\r
-                                               else\r
-                                                       fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-\r
-                                               EffectiveAddressRead(Src,Size,ECX,EAX,"---DS-B",SaveEDX);\r
-                                       }\r
-                               }\r
-                               else\r
-                               {\r
-                                       if (Dest < 7)\r
-                                               EffectiveAddressRead(Src,Size,EBX,EAX,"--CDS-B",SaveEDX);\r
-                                       else\r
-                                               EffectiveAddressRead(Src,Size,EBX,EAX,"---DS-B",SaveEDX);\r
-                               }\r
-\r
-                               /* No flags if Destination Ax */\r
-\r
-                               if (!SaveEDX)\r
-                               {\r
-                                       SetFlags(Size,EAX,TRUE,FALSE,TRUE);\r
-                               }\r
-\r
-                               if (Dest < 7)\r
-                               {\r
-                                       fprintf(fp, "\t\t shr   ecx,9\n");\r
-                                       fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                               }\r
-\r
-                               EffectiveAddressWrite(Dest,Size,ECX,TRUE,"---DS-B",SaveEDX);\r
-\r
-                               Completed();\r
-                       }\r
-                       else\r
-                       {\r
-                               BaseCode = -1; /* Invalid Code */\r
-                       }\r
-               }\r
-               else\r
-               {\r
-                       BaseCode = OpcodeArray[BaseCode];\r
-               }\r
-\r
-               if (OpcodeArray[Opcode] < 0)\r
-                       OpcodeArray[Opcode] = BaseCode;\r
-       }\r
-}\r
-\r
-void moveinstructions(void)\r
-{\r
-       int allowfrom[] = {1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0};\r
-       int allowto[]   = {1,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0};\r
-\r
-       /* For Byte */\r
-\r
-       movecodes(allowfrom,allowto,0x1000,'B');\r
-\r
-       /* For Word & Long */\r
-\r
-       allowto[1] = 1;\r
-       movecodes(allowfrom,allowto,0x2000,'L');\r
-       movecodes(allowfrom,allowto,0x3000,'W');\r
-}\r
-\r
-/*\r
- *\r
- * Opcodes 5###\r
- *\r
- * ADDQ,SUBQ,Scc and DBcc\r
- *\r
- */\r
-\r
-void opcode5(void)\r
-{\r
-       /* ADDQ,SUBQ,Scc and DBcc */\r
-\r
-       int allowtoScc[]        = {1,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0};\r
-       int allowtoADDQ[]  = {1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0};\r
-       int Opcode,BaseCode;\r
-       char Label[32];\r
-       char Label2[32];\r
-       char Size=' ';\r
-       char* Regname="";\r
-       char* RegnameECX="";\r
-\r
-       for (Opcode = 0x5000;Opcode < 0x6000;Opcode++)\r
-       {\r
-               if ((Opcode & 0xc0) == 0xc0)\r
-               {\r
-                       /* Scc or DBcc */\r
-\r
-                       BaseCode = Opcode & 0x5FF8;\r
-                       if ((BaseCode & 0x38) == 0x38) BaseCode |= (Opcode & 7);\r
-\r
-                       /* If mode = 3 or 4 and register = A7 */\r
-                       /* then make it a separate code          */\r
-\r
-#ifdef  A7ROUTINE\r
-                       if (((Opcode & 0x3F) == 0x1F) || ((Opcode & 0x3F) == 0x27))\r
-                       {\r
-                               BaseCode |= 0x07;\r
-                       }\r
-#endif\r
-\r
-                       if (OpcodeArray[BaseCode] == -2)\r
-                       {\r
-                               OpcodeArray[BaseCode] = BaseCode;\r
-\r
-                               if ((BaseCode & 0x38) == 0x8)\r
-                               {\r
-                                       /* DBcc */\r
-\r
-                                       Align();\r
-                                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                                       TimingCycles += 10 ;\r
-\r
-\r
-                                       strcpy(Label,GenerateLabel(BaseCode,1)) ;\r
-                                       strcpy(Label2,ConditionDecode((Opcode >> 8) & 0x0F,TRUE));\r
-\r
-                                       /* False - Decrement Counter - Loop if not -1 */\r
-\r
-                                       fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                                       fprintf(fp, "\t\t mov   ax,[%s+ecx*4]\n",REG_DAT);\r
-                                       fprintf(fp, "\t\t dec   ax\n");\r
-                                       fprintf(fp, "\t\t mov   [%s+ecx*4],ax\n",REG_DAT);\r
-                                       fprintf(fp, "\t\t inc   ax\t\t; Is it -1\n");\r
-                                       fprintf(fp, "\t\t jz    short %s\n",Label);\r
-\r
-                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-                                       Memory_Fetch('W',EAX,TRUE);\r
-                                       fprintf(fp, "\t\t add   esi,eax\n");\r
-                                       Completed();\r
-\r
-                                       /* True - Exit Loop */\r
-                                       fprintf(fp, "%s:\n",Label);\r
-\r
-                                       fprintf(fp, "%s:\n",Label2);\r
-                                       fprintf(fp, "\t\t add   esi,byte 4\n");\r
-                                       TimingCycles += 2 ;\r
-\r
-                                       Completed();\r
-                               }\r
-                               else\r
-                               {\r
-                                       /* Scc */\r
-\r
-                                       int  Dest = EAtoAMN(Opcode, FALSE);\r
-\r
-                                       if (allowtoScc[(Dest & 15)])\r
-                                       {\r
-                                               Align();\r
-                                               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                                               if ((Dest >= 2) && (Dest <=10))\r
-                                                       SavePreviousPC();\r
-\r
-                                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                               if (Dest > 1)\r
-                                                       TimingCycles += 8 ;\r
-                                               else\r
-                                                       TimingCycles += 4 ;\r
-\r
-                                               if (Dest < 7)\r
-                                               {\r
-                                                       fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                                               }\r
-\r
-                                               if (Dest > 1)\r
-                                               {\r
-                                                       EffectiveAddressCalculate(Dest,'B',ECX,TRUE);\r
-       /* ASG - no longer need to mask addresses here */\r
-/*                                                     fprintf(fp,"\t\t and   edi,0FFFFFFh\n");*/\r
-                                               }\r
-\r
-                                               ConditionCheck((Opcode >> 8) & 0x0F,"AL");\r
-\r
-                                               EffectiveAddressWrite(Dest,'B',ECX,FALSE,"---DS-B",TRUE);\r
-\r
-                                               /* take advantage of AL being 0 for false, 0xff for true */\r
-                                               /* need to add 2 cycles if register and condition is true */\r
-\r
-                                               if (Dest == 0)\r
-                                               {\r
-                                                       fprintf(fp, "\t\t and   eax,byte 2\n");\r
-                                                       fprintf(fp, "\t\t add   eax,byte %d\n",TimingCycles);\r
-                                                       fprintf(fp, "\t\t sub   dword [%s],eax\n",ICOUNT);\r
-\r
-                                                       TimingCycles = -1;\r
-                                               }\r
-                                               Completed();\r
-                                       }\r
-                                       else\r
-                                       {\r
-                                               OpcodeArray[BaseCode] = -1;\r
-                                               BaseCode = -1;\r
-                                       }\r
-                               }\r
-                       }\r
-                       else\r
-                       {\r
-                               BaseCode = OpcodeArray[BaseCode];\r
-                       }\r
-\r
-                       OpcodeArray[Opcode] = BaseCode;\r
-               }\r
-               else\r
-               {\r
-                       /* ADDQ or SUBQ */\r
-\r
-                       BaseCode = Opcode & 0x51F8;\r
-                       if ((BaseCode & 0x38) == 0x38) BaseCode |= (Opcode & 7);\r
-\r
-                       /* Special for Address Register Direct - Force LONG */\r
-\r
-                       if ((Opcode & 0x38) == 0x8) BaseCode = ((BaseCode & 0xFF3F) | 0x80);\r
-\r
-\r
-                       /* If mode = 3 or 4 and Size = byte and register = A7 */\r
-                       /* then make it a separate code                                                   */\r
-\r
-#ifdef  A7ROUTINE\r
-                       if ((Opcode & 0xC0) == 0)\r
-                       {\r
-                               if (((Opcode & 0x3F) == 0x1F) || ((Opcode & 0x3F) == 0x27))\r
-                               {\r
-                                       BaseCode |= 0x07;\r
-                               }\r
-                       }\r
-#endif\r
-\r
-                       if (OpcodeArray[BaseCode] == -2)\r
-                       {\r
-                               char *Operation;\r
-                               int Dest = EAtoAMN(Opcode, FALSE);\r
-                               int SaveEDX = (Dest == 1);\r
-\r
-                               if (allowtoADDQ[(Dest & 15)])\r
-                               {\r
-                                       switch (BaseCode & 0xC0)\r
-                                       {\r
-                                               case 0:\r
-                                                       Size = 'B';\r
-                                                       Regname = regnamesshort[0];\r
-                                                       RegnameECX = regnamesshort[ECX];\r
-                                                       break;\r
-\r
-                                               case 0x40:\r
-                                                       Size = 'W';\r
-                                                       Regname = regnamesword[0];\r
-                                                       RegnameECX = regnamesword[ECX];\r
-                                                       break;\r
-\r
-                                               case 0x80:\r
-                                                       Size = 'L';\r
-                                                       Regname = regnameslong[0];\r
-                                                       RegnameECX = regnameslong[ECX];\r
-                                                       break;\r
-                                       }\r
-\r
-                                       OpcodeArray[BaseCode] = BaseCode;\r
-\r
-                                       Align();\r
-                                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                                       if ((Dest >= 2) && (Dest <=10))\r
-                                               SavePreviousPC();\r
-\r
-                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                       if (Dest == 0) /* write to Dx */\r
-                                       {\r
-                                               if (Size != 'L')\r
-                                                       TimingCycles += 4 ;\r
-                                               else\r
-                                                       TimingCycles += 8 ;\r
-                                       }\r
-\r
-                                       if (Dest == 1)\r
-                                       {\r
-                                               if ((Size == 'L') || (Opcode & 0x100)) /* if long or SUBQ */\r
-                                                       TimingCycles += 8 ;\r
-                                               else\r
-                                                       TimingCycles += 4 ;\r
-                                       }\r
-\r
-                                       if (Dest > 1) /* write to mem */\r
-                                       {\r
-                                               if (Size != 'L')\r
-                                                       TimingCycles += 8 ;\r
-                                               else\r
-                                                       TimingCycles += 12 ;\r
-                                       }\r
-\r
-                                       if (Dest < 7)\r
-                                       {\r
-                                               fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-                                               fprintf(fp, "\t\t and   ebx,byte 7\n");\r
-                                       }\r
-\r
-                                       if (Dest > 1)\r
-                                       {\r
-                                               EffectiveAddressRead(Dest,Size,EBX,EAX,"-BCDSDB",SaveEDX);\r
-                                       }\r
-\r
-                                       /* Sub Immediate from Opcode */\r
-\r
-                                       fprintf(fp, "\t\t shr   ecx,9\n");\r
-\r
-                                       Immediate8();\r
-\r
-                                       if (Opcode & 0x100)\r
-                                       {\r
-                                               /* SUBQ */\r
-                                               Operation = "sub";\r
-                                       }\r
-                                       else\r
-                                       {\r
-                                               /* ADDQ */\r
-                                               Operation = "add";\r
-                                       }\r
-\r
-                                       /* For Data or Address register, operate directly */\r
-                                       /* on the memory location. Don't load into EAX   */\r
-\r
-                                       if (Dest < 2)\r
-                                       {\r
-                                               if (Dest == 0)\r
-                                               {\r
-                                                       fprintf(fp, "\t\t %s   [%s+ebx*4],%s\n",Operation,REG_DAT,RegnameECX);\r
-                                               }\r
-                                               else\r
-                                               {\r
-                                                       fprintf(fp, "\t\t %s   [%s+ebx*4],%s\n",Operation,REG_ADD,RegnameECX);\r
-                                               }\r
-                                       }\r
-                                       else\r
-                                       {\r
-                                               fprintf(fp, "\t\t %s   %s,%s\n",Operation,Regname,RegnameECX);\r
-                                       }\r
-\r
-                                       /* No Flags for Address Direct */\r
-\r
-                                       if (!SaveEDX)\r
-                                       {\r
-                                               /* Directly after ADD or SUB, so test not needed */\r
-\r
-                                               SetFlags(Size,EAX,FALSE,TRUE,TRUE);\r
-                                       }\r
-\r
-                                       if (Dest > 1)\r
-                                       {\r
-                                               EffectiveAddressWrite(Dest,Size,EBX,FALSE,"---DS-B",FALSE);\r
-                                       }\r
-\r
-                                       Completed();\r
-                               }\r
-                               else\r
-                               {\r
-                                       OpcodeArray[BaseCode] = -1;\r
-                                       BaseCode = -1;\r
-                               }\r
-                       }\r
-                       else\r
-                       {\r
-                               BaseCode = OpcodeArray[BaseCode];\r
-                       }\r
-\r
-                       OpcodeArray[Opcode] = BaseCode;\r
-               }\r
-       }\r
-}\r
-\r
-/*\r
- * Branch Instructions\r
- *\r
- * BSR, Bcc\r
- *\r
- */\r
-\r
-void branchinstructions(void)\r
-{\r
-       int Opcode,BaseCode;\r
-       int Counter;\r
-       char *Label;\r
-       char jmpLabel[40] ;\r
-\r
-       for (Opcode = 0x60;Opcode < 0x70;Opcode++)\r
-       {\r
-               /* Displacement = 0 -> 16 Bit displacement */\r
-\r
-               BaseCode = Opcode * 0x100;\r
-               OpcodeArray[BaseCode] = BaseCode;\r
-\r
-               Align();\r
-               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-               TimingCycles += 10 ;\r
-\r
-               if (Opcode == 0x60)\r
-               {\r
-                       Memory_Fetch('W',EAX,TRUE);\r
-                       fprintf(fp, "\t\t add   esi,eax\n");\r
-                       MemoryBanking(BaseCode);\r
-                       Completed();\r
-               }\r
-               else\r
-               {\r
-                       if (Opcode != 0x61)\r
-                       {\r
-                               Label = ConditionDecode(Opcode & 0x0F,TRUE);\r
-\r
-                               /* Code for Failed branch */\r
-\r
-                               fprintf(fp, "\t\t add   esi,byte 2\n");\r
-\r
-                               /* 2 less cycles for Failure */\r
-\r
-                               TimingCycles -= 2;\r
-                               Completed();\r
-                               TimingCycles += 2;\r
-\r
-                               /* Successful Branch */\r
-\r
-                               Align();\r
-                               fprintf(fp, "%s:\n",Label);\r
-\r
-                               Memory_Fetch('W',EAX,TRUE);\r
-                               fprintf(fp, "\t\t add   esi,eax\n");\r
-                               MemoryBanking(BaseCode+2);\r
-                               Completed();\r
-\r
-                       }\r
-                       else\r
-                       {\r
-                               /* BSR - Special Case */\r
-\r
-                               TimingCycles += 8 ;\r
-\r
-                               Memory_Fetch('W',EBX,TRUE);\r
-                               fprintf(fp, "\t\t add   ebx,esi\n");\r
-\r
-                               fprintf(fp, "\t\t add   esi,byte 2\n");\r
-                               PushPC(ECX,EAX,"-B-DS-B",1);\r
-\r
-                               fprintf(fp, "\t\t mov   esi,ebx\n");\r
-                               MemoryBanking(BaseCode+3);\r
-                               Completed();\r
-                       }\r
-               }\r
-\r
-               /* 8 Bit Displacement */\r
-\r
-               Align();\r
-               fprintf(fp, "%s:\n",GenerateLabel(BaseCode+1,0));\r
-               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-               TimingCycles += 10 ;\r
-\r
-               if (Opcode > 0x60)\r
-               {\r
-                       if (Opcode != 0x61)\r
-                       {\r
-                               Label = ConditionDecode(Opcode & 0x0F,TRUE);\r
-\r
-                               /* Code for Failed branch */\r
-\r
-                               TimingCycles -= 2;\r
-                               Completed();\r
-                               TimingCycles += 2;\r
-\r
-                               /* Successful Branch */\r
-\r
-                               Align();\r
-                               fprintf(fp, "%s:\n",Label);\r
-                       }\r
-                       else\r
-                       {\r
-                               /* BSR - Special Case */\r
-\r
-                               TimingCycles += 8 ;\r
-\r
-                               PushPC(EDI,EBX,"--CDS-B",1);\r
-                       }\r
-               }\r
-\r
-               /* Common Ending */\r
-\r
-               fprintf(fp, "\t\t movsx eax,cl               ; Sign Extend displacement\n");\r
-               fprintf(fp, "\t\t add   esi,eax\n");\r
-               MemoryBanking(BaseCode+5);\r
-               Completed();\r
-\r
-               /* Fill up Opcode Array */\r
-\r
-               for (Counter=1;Counter<0x100;Counter++)\r
-                       OpcodeArray[BaseCode+Counter] = BaseCode+1;\r
-\r
-               if(CPU==2)\r
-               {\r
-\r
-                       /* 8 bit 0xff & 68020 instruction - 32 bit displacement */\r
-\r
-                 Align();\r
-                 fprintf(fp, "%s:\n",GenerateLabel(BaseCode+0xff,0));\r
-                 sprintf( jmpLabel, GenerateLabel(BaseCode+0xff,1) ) ;\r
-                 fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                 TimingCycles += 10 ;\r
-\r
-                 if (Opcode == 0x60)\r
-                 {\r
-                         /* bra - always branch */\r
-                         Memory_Fetch('L',EAX,FALSE);\r
-                         fprintf(fp, "\t\t add   esi,eax\n");\r
-                         MemoryBanking(BaseCode+6);\r
-                         Completed();\r
-                 }\r
-                 else\r
-                 {\r
-                         if (Opcode != 0x61)\r
-                         {\r
-                                 Label = ConditionDecode(Opcode & 0x0F,TRUE);\r
-\r
-                                 /* Code for Failed branch */\r
-                                 fprintf(fp, "\t\t add   esi,byte 4\n");\r
-\r
-                                 TimingCycles -= 2;\r
-                                 Completed();\r
-                                 TimingCycles += 2;\r
-\r
-                                 /* Successful Branch */\r
-                                 Align();\r
-                                 fprintf(fp, "%s:\n",Label);\r
-\r
-                                 Memory_Fetch('L',EAX,FALSE);\r
-                                 fprintf(fp, "\t\t add   esi,eax\n");\r
-                                 MemoryBanking(BaseCode+8);\r
-                                 Completed();\r
-                         }\r
-                         else\r
-                         {\r
-                                 /* BSR - Special Case */\r
-\r
-                                 TimingCycles += 8 ;\r
-\r
-                                 Memory_Fetch('L',EBX,TRUE);\r
-                                 fprintf(fp, "\t\t add   ebx,esi\n");\r
-\r
-                                 fprintf(fp, "\t\t add   esi,byte 4\n");\r
-                                 PushPC(ECX,EAX,"-B-DS-B",1);\r
-\r
-                                 fprintf(fp, "\t\t mov   esi,ebx\n");\r
-                                 MemoryBanking(BaseCode+9);\r
-                                 Completed();\r
-                         }\r
-                 }\r
-\r
-                 OpcodeArray[BaseCode+0xff] = BaseCode+0xff;\r
-               }\r
-       }\r
-}\r
-\r
-/*\r
- * Move Quick Commands\r
- *\r
- * Fairly simple, as only allowed to Data Registers\r
- *\r
- */\r
-\r
-void moveq(void)\r
-{\r
-       int Count;\r
-\r
-       /* The Code */\r
-\r
-       Align();\r
-       fprintf(fp, "%s:\n",GenerateLabel(0x7000,0));\r
-       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-       TimingCycles += 4 ;\r
-\r
-       fprintf(fp, "\t\t movsx eax,cl\n");\r
-       fprintf(fp, "\t\t shr   ecx,9\n");\r
-       fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-       SetFlags('L',EAX,TRUE,FALSE,FALSE);\r
-       EffectiveAddressWrite(0,'L',ECX,TRUE,"---DS-B",FALSE);\r
-       Completed();\r
-\r
-       /* Set OpcodeArray (Not strictly correct, since some are illegal!) */\r
-\r
-       for (Count=0x7000;Count<0x8000;Count++)\r
-       {\r
-               OpcodeArray[Count] = 0x7000;\r
-       }\r
-}\r
-\r
-/*\r
- * Extended version of Add & Sub commands\r
- *\r
- */\r
-\r
-void addx_subx(void)\r
-{\r
-       int     Opcode, BaseCode ;\r
-       int     regx,type,leng,rm,regy,mode ;\r
-       int ModeModX;\r
-       int ModeModY;\r
-       char  Size=' ' ;\r
-       char * Regname="" ;\r
-       char * RegnameEBX="" ;\r
-       char * Operand="";\r
-       char * Label;\r
-\r
-       for (type = 0 ; type < 2 ; type ++) /* 0=subx, 1=addx */\r
-               for (regx = 0 ; regx < 8 ; regx++)\r
-                       for (leng = 0 ; leng < 3 ; leng++)\r
-                               for (rm = 0 ; rm < 2 ; rm++)\r
-                                       for (regy = 0 ; regy < 8 ; regy++)\r
-                                       {\r
-                                               Opcode = 0x9100 | (type<<14) | (regx<<9) | (leng<<6) | (rm<<3) | regy ;\r
-\r
-                                               BaseCode = Opcode & 0xd1c8 ;\r
-\r
-                                               ModeModX = 0;\r
-                                               ModeModY = 0;\r
-\r
-#ifdef A7ROUTINE\r
-                                               if ((rm == 1) && (leng == 0))\r
-                                               {\r
-                                                       if (regx == 7)\r
-                                                       {\r
-                                                               BaseCode |= (regx << 9);\r
-                                                               ModeModY = 16;\r
-                                                       }\r
-                                                       if (regy == 7)\r
-                                                       {\r
-                                                               BaseCode |= regy;\r
-                                                               ModeModX = 16;\r
-                                                       }\r
-                                               }\r
-#endif\r
-\r
-                                               if (rm == 0)\r
-                                                       mode = 0 ;\r
-                                               else\r
-                                                       mode = 4 ;\r
-\r
-                                               switch (leng)\r
-                                               {\r
-                                                       case 0:\r
-                                                               Size = 'B';\r
-                                                               Regname = regnamesshort[0];\r
-                                                               RegnameEBX = regnamesshort[EBX];\r
-                                                               break;\r
-                                                       case 1:\r
-                                                               Size = 'W';\r
-                                                               Regname = regnamesword[0];\r
-                                                               RegnameEBX = regnamesword[EBX];\r
-                                                               break;\r
-                                                       case 2:\r
-                                                               Size = 'L';\r
-                                                               Regname = regnameslong[0];\r
-                                                               RegnameEBX = regnameslong[EBX];\r
-                                                               break;\r
-                                               }\r
-\r
-                                               if (OpcodeArray[BaseCode] == -2)\r
-                                               {\r
-                                                       if (type == 0)\r
-                                                               Operand = "sbb";\r
-                                                       else\r
-                                                               Operand = "adc";\r
-\r
-                                                       Align();\r
-                                                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                                                       if (mode == 4)\r
-                                                               SavePreviousPC();\r
-\r
-                                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                                       /* don't add in EA timing for ADDX,SUBX */\r
-\r
-                                                       AddEACycles = 0 ;\r
-\r
-                                                       if (rm == 0) /* reg to reg */\r
-                                                       {\r
-                                                               if (Size != 'L')\r
-                                                                       TimingCycles += 4 ;\r
-                                                               else\r
-                                                                       TimingCycles += 8 ;\r
-                                                       }\r
-                                                       else\r
-                                                       {\r
-                                                               if (Size != 'L')\r
-                                                                       TimingCycles += 18 ;\r
-                                                               else\r
-                                                                       TimingCycles += 30 ;\r
-                                                       }\r
-\r
-                                                       fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-                                                       fprintf(fp, "\t\t and   ebx, byte 7\n");\r
-                                                       fprintf(fp, "\t\t shr   ecx, byte 9\n");\r
-                                                       fprintf(fp, "\t\t and   ecx, byte 7\n");\r
-\r
-                                                       /* Get Source */\r
-\r
-                                                       EffectiveAddressRead(mode+ModeModX,Size,EBX,EBX,"--CDS-B",FALSE);\r
-\r
-                                                       /* Get Destination (if needed) */\r
-\r
-                                                       if (mode == 4)\r
-                                                               EffectiveAddressRead(mode+ModeModY,Size,ECX,EAX,"-BCDSDB",FALSE);\r
-\r
-                                                       /* Copy the X flag into the Carry Flag */\r
-\r
-                                                       CopyX();\r
-\r
-                                                       /* Do the sums */\r
-\r
-                                                       if (mode == 0)\r
-                                                               fprintf(fp, "\t\t %s   [%s+ecx*4],%s\n",Operand,REG_DAT,RegnameEBX);\r
-                                                       else\r
-                                                               fprintf(fp, "\t\t %s   %s,%s\n",Operand,Regname,RegnameEBX);\r
-\r
-                                                       /* Preserve old Z flag */\r
-\r
-                                                       fprintf(fp, "\t\t mov   ebx,edx\n");\r
-\r
-                                                       /* Set the Flags */\r
-\r
-                                                       SetFlags(Size,EAX,FALSE,TRUE,FALSE);\r
-\r
-                                                       /* Handle the Z flag */\r
-\r
-                                                       Label = GenerateLabel(0,1);\r
-\r
-                                                       fprintf(fp, "\t\t jnz   short %s\n\n",Label);\r
-\r
-                                                       fprintf(fp, "\t\t and   dl,0BFh       ; Remove Z\n");\r
-                                                       fprintf(fp, "\t\t and   bl,40h        ; Mask out Old Z\n");\r
-                                                       fprintf(fp, "\t\t or    dl,bl         ; Copy across\n\n");\r
-                                                       fprintf(fp, "%s:\n",Label);\r
-\r
-                                                       /* Update the Data (if needed) */\r
-\r
-                                                       if (mode == 4)\r
-                                                               EffectiveAddressWrite(mode,Size,ECX,FALSE,"---DS-B",TRUE);\r
-\r
-                                                       Completed();\r
-                                               }\r
-\r
-                                               OpcodeArray[Opcode] = BaseCode ;\r
-                                       }\r
-}\r
-\r
-/*\r
- * Logicals / Simple Maths (+ and -)\r
- *\r
- * OR,AND,CMP,EOR,ADD and SUB\r
- *\r
- */\r
-\r
-void dumpx( int start, int reg, int type, char * Op, int dir, int leng, int mode, int sreg )\r
-{\r
-       int Opcode,BaseCode ;\r
-       char Size=' ' ;\r
-       char * RegnameECX="" ;\r
-       char * Regname="" ;\r
-       int Dest ;\r
-       int SaveEDX ;\r
-       int SaveDir;\r
-       char * allow="" ;\r
-       char * allowtypes[] = { "0-23456789ab----", "--2345678-------",\r
-               "0123456789ab----", "0-2345678-------"};\r
-\r
-       SaveDir = dir;\r
-\r
-       switch (type)\r
-       {\r
-               case 0: /* or and*/\r
-                       if (dir == 0)\r
-                               allow = allowtypes[0];\r
-                       else\r
-                               allow = allowtypes[1];\r
-                       break ;\r
-\r
-               case 1: /* cmp*/\r
-                       allow = allowtypes[2] ;\r
-                       break ;\r
-\r
-               case 2: /* eor*/\r
-                       allow = allowtypes[3] ;\r
-                       break ;\r
-\r
-               case 3: /* adda suba cmpa*/\r
-                       allow = allowtypes[2] ;\r
-                       break ;\r
-\r
-               case 4: /* sub add*/\r
-                       if (dir == 0)\r
-                               allow = allowtypes[0] ;\r
-                       else\r
-                               allow = allowtypes[1] ;\r
-                       break ;\r
-       }\r
-\r
-       if ((type == 4) && (dir == 0) && (leng > 0))\r
-       {\r
-               allow = allowtypes[2] ; /* word and long ok*/\r
-       }\r
-\r
-       Opcode = start | (reg << 9 ) | (dir<<8) | (leng<<6) | (mode<<3) | sreg;\r
-\r
-       BaseCode = Opcode & 0xf1f8;\r
-\r
-       if (mode == 7) BaseCode |= sreg ;\r
-\r
-#ifdef A7ROUTINE\r
-       if ((mode == 3 || mode == 4) && ( leng == 0 ) && (sreg == 7 ))\r
-               BaseCode |= sreg ;\r
-#endif\r
-\r
-\r
-\r
-       /* If Source = Data or Address register - combine into same routine */\r
-\r
-       if (((Opcode & 0x38) == 0x08) && (allow[1] != '-'))\r
-       {\r
-               BaseCode &= 0xfff7;\r
-       }\r
-\r
-       Dest = EAtoAMN(Opcode, FALSE);\r
-       SaveEDX = (Dest == 1) || (type == 3);\r
-\r
-       if (allow[Dest&0xf] != '-')\r
-       {\r
-               if (OpcodeArray[BaseCode] == -2)\r
-               {\r
-                       switch (leng)\r
-                       {\r
-                               case 0:\r
-                                       Size = 'B';\r
-                                       Regname = regnamesshort[0];\r
-                                       RegnameECX = regnamesshort[ECX];\r
-                                       break;\r
-                               case 1:\r
-                                       Size = 'W';\r
-                                       Regname = regnamesword[0];\r
-                                       RegnameECX = regnamesword[ECX];\r
-                                       break;\r
-                               case 2:\r
-                                       Size = 'L';\r
-                                       Regname = regnameslong[0];\r
-                                       RegnameECX = regnameslong[ECX];\r
-                                       break;\r
-\r
-                               case 3: /* cmpa adda suba */\r
-                                       if (dir == 0)\r
-                                       {\r
-                                               Size = 'W';\r
-                                               Regname = regnamesword[0];\r
-                                               RegnameECX = regnamesword[ECX];\r
-                                       }\r
-                                       else\r
-                                       {\r
-                                               Size = 'L';\r
-                                               Regname = regnameslong[0];\r
-                                               RegnameECX = regnameslong[ECX];\r
-                                       }\r
-                                       dir = 0 ;\r
-                                       break ;\r
-                       }\r
-\r
-                       Align();\r
-                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                       if ((Dest >= 2) && (Dest <=10))\r
-                               SavePreviousPC();\r
-\r
-                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                       if (dir==0)\r
-                       {\r
-                               if (Size != 'L')\r
-                                       TimingCycles += 4;\r
-                               else\r
-                                       TimingCycles += 6;\r
-                       }\r
-                       else\r
-                       {\r
-                               if (Size != 'L')\r
-                                       TimingCycles += 8;\r
-                               else\r
-                                       TimingCycles += 12;\r
-                       }\r
-\r
-                       if ((mode == 0) && (dir==0) && (Size == 'L'))\r
-                               TimingCycles += 2 ;\r
-\r
-                       if ((mode == 1) && (dir==0) && (Size != 'L'))\r
-                               TimingCycles += 4 ;\r
-\r
-                       if (Dest < 7)    /* Others do not need reg.no. */\r
-                       {\r
-                               fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-\r
-                               if ((Dest == 0) & (allow[1] != '-'))\r
-                                       fprintf(fp, "\t\t and   ebx,byte 15\n");\r
-                               else\r
-                                       fprintf(fp, "\t\t and   ebx,byte 7\n");\r
-                       }\r
-\r
-                       fprintf(fp, "\t\t shr   ecx,byte 9\n");\r
-                       fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-\r
-                       EffectiveAddressRead(Dest,Size,EBX,EAX,"-BCDSDB",SaveEDX);\r
-\r
-                       if (dir == 0)\r
-                       {\r
-                               if (type != 3)\r
-                               {\r
-                                       fprintf(fp, "\t\t %s   [%s+ECX*4],%s\n",Op ,REG_DAT ,Regname ) ;\r
-\r
-                                       if (type == 4)\r
-                                               SetFlags(Size,EAX,FALSE,TRUE,FALSE);\r
-                                       else\r
-                                               SetFlags(Size,EAX,FALSE,FALSE,FALSE);\r
-                               }\r
-                               else\r
-                               {\r
-                                       if (Size == 'W')\r
-                                               fprintf(fp, "\t\t cwde\n");\r
-\r
-                                       fprintf(fp, "\t\t %s   [%s+ECX*4],EAX\n",Op ,REG_ADD);\r
-\r
-                                       if (Op[0] == 'c')\r
-                                       {\r
-                                               SetFlags('L',EAX,FALSE,FALSE,FALSE);\r
-                                       }\r
-                               }\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(fp, "\t\t %s   %s,[%s+ECX*4]\n", Op, Regname ,REG_DAT ) ;\r
-\r
-                               if (type == 4)\r
-                                       SetFlags(Size,EAX,FALSE,TRUE,TRUE);\r
-                               else\r
-                                       SetFlags(Size,EAX,FALSE,FALSE,TRUE);\r
-\r
-                               EffectiveAddressWrite(Dest,Size,EBX,FALSE,"---DS-B",FALSE);\r
-                       }\r
-                       Completed();\r
-               }\r
-\r
-               OpcodeArray[Opcode] = BaseCode;\r
-       }\r
-\r
-       dir = SaveDir;\r
-}\r
-\r
-void typelogicalmath(void)\r
-{\r
-       int dir, leng, mode, sreg ,reg ;\r
-\r
-       for (reg = 0 ; reg < 8 ; reg++)\r
-       {\r
-               /* or */\r
-               for (dir = 0 ; dir < 2 ; dir++)\r
-                       for (leng = 0 ; leng < 3; leng++)\r
-                               for (mode = 0 ; mode < 8 ; mode++)\r
-                                       for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                                               dumpx( 0x8000, reg, 0, "or ", dir, leng, mode, sreg ) ;\r
-\r
-               /* sub */\r
-               for (dir = 0 ; dir < 2 ; dir++)\r
-                       for (leng = 0 ; leng < 3; leng++)\r
-                               for (mode = 0 ; mode < 8 ; mode++)\r
-                                       for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                                               dumpx( 0x9000, reg, 4, "sub", dir, leng, mode, sreg ) ;\r
-\r
-               /* suba */\r
-\r
-               for (dir = 0 ; dir < 2 ; dir++)\r
-                       for (mode = 0 ; mode < 8 ; mode++)\r
-                               for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                                       dumpx( 0x9000, reg, 3, "sub", dir, 3, mode, sreg ) ;\r
-\r
-\r
-               /* cmp */\r
-               for (leng = 0 ; leng < 3; leng++)\r
-                       for (mode = 0 ; mode < 8 ; mode++)\r
-                               for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                                       dumpx( 0xb000, reg, 1, "cmp", 0, leng, mode, sreg ) ;\r
-\r
-               /* cmpa */\r
-\r
-               for (dir = 0 ; dir < 2 ; dir++)\r
-                       for (mode = 0 ; mode < 8 ; mode++)\r
-                               for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                                       dumpx( 0xb000, reg, 3, "cmp", dir, 3, mode, sreg ) ;\r
-\r
-               /* adda */\r
-\r
-               for (dir = 0 ; dir < 2 ; dir++)\r
-                       for (mode = 0 ; mode < 8 ; mode++)\r
-                               for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                                       dumpx( 0xd000, reg, 3, "add", dir, 3, mode, sreg ) ;\r
-\r
-\r
-               /* eor */\r
-               for (leng = 0 ; leng < 3; leng++)\r
-                       for (mode = 0 ; mode < 8 ; mode++)\r
-                               for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                                       dumpx( 0xb100, reg, 2, "xor", 1, leng, mode, sreg ) ;\r
-\r
-               /* and */\r
-               for (dir = 0 ; dir < 2 ; dir++)\r
-                       for (leng = 0 ; leng < 3; leng++)\r
-                               for (mode = 0 ; mode < 8 ; mode++)\r
-                                       for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                                               dumpx( 0xc000, reg, 0, "and", dir, leng, mode, sreg ) ;\r
-\r
-               /* add  */\r
-               for (dir = 0 ; dir < 2 ; dir++)\r
-                       for (leng = 0 ; leng < 3; leng++)\r
-                               for (mode = 0 ; mode < 8 ; mode++)\r
-                                       for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                                               dumpx( 0xd000, reg, 4, "add", dir, leng, mode, sreg ) ;\r
-       }\r
-}\r
-\r
-/*\r
- * Single commands missed out by routines above\r
- *\r
- */\r
-\r
-void mul(void)\r
-{\r
-       int dreg, type, mode, sreg ;\r
-       int Opcode, BaseCode ;\r
-       int Dest ;\r
-       char allow[] = "0-23456789ab-----" ;\r
-\r
-       for (dreg = 0 ; dreg < 8 ; dreg++)\r
-               for (type = 0 ; type < 2 ; type++)\r
-                       for (mode = 0 ; mode < 8 ; mode++)\r
-                               for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                               {\r
-                                       Opcode = 0xc0c0 | (dreg<<9) | (type<<8) | (mode<<3) | sreg ;\r
-                                       BaseCode = Opcode & 0xc1f8 ;\r
-                                       if (mode == 7)\r
-                                       {\r
-                                               BaseCode |= sreg ;\r
-                                       }\r
-\r
-                                       Dest = EAtoAMN(Opcode, FALSE);\r
-                                       if (allow[Dest&0x0f] != '-')\r
-                                       {\r
-                                               if (OpcodeArray[ BaseCode ] == -2)\r
-                                               {\r
-                                                       Align();\r
-                                                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                                                       if ((Dest >= 2) && (Dest <=10))\r
-                                                               SavePreviousPC();\r
-\r
-                                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                                       TimingCycles += 70 ;\r
-\r
-                                                       if (mode < 7)\r
-                                                       {\r
-                                                               fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-                                                               fprintf(fp, "\t\t and   ebx,byte 7\n");\r
-                                                       }\r
-\r
-                                                       fprintf(fp, "\t\t shr   ecx, byte 9\n");\r
-                                                       fprintf(fp, "\t\t and   ecx, byte 7\n");\r
-\r
-                                                       EffectiveAddressRead(Dest,'W',EBX,EAX,"ABCDSDB",FALSE);\r
-\r
-                                                       if (type == 0)\r
-                                                               fprintf(fp, "\t\t mul   word [%s+ECX*4]\n",REG_DAT);\r
-                                                       else\r
-                                                               fprintf(fp, "\t\t imul  word [%s+ECX*4]\n",REG_DAT);\r
-\r
-                                                       fprintf(fp, "\t\t shl   edx, byte 16\n");\r
-                                                       fprintf(fp, "\t\t mov   dx,ax\n");\r
-                                                       fprintf(fp, "\t\t mov   [%s+ECX*4],edx\n",REG_DAT);\r
-                                                       SetFlags('L',EDX,TRUE,FALSE,FALSE);\r
-                                                       Completed();\r
-                                               }\r
-\r
-                                               OpcodeArray[Opcode] = BaseCode ;\r
-                                       }\r
-                               }\r
-}\r
-\r
-void mull(void)\r
-{\r
-       int mode, sreg ;\r
-       int Opcode, BaseCode ;\r
-       int Dest ;\r
-       char allow[] = "0-23456789ab-----" ;\r
-       char *Label = NULL ;\r
-\r
-       for (mode = 0 ; mode < 8 ; mode++)\r
-               for (sreg = 0 ; sreg < 8 ; sreg++)\r
-               {\r
-                       Opcode = 0x4c00 | (mode<<3) | sreg ;\r
-                       BaseCode = Opcode & 0x4c38 ;\r
-                       if (mode == 7)\r
-                       {\r
-                               BaseCode |= sreg ;\r
-                       }\r
-\r
-                       Dest = EAtoAMN(Opcode, FALSE);\r
-                       if (allow[Dest&0x0f] != '-')\r
-                       {\r
-                               if (OpcodeArray[ BaseCode ] == -2)\r
-                               {\r
-                                       TimingCycles += 70 ;\r
-                                       Align();\r
-                                       Label = GenerateLabel(BaseCode,0);\r
-                                       fprintf(fp, "%s:\n",Label);\r
-                                       if ((Dest >= 2) && (Dest <=10))\r
-                                               SavePreviousPC();\r
-\r
-                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                       if (mode < 7)\r
-                                       {\r
-                                               fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                                       }\r
-\r
-                                       Memory_Fetch('W', EBX, FALSE );                                                 // fetch the next word\r
-                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                       EffectiveAddressRead(Dest,'L',ECX,EAX,"ABCDSDB",FALSE); // read from the EA\r
-\r
-                                       fprintf(fp, "\t\t mov   ecx,ebx\n");                                    // save 2nd word in ecx\r
-                                       fprintf(fp, "\t\t shr   ebx,12\n");                                             // ebx = Dl register\r
-                                       fprintf(fp, "\t\t and   ebx,7\n");                                              // 0-7\r
-\r
-                                       Label = GenerateLabel(BaseCode,1);\r
-\r
-                                       fprintf(fp, "\t\t test  ecx,0x0800\n");                                 // signed/unsigned?\r
-                                       fprintf(fp, "\t\t jz    short %s\n",Label);                             // skip if unsigned\r
-\r
-                                       fprintf(fp, "\t\t imul   dword [%s+EBX*4]\n",REG_DAT);  // signed 32x32->64\r
-                                       fprintf(fp, "\t\t jmp   short %s_1\n",Label);                   // skip\r
-\r
-                               fprintf(fp, "%s:\n",Label);\r
-                                       fprintf(fp, "\t\t mul  dword [%s+EBX*4]\n",REG_DAT);    // unsigned 32x32->64\r
-\r
-                               fprintf(fp, "%s_1:\n",Label);\r
-                                       fprintf(fp, "\t\t mov   [%s+EBX*4],eax\n",REG_DAT);             // store Dl back\r
-\r
-                                       fprintf(fp, "\t\t test  ecx,0x0400\n");                                 // do we care?\r
-                                       fprintf(fp, "\t\t jz    short %s_2\n",Label);                   // if not, skip\r
-                                       fprintf(fp, "\t\t and   ecx,7\n");                                              // get Dh register\r
-                                       fprintf(fp, "\t\t mov   [%s+ECX*4],edx\n",REG_DAT);             // store upper 32 bits\r
-                                       SetFlags('L',EDX,TRUE,FALSE,FALSE);                                             // set the flags\r
-                                       fprintf(fp, "\t\t and   edx,~0x0800\n");                                // clear the overflow\r
-                                       fprintf(fp, "\t\t jmp   short %s_3\n",Label);                   // skip\r
-\r
-                               fprintf(fp, "%s_2:\n",Label);\r
-                                       fprintf(fp, "\t\t mov   ebx,edx\n");                                    // save upper 32 in ebx\r
-                                       SetFlags('L',EAX,TRUE,FALSE,FALSE);                                             // set the flags\r
-                                       fprintf(fp, "\t\t sar   eax,31\n");                                             // eax = sign-extended\r
-                                       fprintf(fp, "\t\t test  ecx,0x0800\n");                                 // signed/unsigned?\r
-                                       fprintf(fp, "\t\t jnz   short %s_4\n",Label);                   // skip if signed\r
-                                       fprintf(fp, "\t\t xor   eax,eax\n");                                    // always use 0 for unsigned\r
-                               fprintf(fp, "%s_4:\n",Label);\r
-                                       fprintf(fp, "\t\t cmp   eax,ebx\n");                                    // compare upper 32 against eax\r
-                                       fprintf(fp, "\t\t je    short %s_3\n",Label);                   // if equal to sign extension, skip\r
-                                       fprintf(fp, "\t\t or    edx,0x0800\n");                                 // set the overflow\r
-\r
-                               fprintf(fp, "%s_3:\n",Label);\r
-                                       Completed();\r
-                               }\r
-\r
-                               OpcodeArray[Opcode] = BaseCode ;\r
-                       }\r
-               }\r
-}\r
-\r
-void divl(void)\r
-{\r
-       int mode, sreg ;\r
-       int Opcode, BaseCode ;\r
-       int Dest ;\r
-       char allow[] = "0-23456789ab-----" ;\r
-       char *Label = NULL ;\r
-\r
-       for (mode = 0 ; mode < 8 ; mode++)\r
-               for (sreg = 0 ; sreg < 8 ; sreg++)\r
-               {\r
-                       Opcode = 0x4c40 | (mode<<3) | sreg ;\r
-                       BaseCode = Opcode & 0x4c78 ;\r
-                       if (mode == 7)\r
-                       {\r
-                               BaseCode |= sreg ;\r
-                       }\r
-\r
-                       Dest = EAtoAMN(Opcode, FALSE);\r
-                       if (allow[Dest&0x0f] != '-')\r
-                       {\r
-                               if (OpcodeArray[ BaseCode ] == -2)\r
-                               {\r
-                                       TimingCycles += 70 ;\r
-                                       Align();\r
-                                       Label = GenerateLabel(BaseCode,0);\r
-                                       fprintf(fp, "%s:\n",Label);\r
-                                       if ((Dest >= 2) && (Dest <=10))\r
-                                               SavePreviousPC();\r
-\r
-                                       fprintf(fp, "\t\t push  edx\n");                                        // save edx\r
-                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-                                       fprintf(fp, "\t\t and   ecx,byte 7\n");                         // read from ea\r
-\r
-                                       Memory_Fetch('W', EDX, FALSE );                                         // fetch 2nd word in ecx\r
-                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                       EffectiveAddressRead(Dest,'L',ECX,EBX,"---DSDB",FALSE);\r
-\r
-                                       fprintf(fp, "\t\t push  esi\n");                                        // save and 0 esi\r
-                                       ClearRegister(ESI);\r
-\r
-                                       Label = GenerateLabel(BaseCode,1);\r
-\r
-                                       fprintf(fp, "\t\t test  ebx,ebx\n");                            // check divisor against 0\r
-                                       fprintf(fp, "\t\t jz    near %s_ZERO\n",Label);         // handle divide-by-zero\r
-// low part always used\r
-                                       fprintf(fp, "\t\t mov   ecx,edx\n");                            // ecx = extension word\r
-                                       fprintf(fp, "\t\t shr   edx,12\n");                                     // edx = Dq register\r
-                                       fprintf(fp, "\t\t and   edx,7\n");                                      // 0-7\r
-                                       fprintf(fp, "\t\t mov   eax,[%s+edx*4]\n",REG_DAT);     // eax = Dq register value\r
-\r
-                                       ClearRegister(EDX);                                                                     // edx = 0\r
-                                       fprintf(fp, "\t\t test  ecx,0x0400\n");                         // check size\r
-                                       fprintf(fp, "\t\t jz    short %s_1\n",Label);           // skip if 32-bit dividend\r
-// high longword (64bit)\r
-                                       fprintf(fp, "\t\t mov   edx,ecx\n");                            // edx = extension word\r
-                                       fprintf(fp, "\t\t and   edx,7\n");                                      // 0-7\r
-                                       fprintf(fp, "\t\t mov   edx,[%s+edx*4]\n",REG_DAT);     // fetch upper 32-bits\r
-\r
-                                       fprintf(fp, "\t\t test  ecx,0x0800\n");                         // signed?\r
-                                       fprintf(fp, "\t\t jz    near %s_3\n",Label);            // if not, skip to unsigned 64-bit\r
-                                       fprintf(fp, "\t\t jmp   near %s_2\n",Label);            // skip to signed 64-bit case\r
-\r
-                               fprintf(fp, "%s_1:\n",Label);                                                   // short case\r
-                                       ClearRegister(EDX);                                                                     // clear edx\r
-                                       fprintf(fp, "\t\t test  ecx,0x0800\n");                         // signed?\r
-                                       fprintf(fp, "\t\t jz    short %s_3\n",Label);           // if not, don't convert\r
-                                       fprintf(fp, "\t\t cdq\n");                                                      // sign extend into edx\r
-// signed\r
-                               fprintf(fp, "%s_2:\n",Label);                                                   // signed 32/64-bit case\r
-                                       fprintf(fp, "\t\t or    esi,1\n");                                      // esi |= 1 to indicate signed\r
-                                       fprintf(fp, "\t\t test  ebx,ebx\n");                            // check divisor sign\r
-                                       fprintf(fp, "\t\t jge   short %s_2b\n",Label);          // if >= 0, don't set\r
-                                       fprintf(fp, "\t\t or    esi,2\n");                                      // esi |= 2 to indicate negative divisor\r
-                                       fprintf(fp, "\t\t neg   ebx\n");                                        // make positive\r
-                               fprintf(fp, "%s_2b:\n",Label);\r
-                                       fprintf(fp, "\t\t test  edx,edx\n");                            // check dividend sign\r
-                                       fprintf(fp, "\t\t jge   short %s_3\n",Label);           // if >= 0, don't set\r
-                                       fprintf(fp, "\t\t push  ebx\n");                                        // save ebx\r
-                                       fprintf(fp, "\t\t push  ecx\n");                                        // save ecx\r
-                                       ClearRegister(EBX);                                                                     // clear ebx\r
-                                       ClearRegister(ECX);                                                                     // clear ecx\r
-                                       fprintf(fp, "\t\t sub   ebx,eax\n");                            // ebx = 0 - eax\r
-                                       fprintf(fp, "\t\t sbb   ecx,edx\n");                            // ecx = 0 - edx\r
-                                       fprintf(fp, "\t\t mov   eax,ebx\n");                            // eax = ebx\r
-                                       fprintf(fp, "\t\t mov   edx,ecx\n");                            // edx = ecx\r
-                                       fprintf(fp, "\t\t pop   ecx\n");                                        // restore ecx\r
-                                       fprintf(fp, "\t\t pop   ebx\n");                                        // restore ebx\r
-                                       fprintf(fp, "\t\t or    esi,4\n");                                      // esi |= 4 to indicate negative dividend\r
-// unsigned\r
-                               fprintf(fp, "%s_3:\n",Label);                                                   // unsigned 32/64-bit case\r
-                                       fprintf(fp, "\t\t cmp   ebx,edx\n");                            // check ebx against upper 32 bits\r
-                                       fprintf(fp, "\t\t jbe   near %s_OVERFLOW\n",Label);     // generate overflow\r
-                                       fprintf(fp, "\t\t div   ebx\n");                                        // do the divide\r
-                                       fprintf(fp, "\t\t test  esi,esi\n");                            // see if we need to post process\r
-                                       fprintf(fp, "\t\t jz    short %s_4\n",Label);           // if not, skip\r
-                                       fprintf(fp, "\t\t jpo   short %s_4\n",Label);           // if PO (pos*pos or neg*neg), leave the result\r
-                                       fprintf(fp, "\t\t neg   eax\n");                                        // negate the result\r
-\r
-// store results\r
-                               fprintf(fp, "%s_4:\n",Label);\r
-                                       fprintf(fp, "\t\t mov   ebx,ecx\n");                            // ebx = extension word\r
-                                       fprintf(fp, "\t\t and   ebx,7\n");                                      // get Dr in ebx\r
-                                       fprintf(fp, "\t\t shr   ecx,12\n");                                     // ecx = Dq\r
-                                       fprintf(fp, "\t\t and   ecx,7\n");                                      // 0-7\r
-                                       fprintf(fp, "\t\t mov   [%s+ebx*4],edx\n",REG_DAT);     // store remainder first\r
-                                       fprintf(fp, "\t\t mov   [%s+ecx*4],eax\n",REG_DAT);     // store quotient second\r
-                                       fprintf(fp, "\t\t pop   esi\n");                                        // restore esi\r
-                                       fprintf(fp, "\t\t pop   edx\n");                                        // restore edx\r
-                                       SetFlags('L',EAX,TRUE,FALSE,FALSE);                                     // set the flags\r
-                               fprintf(fp, "%s_5:\n",Label);\r
-                                       fprintf(fp, "\t\t and   edx,~1\n");                                     // clear the carry\r
-                                       Completed();\r
-\r
-                                       fprintf(fp, "%s_ZERO:\t\t ;Do divide by zero trap\n", Label);\r
-                                       /* Correct cycle counter for error */\r
-                                       fprintf(fp, "\t\t pop   esi\n");                                        // restore esi\r
-                                       fprintf(fp, "\t\t pop   edx\n");                                        // restore edx\r
-                                       fprintf(fp, "\t\t add   dword [%s],byte %d\n",ICOUNT,95);\r
-                               fprintf(fp,"\t\t jmp short %s_5\n",Label);\r
-                                       Exception(5,BaseCode);\r
-\r
-                               fprintf(fp, "%s_OVERFLOW:\n",Label);\r
-//set overflow\r
-                                       fprintf(fp, "\t\t pop   esi\n");                                        // restore esi\r
-                                       fprintf(fp, "\t\t pop   edx\n");                                        // restore edx\r
-                                       fprintf(fp, "\t\t or    edx,0x0800\n");                         // set the overflow bit\r
-                                       fprintf(fp, "\t\t jmp   near %s_5\n",Label);            // done\r
-\r
-                               }\r
-\r
-                               OpcodeArray[Opcode] = BaseCode ;\r
-                       }\r
-               }\r
-}\r
-\r
-void bfext(void)\r
-{\r
-// just bfextu/bfexts for now\r
-       char allow[] = "0-2--56789a-----" ;\r
-       char *Label = NULL ;\r
-       int mode,dreg,sign,Opcode,BaseCode,Dest ;\r
-       for (mode=0; mode<8; mode++)\r
-               for (dreg=0; dreg<8; dreg++)\r
-                       for (sign=0; sign<2; sign++)\r
-                       {\r
-                               Opcode = 0xe9c0 | (sign<<9) | (mode<<3) | dreg ;\r
-                               BaseCode = Opcode & 0xebf8 ;\r
-                               if (mode == 7)\r
-                                       BaseCode |= dreg ;\r
-                               Dest = EAtoAMN(Opcode, FALSE);\r
-                               if (allow[Dest&0xf] != '-')\r
-                               {\r
-                                       if (OpcodeArray[BaseCode] == -2)\r
-                                       {\r
-                                               Align();\r
-                                               Label = GenerateLabel(BaseCode,0);\r
-                                               fprintf(fp, "%s:\n",Label);\r
-                                               Label = GenerateLabel(BaseCode,1);\r
-                                               if ((Dest >= 2) && (Dest <=10))\r
-                                                       SavePreviousPC();\r
-\r
-                                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                               if (mode < 7)\r
-                                               {\r
-                                                       fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                                               }\r
-\r
-                                               Memory_Fetch('W', EAX, FALSE ) ;\r
-                                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                               EffectiveAddressRead(Dest,'L',ECX,EDX,"ABCDSDB",FALSE);         // edx = dword\r
-\r
-                                               fprintf(fp, "\t\t mov   ecx,eax\n");\r
-                                               fprintf(fp, "\t\t shr   ecx,byte 6\n");\r
-                                               fprintf(fp, "\t\t test  eax,0x0800\n");\r
-                                               fprintf(fp, "\t\t je    short %s_1\n",Label);\r
-       //get offset from Dx\r
-                                               fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                                               fprintf(fp, "\t\t mov   ecx,[%s+ECX*4]\n",REG_DAT);\r
-       //get offset from extension\r
-                                               fprintf(fp, "%s_1:\n",Label);\r
-                                               fprintf(fp, "\t\t and   ecx,31\n");                                                     // ecx = offset\r
-                                               fprintf(fp, "\t\t mov   ebx,eax\n");\r
-                                               fprintf(fp, "\t\t test  eax,0x0020\n");\r
-                                               fprintf(fp, "\t\t je    short %s_2\n",Label);\r
-       //get width from Dy\r
-                                               fprintf(fp, "\t\t and   ebx,byte 7\n");\r
-                                               fprintf(fp, "\t\t mov   ebx,[%s+EBX*4]\n",REG_DAT);\r
-       //get width from extension\r
-                                               fprintf(fp, "%s_2:\n",Label);\r
-       //fix 0=32\r
-                                               fprintf(fp, "\t\t sub   ebx,byte 1\n");\r
-                                               fprintf(fp, "\t\t and   ebx,byte 31\n");\r
-                                               fprintf(fp, "\t\t add   ebx,byte 1\n");                                         // ebx = width\r
-                                               fprintf(fp, "\t\t rol   edx,cl\n");\r
-       // check for N\r
-                                               fprintf(fp, "\t\t mov   ecx,32\n");\r
-                                               fprintf(fp, "\t\t sub   ecx,ebx\n");\r
-                                               fprintf(fp, "\t\t mov   ebx,edx\n");\r
-                                               SetFlags('L',EBX,TRUE,FALSE,FALSE);\r
-                                               if (sign)\r
-                                                       fprintf(fp, "\t\t sar   ebx,cl\n");\r
-                                               else\r
-                                                       fprintf(fp, "\t\t shr   ebx,cl\n");\r
-                                               fprintf(fp, "\t\t shr   eax,12\n");\r
-                                               fprintf(fp, "\t\t and   eax,7\n");\r
-                                               fprintf(fp, "\t\t mov   [%s+EAX*4],ebx\n",REG_DAT);\r
-                                               fprintf(fp, "\t\t test  ebx,ebx\n");\r
-                                               fprintf(fp, "\t\t jnz   short %s_3\n",Label);\r
-       //zero flag\r
-                                               fprintf(fp, "\t\t or    edx,40h\n");\r
-                                               fprintf(fp, "%s_3:\n",Label);\r
-                                               Completed();\r
-                                       }\r
-                                       OpcodeArray[Opcode] = BaseCode ;\r
-                               }\r
-                       }\r
-}\r
-\r
-/*\r
- * not\r
- * clr\r
- * neg\r
- * negx\r
- *\r
- */\r
-\r
-void not(void)\r
-{\r
-       int     type,leng, mode, sreg ;\r
-       int     Opcode, BaseCode ;\r
-       int     Dest ;\r
-       int SaveEDX=0;\r
-       char Size=' ' ;\r
-       char * Regname="" ;\r
-       char * RegnameECX ;\r
-       char * Label;\r
-\r
-       char allow[] = "0-2345678-------" ;\r
-\r
-       for (type = 0 ; type < 4 ; type++)\r
-               for (leng = 0 ; leng < 3 ; leng++)\r
-                       for (mode = 0 ; mode < 8 ; mode++)\r
-                               for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                               {\r
-                                       Opcode = 0x4000 | (type<<9) | (leng<<6) | (mode<<3) | sreg ;\r
-                                       BaseCode = Opcode & 0x46f8 ;\r
-                                       if (mode == 7)\r
-                                       {\r
-                                               BaseCode |= sreg ;\r
-                                       }\r
-\r
-                                       // A7+, A7-\r
-\r
-#ifdef  A7ROUTINE\r
-                                       if ((leng == 0) && (sreg == 7) && (mode > 2) && (mode < 5))\r
-                                       {\r
-                                               BaseCode |= sreg ;\r
-                                       }\r
-#endif\r
-\r
-                                       Dest = EAtoAMN(Opcode, FALSE);\r
-\r
-                                       if (allow[Dest&0x0f] != '-')\r
-                                       {\r
-                                               switch (leng)\r
-                                               {\r
-                                                       case 0:\r
-                                                               Size = 'B';\r
-                                                               Regname = regnamesshort[0];\r
-                                                               RegnameECX = regnamesshort[ECX];\r
-                                                               break;\r
-                                                       case 1:\r
-                                                               Size = 'W';\r
-                                                               Regname = regnamesword[0];\r
-                                                               RegnameECX = regnamesword[ECX];\r
-                                                               break;\r
-                                                       case 2:\r
-                                                               Size = 'L';\r
-                                                               Regname = regnameslong[0];\r
-                                                               RegnameECX = regnameslong[ECX];\r
-                                                               break;\r
-                                               }\r
-\r
-                                               if (OpcodeArray[ BaseCode ] == -2)\r
-                                               {\r
-                                                       Align();\r
-                                                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                                                       if ((Dest >= 2) && (Dest <=10))\r
-                                                               SavePreviousPC();\r
-\r
-                                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                                       if (Size != 'L')\r
-                                                               TimingCycles += 4;\r
-                                                       else\r
-                                                               TimingCycles += 6;\r
-\r
-                                                       if (Dest < 7)\r
-                                                               fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-\r
-                                                       if (type == 0) SaveEDX = TRUE;\r
-                                                       else SaveEDX = FALSE;\r
-\r
-                                                       /* CLR does not need to read source (although it does on a real 68000) */\r
-\r
-                                                       if (type != 1)\r
-                                                       {\r
-                                                               EffectiveAddressRead(Dest,Size,ECX,EAX,"A-CDS-B",SaveEDX);\r
-                                                       }\r
-\r
-                                                       switch (type)\r
-                                                       {\r
-                                                               case 0: /* negx */\r
-\r
-                                                                       /* Preserve old Z flag */\r
-\r
-                                                                       fprintf(fp, "\t\t mov   ebx,edx\n");\r
-\r
-                                                                       CopyX();\r
-                                                                       fprintf(fp, "\t\t adc   %s,byte 0\n", Regname ) ;\r
-                                                                       fprintf(fp, "\t\t neg   %s\n", Regname ) ;\r
-\r
-                                                                       /* Set the Flags */\r
-\r
-                                                                       SetFlags(Size,EAX,FALSE,TRUE,FALSE);\r
-\r
-                                                                       /* Handle the Z flag */\r
-\r
-                                                                       Label = GenerateLabel(0,1);\r
-\r
-                                                                       fprintf(fp, "\t\t jnz   short %s\n\n",Label);\r
-\r
-                                                                       fprintf(fp, "\t\t and   edx,byte -65  ; Remove Z\n");\r
-                                                                       fprintf(fp, "\t\t and   ebx,byte 40h  ; Mask out Old Z\n");\r
-                                                                       fprintf(fp, "\t\t or    edx,ebx       ; Copy across\n\n");\r
-                                                                       fprintf(fp, "%s:\n",Label);\r
-\r
-                                                                       break;\r
-\r
-                                                               case 1: /* clr */\r
-                                                                       ClearRegister(EAX);\r
-                                                                       EffectiveAddressWrite(Dest,Size,ECX,TRUE,"----S-B",FALSE);\r
-                                                                       fprintf(fp, "\t\t mov   edx,40H\n");\r
-                                                                       break;\r
-\r
-                                                               case 2: /* neg */\r
-                                                                       fprintf(fp, "\t\t neg   %s\n",Regname ) ;\r
-                                                                       SetFlags(Size,EAX,FALSE,TRUE,TRUE);\r
-                                                                       break;\r
-\r
-                                                               case 3: /* not */\r
-                                                                       fprintf(fp, "\t\t xor   %s,-1\n",Regname ) ;\r
-                                                                       SetFlags(Size,EAX,FALSE,FALSE,TRUE);\r
-                                                                       break;\r
-                                                       }\r
-\r
-                                                       /* Update (unless CLR command) */\r
-\r
-                                                       if (type != 1)\r
-                                                               EffectiveAddressWrite(Dest,Size,ECX,FALSE,"---DS-B",TRUE);\r
-\r
-                                                       Completed();\r
-                                               }\r
-\r
-                                               OpcodeArray[Opcode] = BaseCode ;\r
-                                       }\r
-                               }\r
-}\r
-\r
-/*\r
- * Move to/from USP\r
- *\r
- */\r
-\r
-void moveusp(void)\r
-{\r
-       int Opcode, BaseCode ;\r
-       int dir, sreg ;\r
-       char * Label;\r
-\r
-       for (dir = 0 ; dir < 2 ; dir++)\r
-               for (sreg = 0 ; sreg < 8 ; sreg++)\r
-               {\r
-                       Opcode = 0x4e60 | ( dir << 3 ) | sreg ;\r
-                       BaseCode = Opcode & 0x4e68 ;\r
-\r
-                       if (OpcodeArray[BaseCode] == -2)\r
-                       {\r
-                               Align();\r
-                               Label = GenerateLabel(BaseCode,0);\r
-                               fprintf(fp, "%s\n", Label );\r
-                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                               TimingCycles += 4;\r
-\r
-                               fprintf(fp, "\t\t test  byte [%s],20h \t\t\t; Supervisor Mode ?\n",REG_SRH);\r
-                               fprintf(fp, "\t\t jz    short OP%d_%4.4x_Trap\n",CPU,BaseCode);\r
-\r
-                               fprintf(fp, "\t\t and   ecx,7\n");\r
-\r
-                               if (dir == 0) /* reg 2 USP */\r
-                               {\r
-                                       fprintf(fp, "\t\t mov   eax,[%s+ECX*4]\n",REG_ADD);\r
-                                       fprintf(fp, "\t\t mov   [%s],eax\n",REG_USP);\r
-                               }\r
-                               else\r
-                               {\r
-                                       fprintf(fp, "\t\t mov   eax,[%s]\n",REG_USP);\r
-                                       fprintf(fp, "\t\t mov   [%s+ECX*4],eax\n",REG_ADD);\r
-                               }\r
-                               Completed();\r
-\r
-                               fprintf(fp, "OP%d_%4.4x_Trap:\n",CPU,BaseCode);\r
-                               Exception(8,BaseCode);\r
-                       }\r
-                       OpcodeArray[Opcode] = BaseCode ;\r
-               }\r
-}\r
-\r
-\r
-/*\r
- * Check\r
- *\r
- */\r
-\r
-void chk(void)\r
-{\r
-       int     dreg,mode,sreg,size ;\r
-       int     Opcode, BaseCode ;\r
-       int     Dest ;\r
-       char * Label ;\r
-\r
-       char  *allow = "0-23456789ab----" ;\r
-\r
-       for (size = 0 ; size < (CPU==2 ? 2 : 1); size++)\r
-               for (dreg = 0 ; dreg < 8; dreg++)\r
-                       for (mode = 0 ; mode < 8; mode++)\r
-                               for (sreg = 0 ; sreg < 8; sreg++)\r
-                               {\r
-                                       if (size == 0)  /* word */\r
-                                               Opcode = 0x4180 | (dreg<<9) | (mode<<3) | sreg ;\r
-                                 else                  /* long */\r
-                                               Opcode = 0x4100 | (dreg<<9) | (mode<<3) | sreg ;\r
-                                       BaseCode = Opcode & 0x41f8 ;\r
-\r
-                                       if (mode == 7)\r
-                                       {\r
-                                               BaseCode |= sreg ;\r
-                                       }\r
-\r
-                                       Dest = EAtoAMN(Opcode, FALSE);\r
-\r
-                                       if (allow[Dest&0xf] != '-')\r
-                                       {\r
-                                               if (OpcodeArray[BaseCode] == -2)\r
-                                               {\r
-                                                       Align();\r
-                                                       Label = GenerateLabel(BaseCode,0);\r
-                                                       fprintf(fp, "%s:\n", Label );\r
-                                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                                       TimingCycles += 10;\r
-\r
-                                                       fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-                                                       fprintf(fp, "\t\t shr   ebx,byte 9\n");\r
-                                                       fprintf(fp, "\t\t and   ebx,byte 7\n");\r
-\r
-                                                       if (Dest < 7)\r
-                                                               fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-\r
-                                                       EffectiveAddressRead(Dest,(size == 0) ? 'W' : 'L',ECX,EAX,"----S-B",FALSE);\r
-\r
-                                                       if (size == 0)  /* word */\r
-                                                       {\r
-                                                               fprintf(fp, "\t\t movsx ebx,word [%s+EBX*4]\n",REG_DAT);\r
-                                                               fprintf(fp, "\t\t movsx eax,ax\n");\r
-                                                       }\r
-                                                       else                    /* long */\r
-                                                               fprintf(fp, "\t\t mov   ebx,[%s+EBX*4]\n",REG_DAT);\r
-\r
-                                                       fprintf(fp, "\t\t test  ebx,ebx\n"); /* is word bx < 0 */\r
-                                                       fprintf(fp, "\t\t jl    near OP%d_%4.4x_Trap_minus\n",CPU,BaseCode);\r
-\r
-                                                       fprintf(fp, "\t\t cmp   ebx,eax\n");\r
-                                                       fprintf(fp, "\t\t jg    near OP%d_%4.4x_Trap_over\n",CPU,BaseCode);\r
-                                                       Completed();\r
-\r
-                                                       /* N is set if data less than zero */\r
-\r
-                                                       Align();\r
-                                                       fprintf(fp, "OP%d_%4.4x_Trap_minus:\n",CPU,BaseCode);\r
-                                                       fprintf(fp, "\t\t or    edx,0x0080\n");         /* N flag = 80H */\r
-                                                       fprintf(fp, "\t\t jmp   short OP%d_%4.4x_Trap_Exception\n",CPU,BaseCode);\r
-\r
-                                                       /* N is cleared if greated than compared number */\r
-\r
-                                                       Align();\r
-                                                       fprintf(fp, "OP%d_%4.4x_Trap_over:\n",CPU,BaseCode);\r
-                                                       fprintf(fp, "\t\t and   edx,0x007f\n");         /* N flag = 80H */\r
-\r
-                                                       fprintf(fp, "OP%d_%4.4x_Trap_Exception:\n",CPU,BaseCode);\r
-                                                       fprintf(fp, "\t\t mov   al,6\n");\r
-                                                       Exception(-1,0x10000+BaseCode);\r
-                                                       Completed();\r
-\r
-                                               }\r
-\r
-                                               OpcodeArray[Opcode] = BaseCode ;\r
-                                       }\r
-                               }\r
-}\r
-\r
-void chk2(void)\r
-{\r
-#if 0\r
-       int     mode,sreg,size ;\r
-       int     Opcode, BaseCode ;\r
-       int     Dest ;\r
-       char * Label ;\r
-\r
-       char  *allow = "--2--56789a-----" ;\r
-\r
-       for (size = 0 ; size < 2; size++)\r
-               for (mode = 0 ; mode < 8; mode++)\r
-                       for (sreg = 0 ; sreg < 8; sreg++)\r
-                       {\r
-                               Opcode = 0x00c0 | (size<<9) | (mode<<3) | sreg;\r
-                               BaseCode = Opcode & 0xfff8 ;\r
-\r
-                               if (mode == 7)\r
-                               {\r
-                                       BaseCode |= sreg ;\r
-                               }\r
-\r
-                               Dest = EAtoAMN(Opcode, FALSE);\r
-\r
-                               if (allow[Dest&0xf] != '-')\r
-                               {\r
-                                       if (OpcodeArray[BaseCode] == -2)\r
-                                       {\r
-                                               Align();\r
-                                               Label = GenerateLabel(BaseCode,0);\r
-                                               fprintf(fp, "%s:\n", Label );\r
-                                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                               TimingCycles += 10;\r
-\r
-                                               fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-                                               fprintf(fp, "\t\t shr   ebx,byte 9\n");\r
-                                               fprintf(fp, "\t\t and   ebx,byte 7\n");\r
-\r
-                                               if (Dest < 7)\r
-                                                       fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-\r
-                                               EffectiveAddressRead(Dest,'W',ECX,EAX,"----S-B",FALSE);\r
-\r
-                                               if (size == 0)  /* word */\r
-                                               {\r
-                                                       fprintf(fp, "\t\t movsx ebx,word [%s+EBX*4]\n",REG_DAT);\r
-                                                       fprintf(fp, "\t\t movsx eax,ax\n");\r
-                                                }\r
-                                                else                   /* long */\r
-                                                       fprintf(fp, "\t\t mov   ebx,[%s+EBX*4]\n",REG_DAT);\r
-\r
-                                               fprintf(fp, "\t\t test  ebx,ebx\n"); /* is word bx < 0 */\r
-                                               fprintf(fp, "\t\t jl    near OP%d_%4.4x_Trap_minus\n",CPU,BaseCode);\r
-\r
-                                               fprintf(fp, "\t\t cmp   ebx,eax\n");\r
-                                               fprintf(fp, "\t\t jg    near OP%d_%4.4x_Trap_over\n",CPU,BaseCode);\r
-                                               Completed();\r
-\r
-                                               /* N is set if data less than zero */\r
-\r
-                                               Align();\r
-                                               fprintf(fp, "OP%d_%4.4x_Trap_minus:\n",CPU,BaseCode);\r
-                                               fprintf(fp, "\t\t or    edx,0x0080\n");         /* N flag = 80H */\r
-                                               fprintf(fp, "\t\t jmp   short OP%d_%4.4x_Trap_Exception\n",CPU,BaseCode);\r
-\r
-                                               /* N is cleared if greated than compared number */\r
-\r
-                                               Align();\r
-                                               fprintf(fp, "OP%d_%4.4x_Trap_over:\n",CPU,BaseCode);\r
-                                               fprintf(fp, "\t\t and   edx,0x007f\n");         /* N flag = 80H */\r
-\r
-                                               fprintf(fp, "OP%d_%4.4x_Trap_Exception:\n",CPU,BaseCode);\r
-                                               fprintf(fp, "\t\t mov   al,6\n");\r
-                                               Exception(-1,0x10000+BaseCode);\r
-                                               Completed();\r
-\r
-                                       }\r
-\r
-                                       OpcodeArray[Opcode] = BaseCode ;\r
-                               }\r
-                       }\r
-#endif\r
-}\r
-\r
-/*\r
- * Load Effective Address\r
- */\r
-\r
-void LoadEffectiveAddress(void)\r
-{\r
-       int     Opcode, BaseCode ;\r
-       int     sreg,mode,dreg ;\r
-       int     Dest ;\r
-       char allow[] = "--2--56789a-----" ;\r
-\r
-       for (sreg = 0 ; sreg < 8 ; sreg++)\r
-               for (mode = 0 ; mode < 8 ; mode++)\r
-                       for (dreg = 0 ; dreg < 8 ; dreg++)\r
-                       {\r
-                               Opcode = 0x41c0 | (sreg<<9) | (mode<<3) | dreg ;\r
-\r
-                               BaseCode = Opcode & 0x41f8 ;\r
-\r
-                               if (mode == 7)\r
-                                       BaseCode = BaseCode | dreg ;\r
-\r
-                               Dest = EAtoAMN(BaseCode, FALSE);\r
-\r
-                               if (allow[Dest&0x0f] != '-')\r
-                               {\r
-                                       if (OpcodeArray[BaseCode] == -2)\r
-                                       {\r
-                                               Align();\r
-                                               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-                                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                               switch (mode)\r
-                                               {\r
-                                                       case 2:\r
-                                                               TimingCycles += 4;\r
-                                                               break;\r
-                                                       case 5:\r
-                                                       case 7:\r
-                                                       case 9:\r
-                                                               TimingCycles += 8;\r
-                                                               break;\r
-                                                       case 6:\r
-                                                       case 8:\r
-                                                       case 10:\r
-                                                               TimingCycles += 12;\r
-                                                               break;\r
-                                               }\r
-\r
-                                               if (mode < 7)\r
-                                               {\r
-                                                       fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-                                                       fprintf(fp, "\t\t and   ebx,byte 7\n");\r
-                                               }\r
-\r
-                                               fprintf(fp, "\t\t shr   ecx,byte 9\n");\r
-                                               fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-\r
-                                               EffectiveAddressCalculate(Dest,'L',EBX,TRUE);\r
-                                               fprintf(fp, "\t\t mov   [%s+ECX*4],edi\n",REG_ADD);\r
-                                               Completed();\r
-                                       }\r
-\r
-                                       OpcodeArray[Opcode] = BaseCode ;\r
-                               }\r
-                       }\r
-}\r
-\r
-/*\r
- * Negate BCD\r
- *\r
- */\r
-\r
-void nbcd(void)\r
-{\r
-       int     Opcode, BaseCode ;\r
-       int     sreg,mode,Dest ;\r
-       char allow[] = "0-2345678-------" ;\r
-\r
-       for (mode = 0 ; mode < 8 ; mode++)\r
-               for (sreg = 0 ; sreg < 8 ; sreg++)\r
-               {\r
-                       Opcode = 0x4800 | (mode<<3) | sreg ;\r
-                       BaseCode = Opcode & 0x4838 ;\r
-\r
-                       if (mode == 7)\r
-                               BaseCode |= sreg ;\r
-\r
-                       // A7+, A7-\r
-\r
-#ifdef  A7ROUTINE\r
-                       if ((sreg == 7) && (mode > 2) && (mode < 5))\r
-                       {\r
-                               BaseCode |= sreg;\r
-                       }\r
-#endif\r
-\r
-                       Dest = EAtoAMN(BaseCode, FALSE);\r
-\r
-                       if (allow[Dest&0xf] != '-')\r
-                       {\r
-                               if (OpcodeArray[BaseCode] == -2)\r
-                               {\r
-                                       Align();\r
-                                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                                       if ((Dest >= 2) && (Dest <=10))\r
-                                               SavePreviousPC();\r
-\r
-                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                       if (mode < 2)\r
-                                               TimingCycles += 6;\r
-                                       else\r
-                                               TimingCycles += 8;\r
-\r
-                                       fprintf(fp, "\t\t and   ecx, byte 7\n");\r
-\r
-                                       EffectiveAddressRead(Dest,'B',ECX,EBX,"--C-SDB",FALSE);\r
-\r
-                                       ClearRegister(EAX);\r
-                                       CopyX();\r
-\r
-                                       fprintf(fp, "\t\t sbb   al,bl\n");\r
-                                       fprintf(fp, "\t\t das\n");\r
-\r
-                                       SetFlags('B',EAX,FALSE,TRUE,TRUE);\r
-\r
-                                       EffectiveAddressWrite(Dest,'B',ECX,EAX,"----S-B",FALSE);\r
-                                       Completed();\r
-                               }\r
-                               OpcodeArray[Opcode] = BaseCode ;\r
-                       }\r
-               }\r
-}\r
-\r
-void tas(void)\r
-{\r
-       int     Opcode, BaseCode ;\r
-       int     sreg,mode,Dest ;\r
-       char allow[] = "0-2345678-------" ;\r
-\r
-       for (mode = 0 ; mode < 8 ; mode++)\r
-               for (sreg = 0 ; sreg < 8 ; sreg++)\r
-               {\r
-                       Opcode = 0x4ac0 | (mode<<3) | sreg ;\r
-                       BaseCode = Opcode & 0x4af8 ;\r
-\r
-                       if (mode == 7)\r
-                               BaseCode |= sreg ;\r
-\r
-#ifdef A7ROUTINE\r
-                       if ((sreg == 7) && (mode > 2) && (mode < 5))\r
-                       {\r
-                               BaseCode |= sreg ;\r
-                       }\r
-#endif\r
-\r
-                       Dest = EAtoAMN(BaseCode, FALSE);\r
-\r
-                       if (allow[Dest&0xf] != '-')\r
-                       {\r
-                               if (OpcodeArray[BaseCode] == -2)\r
-                               {\r
-                                       Align();\r
-                                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                                       if ((Dest >= 2) && (Dest <=10))\r
-                                               SavePreviousPC();\r
-\r
-                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                       if (mode < 2)\r
-                                               TimingCycles += 4;\r
-                                       else\r
-                                               TimingCycles += 14;\r
-\r
-                                       fprintf(fp, "\t\t and   ecx, byte 7\n");\r
-\r
-                                       EffectiveAddressRead(Dest,'B',ECX,EAX,"--C-SDB",FALSE);\r
-\r
-                                       SetFlags('B',EAX,TRUE,FALSE,TRUE);\r
-                                       fprintf(fp, "\t\t or    al,128\n");\r
-\r
-                                       EffectiveAddressWrite(Dest,'B',ECX,EAX,"----S-B",FALSE);\r
-                                       Completed();\r
-                               }\r
-                               OpcodeArray[Opcode] = BaseCode ;\r
-                       }\r
-               }\r
-}\r
-\r
-/*\r
- * push Effective Address\r
- */\r
-\r
-void PushEffectiveAddress(void)\r
-{\r
-       int     Opcode, BaseCode ;\r
-       int     mode,dreg ;\r
-       int     Dest ;\r
-       char allow[] = "--2--56789a-----" ;\r
-\r
-       for (mode = 0 ; mode < 8 ; mode++)\r
-               for (dreg = 0 ; dreg < 8 ; dreg++)\r
-               {\r
-                       Opcode = 0x4840 | (mode<<3) | dreg ;\r
-\r
-                       BaseCode = Opcode & 0x4878 ;\r
-\r
-                       if (mode == 7)\r
-                               BaseCode = BaseCode | dreg ;\r
-\r
-                       Dest = EAtoAMN(BaseCode, FALSE);\r
-\r
-                       if (allow[Dest&0x0f] != '-')\r
-                       {\r
-                               if (OpcodeArray[BaseCode] == -2)\r
-                               {\r
-                                       Align();\r
-                                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-                                       SavePreviousPC();\r
-                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                       switch (mode)\r
-                                       {\r
-                                               case 2:\r
-                                                       TimingCycles += 12;\r
-                                                       break;\r
-                                               case 5:\r
-                                               case 7:\r
-                                               case 9:\r
-                                                       TimingCycles += 16;\r
-                                                       break;\r
-                                               case 6:\r
-                                               case 8:\r
-                                               case 10:\r
-                                                       TimingCycles += 20;\r
-                                                       break;\r
-                                       }\r
-\r
-                                       if (mode < 7)\r
-                                       {\r
-                                               fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                                       }\r
-\r
-                                       EffectiveAddressCalculate(Dest,'L',ECX,TRUE);\r
-\r
-                                       fprintf(fp, "\t\t mov   ecx,[%s]\t ; Push onto Stack\n",REG_A7);\r
-                                       fprintf(fp, "\t\t sub   ecx,byte 4\n");\r
-                                       fprintf(fp, "\t\t mov   [%s],ecx\n",REG_A7);\r
-                                       Memory_Write('L',ECX,EDI,"---DS-B",2);\r
-                                       Completed();\r
-                               }\r
-\r
-                               OpcodeArray[Opcode] = BaseCode ;\r
-                       }\r
-               }\r
-}\r
-\r
-/*\r
- * Test\r
- *\r
- */\r
-\r
-void tst(void)\r
-{\r
-       int     leng, mode, sreg ;\r
-       int     Opcode, BaseCode ;\r
-       int     Dest ;\r
-       char Size=' ' ;\r
-       char * Regname ;\r
-       char * RegnameECX ;\r
-\r
-       char allow[] = "0-2345678-------" ;\r
-       if (CPU==2)\r
-               allow[1] = '1';\r
-\r
-       for (leng = 0 ; leng < 3 ; leng++)\r
-               for (mode = 0 ; mode < 8 ; mode++)\r
-                       for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                       {\r
-                               Opcode = 0x4a00 | (leng<<6) | (mode<<3) | sreg ;\r
-                               BaseCode = Opcode & 0x4af8 ;\r
-                               if (mode == 7)\r
-                               {\r
-                                       BaseCode |= sreg ;\r
-                               }\r
-\r
-                               // A7+, A7-\r
-\r
-#ifdef  A7ROUTINE\r
-                               if ((leng == 0) && (sreg == 7) && (mode > 2) && (mode < 5))\r
-                               {\r
-                                       BaseCode |= sreg ;\r
-                               }\r
-#endif\r
-\r
-                               Dest = EAtoAMN(Opcode, FALSE);\r
-\r
-                               if ((allow[Dest&0x0f] != '-') || (( mode == 1 ) && (leng != 0)))\r
-                               {\r
-                                       switch (leng)\r
-                                       {\r
-                                               case 0:\r
-                                                       Size = 'B';\r
-                                                       Regname = regnamesshort[0];\r
-                                                       RegnameECX = regnamesshort[ECX];\r
-                                                       break;\r
-                                               case 1:\r
-                                                       Size = 'W';\r
-                                                       Regname = regnamesword[0];\r
-                                                       RegnameECX = regnamesword[ECX];\r
-                                                       break;\r
-                                               case 2:\r
-                                                       Size = 'L';\r
-                                                       Regname = regnameslong[0];\r
-                                                       RegnameECX = regnameslong[ECX];\r
-                                                       break;\r
-                                       }\r
-\r
-                                       if (OpcodeArray[ BaseCode ] == -2)\r
-                                       {\r
-                                               Align();\r
-                                               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                                               if ((Dest >= 2) && (Dest <=10))\r
-                                                       SavePreviousPC();\r
-\r
-                                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                               TimingCycles += 4;\r
-\r
-                                               if (Dest < 7)\r
-                                                       fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-\r
-                                               EffectiveAddressRead(Dest,Size,ECX,EAX,"----S-B",FALSE);\r
-\r
-                                               SetFlags(Size,EAX,TRUE,FALSE,FALSE);\r
-                                               Completed();\r
-                                       }\r
-\r
-                                       OpcodeArray[Opcode] = BaseCode ;\r
-                               }\r
-                       }\r
-}\r
-\r
-/*\r
- * Move registers too / from memory\r
- *\r
- */\r
-\r
-void movem_reg_ea(void)\r
-{\r
-       int     leng,mode,sreg ;\r
-       int     Opcode, BaseCode ;\r
-       int     Dest ;\r
-       char  Size ;\r
-       char * Label ;\r
-\r
-       char *allow = "--2-45678-------" ;\r
-\r
-       for (leng = 0 ; leng < 2; leng++)\r
-               for (mode = 0 ; mode < 8; mode++)\r
-                       for (sreg = 0 ; sreg < 8; sreg++)\r
-                       {\r
-                               Opcode = 0x4880 | ( leng<<6) | (mode<<3) | sreg ;\r
-                               BaseCode = Opcode & 0x4cf8 ;\r
-\r
-                               if (mode == 7)\r
-                               {\r
-                                       BaseCode |= sreg ;\r
-                               }\r
-\r
-                               Dest = EAtoAMN(Opcode, FALSE);\r
-\r
-                               Size = "WL"[leng] ;\r
-\r
-                               if (allow[Dest&0xf] != '-')\r
-                               {\r
-                                       if (OpcodeArray[BaseCode] == - 2)\r
-                                       {\r
-                                               Align();\r
-                                               Label = GenerateLabel(BaseCode,0);\r
-                                               fprintf(fp, "%s:\n",Label ) ;\r
-                                               SavePreviousPC();\r
-                                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                               switch (mode)\r
-                                               {\r
-                                                       case 2:\r
-                                                       case 4:\r
-                                                               TimingCycles += 8 ;\r
-                                                               break;\r
-                                                       case 5:\r
-                                                       case 7:\r
-                                                               TimingCycles += 12 ;\r
-                                                               break;\r
-                                                       case 6:\r
-                                                       case 8:\r
-                                                               TimingCycles += 14 ;\r
-                                                               break;\r
-                                               }\r
-\r
-                                               fprintf(fp, "\t\t push edx\n");\r
-\r
-                                               Memory_Fetch('W',EDX,FALSE);\r
-                                               fprintf(fp, "\t\t add   esi,byte 2\n");\r
-\r
-                                               if (mode < 7)\r
-                                               {\r
-                                                       fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                                               }\r
-\r
-                                               if (mode == 4)\r
-                                               {\r
-                                                       fprintf(fp, "\t\t push  ecx\n");\r
-                                                       fprintf(fp, "\t\t mov   edi,[%s+ECX*4]\n",REG_ADD);\r
-                                               }\r
-                                               else\r
-                                                       EffectiveAddressCalculate(Dest,'L',ECX,TRUE);\r
-\r
-                                               fprintf(fp, "\t\t mov   ebx,1\n");\r
-\r
-                                               /* predecrement uses d0-d7..a0-a7  a7 first*/\r
-                                               /* other modes use      a7-a0..d7-d0  d0 first*/\r
-\r
-                                               if (Dest != 4)\r
-                                                       ClearRegister(ECX);\r
-                                               else\r
-                                                       fprintf(fp, "\t\t mov   ecx,3Ch\n");\r
-\r
-                                               fprintf(fp, "OP%d_%4.4x_Again:\n",CPU,BaseCode);\r
-                                               fprintf(fp, "\t\t test  edx,ebx\n");\r
-                                               fprintf(fp, "\t\t je    OP%d_%4.4x_Skip\n",CPU,BaseCode);\r
-\r
-                                               fprintf(fp, "\t\t mov   eax,[%s+ecx]\n",REG_DAT);  /* load eax with current reg data */\r
-\r
-                                               if (Dest == 4)\r
-                                               {\r
-                                                       if (Size == 'W')                                                /* adjust pointer before write */\r
-                                                               fprintf(fp, "\t\t sub   edi,byte 2\n");\r
-                                                       else\r
-                                                               fprintf(fp, "\t\t sub   edi,byte 4\n");\r
-                                               }\r
-\r
-                                               Memory_Write(Size,EDI,EAX,"-BCDSDB",1);\r
-\r
-                                               if (Dest != 4)\r
-                                               {\r
-                                                       if (Size == 'W')                                        /* adjust pointer after write */\r
-                                                               fprintf(fp, "\t\t add   edi,byte 2\n");\r
-                                                       else\r
-                                                               fprintf(fp, "\t\t add   edi,byte 4\n");\r
-                                               }\r
-\r
-                                               /* Update Cycle Count */\r
-\r
-                                               if (Size == 'W')\r
-                                                       fprintf(fp, "\t\t sub   dword [%s],byte 4\n",ICOUNT);\r
-                                               else\r
-                                                       fprintf(fp, "\t\t sub   dword [%s],byte 8\n",ICOUNT);\r
-\r
-                                               fprintf(fp, "OP%d_%4.4x_Skip:\n",CPU,BaseCode);\r
-\r
-                                               if (Dest != 4)\r
-                                                       fprintf(fp, "\t\t add   ecx,byte 4h\n");\r
-                                               else\r
-                                                       fprintf(fp, "\t\t sub   ecx,byte 4h\n");\r
-\r
-                                               fprintf(fp, "\t\t add   ebx,ebx\n");            /* faster than shl ebx,1 */\r
-                                               fprintf(fp, "\t\t test  bx,bx\n");                /* check low 16 bits */\r
-                                               fprintf(fp, "\t\t jnz   OP%d_%4.4x_Again\n",CPU,BaseCode);\r
-\r
-                                               if (Dest == 4)\r
-                                               {\r
-                                                       fprintf(fp, "\t\t pop   ecx\n");\r
-                                                       fprintf(fp, "\t\t mov   [%s+ECX*4],edi\n",REG_ADD);\r
-                                               }\r
-\r
-                                               fprintf(fp, "\t\t pop   edx\n");\r
-                                               Completed();\r
-                                       }\r
-\r
-                                       OpcodeArray[Opcode] = BaseCode ;\r
-                               }\r
-                       }\r
-}\r
-\r
-void movem_ea_reg(void)\r
-{\r
-       int     leng,mode,sreg ;\r
-       int     Opcode, BaseCode ;\r
-       int     Dest ;\r
-       char  Size ;\r
-       char * Label ;\r
-\r
-       char  *allow = "--23-56789a-----" ;\r
-\r
-       for (leng = 0 ; leng < 2; leng++)\r
-               for (mode = 0 ; mode < 8; mode++)\r
-                       for (sreg = 0 ; sreg < 8; sreg++)\r
-                       {\r
-                               Opcode = 0x4c80 | ( leng<<6) | (mode<<3) | sreg ;\r
-                               BaseCode = Opcode & 0x4cf8 ;\r
-\r
-                               if (mode == 7)\r
-                               {\r
-                                       BaseCode |= sreg ;\r
-                               }\r
-\r
-                               Dest = EAtoAMN(Opcode, FALSE);\r
-\r
-                               Size = "WL"[leng] ;\r
-\r
-                               if (allow[Dest&0xf] != '-')\r
-                               {\r
-                                       if (OpcodeArray[BaseCode] == - 2)\r
-                                       {\r
-                                               Align();\r
-                                               Label = GenerateLabel(BaseCode,0);\r
-\r
-                                               fprintf(fp, "%s:\n",Label ) ;\r
-                                               SavePreviousPC();\r
-                                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                               switch (mode)\r
-                                               {\r
-                                                       case 2:\r
-                                                       case 4:\r
-                                                               TimingCycles += 8 ;\r
-                                                               break;\r
-                                                       case 5:\r
-                                                       case 7:\r
-                                                               TimingCycles += 12 ;\r
-                                                               break;\r
-                                                       case 6:\r
-                                                       case 8:\r
-                                                               TimingCycles += 14 ;\r
-                                                               break;\r
-                                               }\r
-\r
-                                               fprintf(fp, "\t\t push  edx\n");                         /* save edx because sr is unaffected */\r
-\r
-                                               Memory_Fetch('W',EDX,FALSE);\r
-                                               fprintf(fp, "\t\t add   esi,byte 2\n");\r
-\r
-                                               if (mode < 7)\r
-                                               {\r
-                                                       fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                                               }\r
-\r
-                                               if (mode == 3)\r
-                                                       fprintf(fp, "\t\t push   ecx\n");                       /* if (An)+ then it needed later */\r
-\r
-                                               EffectiveAddressCalculate(Dest,'L',ECX,TRUE);\r
-\r
-                                               fprintf(fp, "\t\t mov   ebx,1\n");                        /* setup register list mask */\r
-\r
-                                               /* predecrement uses d0-d7..a0-a7  a7 first*/\r
-                                               /* other modes use      a7-a0..d7-d0  d0 first*/\r
-\r
-                                               ClearRegister(ECX);                                                               /* always start with D0 */\r
-\r
-                                               fprintf(fp, "OP%d_%4.4x_Again:\n",CPU,BaseCode);\r
-                                               fprintf(fp, "\t\t test  edx,ebx\n");                    /* is bit set for this register? */\r
-                                               fprintf(fp, "\t\t je    OP%d_%4.4x_Skip\n",CPU,BaseCode);\r
-\r
-                                               Memory_Read(Size,EDI,"-BCDSDB",1);\r
-\r
-                                               if (Size == 'W')\r
-                                                       fprintf(fp, "\t\t cwde\n");                             /* word size must be sign extended */\r
-\r
-                                               fprintf(fp, "\t\t mov   [%s+ecx],eax\n",REG_DAT);  /* load current reg with eax */\r
-\r
-                                               if (Size == 'W')                                                /* adjust pointer after write */\r
-                                                       fprintf(fp, "\t\t add   edi,byte 2\n");\r
-                                               else\r
-                                                       fprintf(fp, "\t\t add   edi,byte 4\n");\r
-\r
-                                               /* Update Cycle Count */\r
-\r
-                                               if (Size == 'W')\r
-                                                       fprintf(fp, "\t\t sub   dword [%s],byte 4\n",ICOUNT);\r
-                                               else\r
-                                                       fprintf(fp, "\t\t sub   dword [%s],byte 8\n",ICOUNT);\r
-\r
-                                               fprintf(fp, "OP%d_%4.4x_Skip:\n",CPU,BaseCode);\r
-                                               fprintf(fp, "\t\t add   ecx,byte 4\n");                 /* adjust pointer to next reg */\r
-                                               fprintf(fp, "\t\t add   ebx,ebx\n");                    /* Faster than shl ebx,1 */\r
-                                               fprintf(fp, "\t\t test  bx,bx\n");                        /* check low 16 bits */\r
-                                               fprintf(fp, "\t\t jnz   OP%d_%4.4x_Again\n",CPU,BaseCode);\r
-\r
-                                               if (mode == 3)\r
-                                               {\r
-                                                       fprintf(fp, "\t\t pop   ecx\n");\r
-                                                       fprintf(fp, "\t\t mov   [%s+ECX*4],edi\n",REG_ADD);     /* reset Ax if mode = (Ax)+ */\r
-                                               }\r
-\r
-                                               fprintf(fp, "\t\t pop   edx\n");                         /* restore flags */\r
-                                               Completed();\r
-                                       }\r
-\r
-                                       OpcodeArray[Opcode] = BaseCode ;\r
-                               }\r
-                       }\r
-}\r
-\r
-/*\r
- * Link / Unlink\r
- *\r
- * Local stack space\r
- *\r
- */\r
-\r
-void link(void)\r
-{\r
-       int     sreg ;\r
-       int     Opcode, BaseCode ;\r
-\r
-       for (sreg = 0 ; sreg < 8; sreg++)\r
-       {\r
-               Opcode = 0x4e50 | sreg ;\r
-               BaseCode = 0x4e50 ;\r
-\r
-               if (OpcodeArray[BaseCode] == - 2)\r
-               {\r
-                       Align();\r
-                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-                       SavePreviousPC();\r
-                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                       TimingCycles += 16;\r
-\r
-                       fprintf(fp, "\t\t sub   dword [%s],byte 4\n",REG_A7);\r
-\r
-                       fprintf(fp, "\t\t and   ecx, byte 7\n");\r
-                       fprintf(fp, "\t\t mov   eax,[%s+ECX*4]\n",REG_ADD);\r
-                       fprintf(fp, "\t\t mov   edi,[%s]\n",REG_A7);\r
-                       fprintf(fp, "\t\t mov   [%s+ECX*4],edi\n",REG_ADD);\r
-\r
-                       Memory_Write('L',EDI,EAX,"---DS-B",1);\r
-\r
-                       Memory_Fetch('W',EAX,TRUE);\r
-                       fprintf(fp, "\t\t add   esi,byte 2\n");\r
-                       fprintf(fp, "\t\t add   [%s],eax\n",REG_A7);\r
-\r
-                       Completed();\r
-               }\r
-\r
-               OpcodeArray[Opcode] = BaseCode ;\r
-       }\r
-}\r
-\r
-void unlinkasm(void)\r
-{\r
-       int     sreg ;\r
-       int     Opcode, BaseCode ;\r
-\r
-       for (sreg = 0 ; sreg < 8; sreg++)\r
-       {\r
-               Opcode = 0x4e58 | sreg ;\r
-               BaseCode = 0x4e58 ;\r
-\r
-               if (OpcodeArray[BaseCode] == - 2)\r
-               {\r
-                       Align();\r
-                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-                       SavePreviousPC();\r
-                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                       TimingCycles += 12;\r
-\r
-                       fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-                       fprintf(fp, "\t\t and   ebx, byte 7\n");\r
-                       fprintf(fp, "\t\t mov   edi,[%s+EBX*4]\n",REG_ADD);\r
-\r
-                       Memory_Read('L',EDI,"-B-DSDB",1);\r
-\r
-                       fprintf(fp, "\t\t mov   [%s+EBX*4],eax\n",REG_ADD);\r
-                       fprintf(fp, "\t\t add   edi,byte 4\n");\r
-                       fprintf(fp, "\t\t mov   dword [%s],EDI\n",REG_A7);\r
-                       Completed();\r
-               }\r
-\r
-               OpcodeArray[Opcode] = BaseCode ;\r
-       }\r
-}\r
-\r
-void trap(void)\r
-{\r
-       int Count;\r
-       int BaseCode = 0x4E40;\r
-\r
-       if (OpcodeArray[BaseCode] == -2)\r
-       {\r
-               Align();\r
-               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-               fprintf(fp, "\t\t mov   eax,ecx\n");\r
-               fprintf(fp, "\t\t and   eax,byte 15\n");\r
-               fprintf(fp, "\t\t or    eax,byte 32\n");\r
-               Exception(-1,BaseCode);\r
-               Completed();\r
-       }\r
-\r
-       for (Count=0;Count<=15;Count++)\r
-               OpcodeArray[BaseCode+Count] = BaseCode;\r
-}\r
-\r
-void reset(void)\r
-{\r
-       int BaseCode = 0x4E70;\r
-       char * Label;\r
-\r
-       if (OpcodeArray[BaseCode] == -2)\r
-       {\r
-               Align();\r
-               Label = GenerateLabel(BaseCode,0);\r
-\r
-               TimingCycles += 132;\r
-\r
-               fprintf(fp, "%s:\n", Label );\r
-               SavePreviousPC();\r
-\r
-               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-               fprintf(fp, "\t\t test  byte [%s],20h \t\t\t; Supervisor Mode ?\n",REG_SRH);\r
-               fprintf(fp, "\t\t jnz   near OP%d_%4.4x_RESET\n",CPU,BaseCode);\r
-               Exception(8,BaseCode);\r
-\r
-               fprintf(fp, "\nOP%d_%4.4x_RESET:\n",CPU,BaseCode);\r
-\r
-               /* Prefetch next instruction */\r
-\r
-               if(CPU==2)\r
-               {\r
-                       /* 32 bit memory version */\r
-\r
-                       fprintf(fp, "\t\t xor   esi,2\n");      /* ASG */\r
-#ifdef STALLCHECK\r
-                ClearRegister(ECX);\r
-                       fprintf(fp, "\t\t mov   cx,[esi+ebp]\n");\r
-#else\r
-                       fprintf(fp, "\t\t movzx ecx,word [esi+ebp]\n");\r
-#endif\r
-                       fprintf(fp, "\t\t xor   esi,2\n");      /* ASG */\r
-               }\r
-               else\r
-               {\r
-                       /* 16 bit memory */\r
-#ifdef STALLCHECK\r
-                ClearRegister(ECX);\r
-                       fprintf(fp, "\t\t mov   cx,[esi+ebp]\n");\r
-#else\r
-                       fprintf(fp, "\t\t movzx ecx,word [esi+ebp]\n");\r
-#endif\r
-               }\r
-\r
-               fprintf(fp, "\t\t mov  eax,dword [%s]\n", REG_RESET_CALLBACK);\r
-               fprintf(fp, "\t\t test eax,eax\n");\r
-               fprintf(fp, "\t\t jz   near OP%d_%4.4x_END\n",CPU,BaseCode);\r
-\r
-               /* Callback for Reset */\r
-\r
-               fprintf(fp, "\t\t mov   [%s],ESI,\n",REG_PC);\r
-               fprintf(fp, "\t\t mov   [%s],edx\n",REG_CCR);\r
-               fprintf(fp, "\t\t push  ECX\n");\r
-\r
-               fprintf(fp, "\t\t call  [eax]\n");\r
-\r
-               fprintf(fp, "\t\t mov   ESI,[%s]\n",REG_PC);\r
-               fprintf(fp, "\t\t mov   edx,[%s]\n",REG_CCR);\r
-               fprintf(fp, "\t\t pop   ECX\n");\r
-               fprintf(fp, "\t\t mov   ebp,dword [_OP_ROM]\n");\r
-\r
-               fprintf(fp, "OP%d_%4.4x_END:\n",CPU,BaseCode);\r
-               fprintf(fp, "\t\t sub   dword [%s],%d\n",ICOUNT,TimingCycles);\r
-               fprintf(fp, "\t\t jmp   [%s_OPCODETABLE+ecx*4]\n\n", CPUtype);\r
-       }\r
-       OpcodeArray[BaseCode] = BaseCode ;\r
-}\r
-\r
-void nop(void)\r
-{\r
-       int     BaseCode = 0x4e71 ;\r
-\r
-       if (OpcodeArray[BaseCode] == -2)\r
-       {\r
-               Align();\r
-               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-               TimingCycles += 4;\r
-\r
-               Completed();\r
-               OpcodeArray[BaseCode] = BaseCode ;\r
-       }\r
-}\r
-\r
-void stop(void)\r
-{\r
-       char TrueLabel[16];\r
-       int      BaseCode = 0x4e72 ;\r
-\r
-       if (OpcodeArray[BaseCode] == -2)\r
-       {\r
-               Align();\r
-               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-               TimingCycles += 4;\r
-\r
-               /* Must be in Supervisor Mode */\r
-\r
-               sprintf(TrueLabel,GenerateLabel(0,1));\r
-\r
-               fprintf(fp, "\t\t test  byte [%s],20h \t\t\t; Supervisor Mode ?\n",REG_SRH);\r
-               fprintf(fp, "\t\t je    near %s\n\n",TrueLabel);\r
-\r
-               /* Next WORD is new SR */\r
-\r
-               Memory_Fetch('W',EAX,FALSE);\r
-               fprintf(fp, "\t\t add   esi,byte 2\n");\r
-\r
-               WriteCCR('W');\r
-\r
-               /* See if Valid interrupt waiting */\r
-\r
-               CheckInterrupt = 0;\r
-\r
-               fprintf(fp, "\t\t mov   eax,[%s]\n",REG_IRQ);\r
-               fprintf(fp, "\t\t and   eax,byte 07H\n");\r
-\r
-               fprintf(fp, "\t\t cmp   al,7\t\t ; Always take 7\n");\r
-               fprintf(fp, "\t\t je    near procint\n\n");\r
-\r
-               fprintf(fp, "\t\t mov   ebx,[%s]\t\t; int mask\n",REG_SRH);\r
-               fprintf(fp, "\t\t and   ebx,byte 07H\n");\r
-               fprintf(fp, "\t\t cmp   eax,ebx\n");\r
-               fprintf(fp, "\t\t jg    near procint\n\n");\r
-\r
-               /* No int waiting - clear count, set stop */\r
-\r
-               ClearRegister(ECX);\r
-               fprintf(fp, "\t\t mov   [%s],ecx\n",ICOUNT);\r
-               fprintf(fp, "\t\t or    byte [%s],80h\n",REG_IRQ);\r
-               Completed();\r
-\r
-               /* User Mode - Exception */\r
-\r
-               Align();\r
-               fprintf(fp, "%s:\n",TrueLabel);\r
-               Exception(8,BaseCode);\r
-\r
-               OpcodeArray[BaseCode] = BaseCode ;\r
-       }\r
-}\r
-\r
-void ReturnFromException(void)\r
-{\r
-       char TrueLabel[16];\r
-\r
-       int BaseCode = 0x4e73;\r
-\r
-       Align();\r
-       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-       SavePreviousPC();\r
-       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-       TimingCycles += 20;\r
-\r
-       /* Check in Supervisor Mode */\r
-\r
-       sprintf(TrueLabel,GenerateLabel(0,1));\r
-       fprintf(fp, "\t\t test  byte [%s],20h \t\t\t; Supervisor Mode ?\n",REG_SRH);\r
-       fprintf(fp, "\t\t je    near %s\n\n",TrueLabel);\r
-\r
-       /* Get SR - Save in EBX */\r
-\r
-       fprintf(fp, "\t\t mov   edi,[%s]\n",REG_A7);\r
-       fprintf(fp, "\t\t add   dword [%s],byte 6\n",REG_A7);\r
-       Memory_Read('W',EDI,"-----DB",2);\r
-       fprintf(fp, "\t\t add   edi,byte 2\n");\r
-       fprintf(fp, "\t\t mov   esi,eax\n");\r
-\r
-       /* Get PC */\r
-\r
-       Memory_Read('L',EDI,"----S-B",0);\r
-       fprintf(fp, "\t\t xchg  esi,eax\n");\r
-\r
-       /* Update CCR (and A7) */\r
-\r
-       WriteCCR('W');\r
-\r
-       MemoryBanking(BaseCode);\r
-       Completed();\r
-\r
-       fprintf(fp, "%s:\n",TrueLabel);\r
-       Exception(8,0x10000+BaseCode);\r
-\r
-       OpcodeArray[BaseCode] = BaseCode;\r
-}\r
-\r
-void trapv(void)\r
-{\r
-       int BaseCode = 0x4E76;\r
-       char * Label;\r
-\r
-       if (OpcodeArray[BaseCode] == -2)\r
-       {\r
-               Align();\r
-               Label = GenerateLabel(BaseCode,0);\r
-               fprintf(fp, "%s\n", Label );\r
-               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-               TimingCycles += 4;\r
-\r
-               fprintf(fp, "\t\t test  dh,08h\n");\r
-               fprintf(fp, "\t\t jz    near OP%d_%4.4x_Clear\n",CPU,BaseCode);\r
-               Exception(7,BaseCode);\r
-\r
-               fprintf(fp, "OP%d_%4.4x_Clear:\n",CPU,BaseCode);\r
-               Completed();\r
-       }\r
-       OpcodeArray[BaseCode] = BaseCode ;\r
-}\r
-\r
-void illegal_opcode(void)\r
-{\r
-       Align();\r
-       fprintf(fp, "ILLEGAL:\n");\r
-       fprintf(fp, "\t\t mov [_illegal_op],ecx\n");\r
-       fprintf(fp, "\t\t mov [_illegal_pc],esi\n");\r
-\r
-#ifdef MAME_DEBUG\r
-       fprintf(fp, "\t\t jmp ecx\n");\r
-       fprintf(fp, "\t\t pushad\n");\r
-       fprintf(fp, "\t\t call _m68k_illegal_opcode\n");\r
-       fprintf(fp, "\t\t popad\n");\r
-#endif\r
-\r
-       Exception(4,0xFFFE);\r
-}\r
-\r
-/*\r
- * Return from subroutine\r
- * restoring flags as well\r
- *\r
- */\r
-\r
-void ReturnandRestore(void)\r
-{\r
-       int BaseCode = 0x4e77;\r
-\r
-       Align();\r
-       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-       SavePreviousPC();\r
-       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-       TimingCycles += 20;\r
-\r
-       /* Get SR into ESI */\r
-\r
-       fprintf(fp, "\t\t mov   edi,[%s]\n",REG_A7);\r
-       fprintf(fp, "\t\t add   dword [%s],byte 6\n",REG_A7);\r
-\r
-       Memory_Read('W',EDI,"-----DB",2);\r
-       fprintf(fp, "\t\t add   edi,byte 2\n");\r
-       fprintf(fp, "\t\t mov   esi,eax\n");\r
-\r
-       /* Get PC */\r
-\r
-       Memory_Read('L',EDI,"----SDB",0);\r
-       fprintf(fp, "\t\t xchg  esi,eax\n");\r
-\r
-       /* Update flags */\r
-\r
-       WriteCCR('B');\r
-\r
-       MemoryBanking(BaseCode);\r
-       Completed();\r
-\r
-       OpcodeArray[BaseCode] = BaseCode;\r
-}\r
-\r
-/*\r
- * Return from Subroutine\r
- *\r
- */\r
-\r
-void rts(void)\r
-{\r
-       int     BaseCode = 0x4e75 ;\r
-\r
-       if (OpcodeArray[BaseCode] == -2)\r
-       {\r
-               Align();\r
-               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-               SavePreviousPC();\r
-\r
-               TimingCycles += 16;\r
-\r
-               OpcodeArray[BaseCode] = BaseCode ;\r
-\r
-               fprintf(fp, "\t\t mov   eax,[%s]\n",REG_A7);\r
-               fprintf(fp, "\t\t add   dword [%s],byte 4\n",REG_A7);\r
-               Memory_Read('L',EAX,"---D--B",1);\r
-               fprintf(fp, "\t\t mov   esi,eax\n");\r
-               MemoryBanking(BaseCode);\r
-               Completed();\r
-       }\r
-}\r
-\r
-void jmp_jsr(void)\r
-{\r
-       int     Opcode, BaseCode ;\r
-       int     dreg,mode,type ;\r
-       int     Dest ;\r
-       char allow[] = "--2--56789a-----" ;\r
-\r
-       for (type = 0 ; type < 2 ; type++)\r
-               for (mode = 0 ; mode < 8 ; mode++)\r
-                       for (dreg = 0 ; dreg < 8 ; dreg++)\r
-                       {\r
-                               Opcode = 0x4e80 | (type<<6) | (mode<<3) | dreg ;\r
-                               BaseCode = Opcode & 0x4ef8 ;\r
-                               if (mode == 7)\r
-                                       BaseCode = BaseCode | dreg ;\r
-\r
-                               Dest = EAtoAMN(BaseCode, FALSE);\r
-                               if (allow[Dest&0x0f] != '-')\r
-                               {\r
-                                       if (OpcodeArray[BaseCode] == -2)\r
-                                       {\r
-                                               Align();\r
-                                               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-                                               SavePreviousPC();\r
-                                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                               switch (mode)\r
-                                               {\r
-                                                       case 2:\r
-                                                               TimingCycles += 8;\r
-                                                               break;\r
-                                                       case 5:\r
-                                                       case 7:\r
-                                                       case 9:\r
-                                                               TimingCycles += 10;\r
-                                                               break;\r
-                                                       case 8:\r
-                                                               TimingCycles += 12;\r
-                                                               break;\r
-                                                       case 6:\r
-                                                       case 10:\r
-                                                               TimingCycles += 14;\r
-                                                               break;\r
-                                               }\r
-\r
-                                               if (type == 0) /* jsr takes 8 more than jmp */\r
-                                                       TimingCycles += 8;\r
-\r
-                                               if (mode < 7)\r
-                                               {\r
-                                                       fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                                               }\r
-                                               EffectiveAddressCalculate(Dest,'L',ECX,TRUE);\r
-\r
-                                               /* jsr needs to push PC onto stack */\r
-\r
-                                               if (type == 0)\r
-                                               {\r
-                                                       PushPC(EBX,EAX,"---D-DB",1);\r
-                                               }\r
-\r
-                                               fprintf(fp, "\t\t mov   esi,edi\n");\r
-                                               MemoryBanking(BaseCode);\r
-                                               Completed();\r
-                                       }\r
-\r
-                                       OpcodeArray[Opcode] = BaseCode ;\r
-                               }\r
-                       }\r
-}\r
-\r
-void cmpm(void)\r
-{\r
-       int     Opcode, BaseCode ;\r
-       int     regx,leng,regy ;\r
-       int ModeModX, ModeModY;\r
-       char Size=' ' ;\r
-       char * Regname="" ;\r
-       char * RegnameEBX="" ;\r
-\r
-       for (regx = 0 ; regx < 8 ; regx++)\r
-               for (leng = 0 ; leng < 3 ; leng++)\r
-                       for (regy = 0 ; regy < 8 ; regy++)\r
-                       {\r
-                               Opcode = 0xb108 | (regx<<9) | (leng<<6) | regy ;\r
-                               BaseCode = Opcode & 0xb1c8 ;\r
-\r
-                               ModeModX = 0;\r
-                               ModeModY = 0;\r
-\r
-#ifdef A7ROUTINE\r
-                               if (leng==0)\r
-                               {\r
-                                       if (regx==7)\r
-                                       {\r
-                                               BaseCode |= (regx<<9);\r
-                                               ModeModX = 16;\r
-                                       }\r
-\r
-                                       if (regy==7)\r
-                                       {\r
-                                               BaseCode |= regy;\r
-                                               ModeModY = 16;\r
-                                       }\r
-                               }\r
-#endif\r
-\r
-                               switch (leng)\r
-                               {\r
-                                       case 0:\r
-                                               Size = 'B';\r
-                                               Regname = regnamesshort[EAX];\r
-                                               RegnameEBX = regnamesshort[EBX];\r
-                                               break;\r
-                                       case 1:\r
-                                               Size = 'W';\r
-                                               Regname = regnamesword[EAX];\r
-                                               RegnameEBX = regnamesword[EBX];\r
-                                               break;\r
-                                       case 2:\r
-                                               Size = 'L';\r
-                                               Regname = regnameslong[EAX];\r
-                                               RegnameEBX = regnameslong[EBX];\r
-                                               break;\r
-                               }\r
-\r
-                               if (OpcodeArray[BaseCode] == -2)\r
-                               {\r
-                                       Align();\r
-                                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-                                       SavePreviousPC();\r
-                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                       AddEACycles = 0 ;\r
-\r
-                                       if (Size != 'L')\r
-                                               TimingCycles += 12 ;\r
-                                       else\r
-                                               TimingCycles += 20 ;\r
-\r
-                                       fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-                                       fprintf(fp, "\t\t and   ebx, byte 7\n");\r
-                                       fprintf(fp, "\t\t shr   ecx, byte 9\n");\r
-                                       fprintf(fp, "\t\t and   ecx, byte 7\n");\r
-\r
-                                       EffectiveAddressRead(3+ModeModY,Size,EBX,EBX,"--C-S-B",FALSE);\r
-                                       EffectiveAddressRead(3+ModeModX,Size,ECX,EAX,"-B--S-B",FALSE);\r
-\r
-                                       fprintf(fp, "\t\t cmp   %s,%s\n",Regname,RegnameEBX);\r
-                                       SetFlags(Size,EAX,FALSE,FALSE,FALSE);\r
-                                       Completed();\r
-                               }\r
-\r
-                               OpcodeArray[Opcode] = BaseCode ;\r
-                       }\r
-}\r
-\r
-void exg(void)\r
-{\r
-       int     Opcode, BaseCode ;\r
-       int     regx,type,regy ;\r
-       int     opmask[3] = { 0x08, 0x09, 0x11} ;\r
-\r
-       for (regx = 0 ; regx < 8 ; regx++)\r
-               for (type = 0 ; type < 3 ; type++)\r
-                       for (regy = 0 ; regy < 8 ; regy++)\r
-                       {\r
-                               Opcode = 0xc100 | (regx<<9) | (opmask[type]<<3) | regy ;\r
-                               BaseCode = Opcode & 0xc1c8 ;\r
-\r
-                               if (OpcodeArray[BaseCode] == -2)\r
-                               {\r
-                                       Align();\r
-                                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                       TimingCycles += 6 ;\r
-\r
-                                       fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-                                       fprintf(fp, "\t\t and   ebx,byte 7\n");\r
-                                       fprintf(fp, "\t\t shr   ecx,byte 9\n");\r
-                                       fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-\r
-                                       if (type == 0)\r
-                                       {\r
-                                               fprintf(fp, "\t\t mov   eax,[%s+ECX*4]\n",REG_DAT);\r
-                                               fprintf(fp, "\t\t mov   edi,[%s+EBX*4]\n",REG_DAT);\r
-                                               fprintf(fp, "\t\t mov   [%s+ECX*4],edi\n",REG_DAT);\r
-                                               fprintf(fp, "\t\t mov   [%s+EBX*4],eax\n",REG_DAT);\r
-                                       }\r
-                                       if (type == 1)\r
-                                       {\r
-                                               fprintf(fp, "\t\t mov   eax,[%s+ECX*4]\n",REG_ADD);\r
-                                               fprintf(fp, "\t\t mov   edi,[%s+EBX*4]\n",REG_ADD);\r
-                                               fprintf(fp, "\t\t mov   [%s+ECX*4],edi\n",REG_ADD);\r
-                                               fprintf(fp, "\t\t mov   [%s+EBX*4],eax\n",REG_ADD);\r
-                                       }\r
-                                       if (type == 2)\r
-                                       {\r
-                                               fprintf(fp, "\t\t mov   eax,[%s+ECX*4]\n",REG_DAT);\r
-                                               fprintf(fp, "\t\t mov   edi,[%s+EBX*4]\n",REG_ADD);\r
-                                               fprintf(fp, "\t\t mov   [%s+ECX*4],edi\n",REG_DAT);\r
-                                               fprintf(fp, "\t\t mov   [%s+EBX*4],eax\n",REG_ADD);\r
-                                       }\r
-\r
-                                       Completed();\r
-                               }\r
-\r
-                               OpcodeArray[Opcode] = BaseCode ;\r
-                       }\r
-}\r
-\r
-void ext(void)\r
-{\r
-       int     Opcode, BaseCode ;\r
-       int     type,regy ;\r
-\r
-       for (type = 2 ; type < 8 ; type++)\r
-               for (regy = 0 ; regy < 8 ; regy++)\r
-               {\r
-                       if (type > 3 && type < 7)\r
-                               continue ;\r
-                       Opcode = 0x4800 | (type<<6) | regy ;\r
-                       BaseCode = Opcode & 0x48c0 ;\r
-\r
-                       if (OpcodeArray[BaseCode] == -2)\r
-                       {\r
-                               Align();\r
-                               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                               TimingCycles += 4 ;\r
-\r
-                               fprintf(fp, "\t\t and   ecx, byte 7\n");\r
-\r
-                               if (type == 2) /* byte to word */\r
-                               {\r
-                                       fprintf(fp, "\t\t movsx eax,byte [%s+ECX*4]\n",REG_DAT);\r
-                                       fprintf(fp, "\t\t mov   [%s+ECX*4],ax\n",REG_DAT);\r
-                                       SetFlags('W',EAX,TRUE,FALSE,FALSE);\r
-                               }\r
-                               if (type == 3) /* word to long */\r
-                               {\r
-                                       fprintf(fp, "\t\t movsx eax,word [%s+ECX*4]\n",REG_DAT);\r
-                                       fprintf(fp, "\t\t mov   [%s+ECX*4],eax\n",REG_DAT);\r
-                                       SetFlags('L',EAX,TRUE,FALSE,FALSE);\r
-                               }\r
-                               if (type == 7) /* byte to long */\r
-                               {\r
-                                       fprintf(fp, "\t\t movsx eax,byte [%s+ECX*4]\n",REG_DAT);\r
-                                       fprintf(fp, "\t\t mov   [%s+ECX*4],eax\n",REG_DAT);\r
-                                       SetFlags('L',EAX,TRUE,FALSE,FALSE);\r
-                               }\r
-                               Completed();\r
-                       }\r
-\r
-                       OpcodeArray[Opcode] = BaseCode ;\r
-               }\r
-}\r
-\r
-void swap(void)\r
-{\r
-       int     Opcode, BaseCode ;\r
-       int     sreg ;\r
-\r
-       for (sreg = 0 ; sreg < 8 ; sreg++)\r
-       {\r
-               Opcode = 0x4840 | sreg ;\r
-               BaseCode = Opcode & 0x4840;\r
-\r
-               if (OpcodeArray[BaseCode] == -2)\r
-               {\r
-                       Align();\r
-                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                       TimingCycles += 4 ;\r
-\r
-                       fprintf(fp, "\t\t and   ecx, byte 7\n");\r
-                       fprintf(fp, "\t\t mov   eax, dword [%s+ECX*4]\n",REG_DAT);\r
-                       fprintf(fp, "\t\t ror   eax, 16\n");\r
-                       fprintf(fp, "\t\t test  eax,eax\n");\r
-                       fprintf(fp, "\t\t mov   dword [%s+ECX*4],eax\n",REG_DAT);\r
-                       SetFlags('L',EAX,FALSE,FALSE,FALSE);\r
-                       Completed();\r
-               }\r
-\r
-               OpcodeArray[Opcode] = BaseCode ;\r
-       }\r
-}\r
-\r
-/*\r
- * Line A and Line F commands\r
- *\r
- */\r
-\r
-void LineA(void)\r
-{\r
-       int Count;\r
-\r
-       /* Line A */\r
-\r
-       Align();\r
-       fprintf(fp, "%s:\n",GenerateLabel(0xA000,0));\r
-       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-       Exception(0x0A,0xA000);\r
-\r
-       for (Count=0xA000;Count<0xB000;Count++)\r
-       {\r
-               OpcodeArray[Count] = 0xA000;\r
-       }\r
-}\r
-\r
-void LineF(void)\r
-{\r
-       int Count;\r
-\r
-       /* Line F */\r
-\r
-       Align();\r
-       fprintf(fp, "%s:\n",GenerateLabel(0xF000,0));\r
-       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-       Exception(0x0B,0xF000);\r
-\r
-       for (Count=0xF000;Count<0x10000;Count++)\r
-       {\r
-               OpcodeArray[Count] = 0xF000;\r
-       }\r
-}\r
-\r
-/*\r
- * Moves To/From CCR and SR\r
- *\r
- * (Move from CCR is 68010 command)\r
- *\r
- */\r
-\r
-void movesr(void)\r
-{\r
-       int Opcode, BaseCode ;\r
-       int type, mode, sreg ;\r
-       int Dest ;\r
-       char allow[] = "0-2345678-------" ;\r
-       char Size;\r
-\r
-       for (type = 0 ; type < 4 ; type++)\r
-               for (mode = 0 ; mode < 8 ; mode++)\r
-                       for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                       {\r
-                               Opcode = 0x40c0 | (type << 9) | ( mode << 3 ) | sreg ;\r
-\r
-                               /* To has extra modes */\r
-\r
-                               if (type > 1)\r
-                               {\r
-                                       allow[0x9] = '9';\r
-                                       allow[0xa] = 'a';\r
-                                       allow[0xb] = 'b' ;\r
-                               }\r
-\r
-                               if ((type == 0) | (type == 3))\r
-                                       Size = 'W'; /* SR */\r
-                               else\r
-                                       Size = 'B'; /* CCR */\r
-\r
-                               BaseCode = Opcode & 0x46f8 ;\r
-\r
-                               if (mode == 7)\r
-                                       BaseCode |= sreg ;\r
-\r
-                               Dest = EAtoAMN(BaseCode, FALSE);\r
-\r
-                               if (allow[Dest&0xf] != '-')\r
-                               {\r
-                                       if (OpcodeArray[BaseCode] == -2)\r
-                                       {\r
-                                               char TrueLabel[16];\r
-\r
-                                               Align();\r
-                                               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                                               if ((Dest >= 2) && (Dest <=10))\r
-                                                       SavePreviousPC();\r
-\r
-                                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                               if (type > 1) /* move to */\r
-                                                       TimingCycles += 12 ;\r
-                                               else\r
-                                               {\r
-                                                       if (mode < 2)\r
-                                                               TimingCycles += 6 ;\r
-                                                       else\r
-                                                               TimingCycles += 8 ;\r
-                                               }\r
-\r
-                                               /* If Move to SR then must be in Supervisor Mode */\r
-\r
-                                               if (type == 3)\r
-                                               {\r
-                                                       sprintf(TrueLabel,GenerateLabel(0,1));\r
-\r
-                                                       fprintf(fp, "\t\t test  byte [%s],20h \t\t\t; Supervisor Mode ?\n",REG_SRH);\r
-                                                       fprintf(fp, "\t\t je    near %s\n\n",TrueLabel);\r
-                                               }\r
-\r
-                                               /* 68010 Command ? */\r
-                                               if (type==1) CheckCPUtype(1);\r
-\r
-\r
-                                               if (mode < 7)\r
-                                               {\r
-                                                       fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                                               }\r
-\r
-                                               /* Always read/write word 2 bytes */\r
-                                               if (type < 2)\r
-                                               {\r
-                                                       ReadCCR(Size,EBX);\r
-                                                       EffectiveAddressWrite(Dest & 15,'W',ECX,TRUE,"---DS-B",TRUE);\r
-                                               }\r
-                                               else\r
-                                               {\r
-                                                       EffectiveAddressRead(Dest & 15,'W',ECX,EAX,"----S-B",FALSE);\r
-                                                       WriteCCR(Size);\r
-                                               }\r
-                                               Completed();\r
-\r
-                                               /* Exception if not Supervisor Mode */\r
-\r
-                                               if (type == 3)\r
-                                               {\r
-                                                       /* Was in User Mode - Exception */\r
-\r
-                                                       fprintf(fp, "%s:\n",TrueLabel);\r
-                                                       Exception(8,BaseCode);\r
-                                               }\r
-                                       }\r
-\r
-                                       OpcodeArray[Opcode] = BaseCode ;\r
-                               }\r
-                       }\r
-}\r
-\r
-/*\r
- * Decimal mode Add / Subtracts\r
- *\r
- */\r
-\r
-void abcd_sbcd(void)\r
-{\r
-       int     Opcode, BaseCode ;\r
-       int     regx,type,rm,regy,mode ;\r
-       int ModeModX;\r
-       int ModeModY;\r
-       char *Label;\r
-\r
-       for (type = 0 ; type < 2 ; type ++) /* 0=sbcd, 1=abcd */\r
-               for (regx = 0 ; regx < 8 ; regx++)\r
-                       for (rm = 0 ; rm < 2 ; rm++)\r
-                               for (regy = 0 ; regy < 8 ; regy++)\r
-                               {\r
-                                       Opcode = 0x8100 | (type<<14) | (regx<<9) | (rm<<3) | regy ;\r
-                                       BaseCode = Opcode & 0xc108 ;\r
-\r
-                                       ModeModX = 0;\r
-                                       ModeModY = 0;\r
-\r
-                                       if (rm == 0)\r
-                                               mode = 0 ;\r
-                                       else\r
-                                       {\r
-                                               mode = 4 ;\r
-\r
-#ifdef A7ROUTINE\r
-\r
-                                               if (regx == 7)\r
-                                               {\r
-                                                       BaseCode |= (regx << 9);\r
-                                                       ModeModY = 16;\r
-                                               }\r
-                                               if (regy == 7)\r
-                                               {\r
-                                                       BaseCode |= regy;\r
-                                                       ModeModX = 16;\r
-                                               }\r
-\r
-#endif\r
-                                       }\r
-\r
-                                       if (OpcodeArray[BaseCode] == -2)\r
-                                       {\r
-                                               Align();\r
-                                               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                                               if (mode == 4)\r
-                                                       SavePreviousPC();\r
-\r
-                                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                               AddEACycles = 0 ;\r
-\r
-                                               if (rm == 0)\r
-                                                       TimingCycles += 6 ;\r
-                                               else\r
-                                                       TimingCycles += 18 ;\r
-\r
-                                               fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-                                               fprintf(fp, "\t\t and   ebx, byte 7\n");\r
-                                               fprintf(fp, "\t\t shr   ecx, byte 9\n");\r
-                                               fprintf(fp, "\t\t and   ecx, byte 7\n");\r
-\r
-                                               EffectiveAddressRead(mode+ModeModX,'B',EBX,EBX,"--C-S-B",TRUE);\r
-                                               EffectiveAddressRead(mode+ModeModY,'B',ECX,EAX,"-BC-SDB",TRUE);\r
-\r
-                                               CopyX();\r
-\r
-                                               if (type == 0)\r
-                                               {\r
-                                                       fprintf(fp, "\t\t sbb   al,bl\n");\r
-                                                       fprintf(fp, "\t\t das\n");\r
-                                               }\r
-                                               else\r
-                                               {\r
-                                                       fprintf(fp, "\t\t adc   al,bl\n");\r
-                                                       fprintf(fp, "\t\t daa\n");\r
-                                               }\r
-\r
-                                               /* Should only clear Zero flag if not zero */\r
-\r
-                                               Label = GenerateLabel(0,1);\r
-\r
-                                               fprintf(fp, "\t\t mov   ebx,edx\n");\r
-                                               fprintf(fp, "\t\t setc  dl\n");\r
-\r
-                                               fprintf(fp, "\t\t jnz   short %s\n\n",Label);\r
-\r
-                                               /* Keep original Zero flag */\r
-                                               fprintf(fp, "\t\t and   bl,40h        ; Mask out Old Z\n");\r
-                                               fprintf(fp, "\t\t or    dl,bl         ; Copy across\n\n");\r
-\r
-                                               fprintf(fp, "%s:\n",Label);\r
-\r
-                                               fprintf(fp, "\t\t mov   bl,dl\n");  /* copy carry into sign */\r
-                                               fprintf(fp, "\t\t and   bl,1\n");\r
-                                               fprintf(fp, "\t\t shl   bl,7\n");\r
-                                               fprintf(fp, "\t\t and   dl,7Fh\n");\r
-                                               fprintf(fp, "\t\t or    dl,bl\n");\r
-\r
-                                               fprintf(fp, "\t\t mov   [%s],edx\n",REG_X);\r
-\r
-                                               EffectiveAddressWrite(mode,'B',ECX,EAX,"---DS-B",TRUE);\r
-                                               Completed();\r
-                                       }\r
-\r
-                                       OpcodeArray[Opcode] = BaseCode ;\r
-                               }\r
-}\r
-\r
-/*\r
- * Rotate Left / Right\r
- *\r
- */\r
-\r
-void rol_ror(void)\r
-{\r
-       int Opcode, BaseCode ;\r
-       int dreg, dr, leng, ir, sreg ;\r
-       char Size=' ';\r
-       char * Label ;\r
-       char * Regname="" ;\r
-       char * RegnameECX ;\r
-\r
-       for (dreg = 0 ; dreg < 8 ; dreg++)\r
-               for (dr = 0 ; dr < 2 ; dr++)\r
-                       for (leng = 0 ; leng < 3 ; leng++)\r
-                               for (ir = 0 ; ir < 2 ; ir++)\r
-                                       for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                                       {\r
-                                               Opcode = 0xe018 | (dreg<<9) | (dr<<8) | (leng<<6) | (ir<<5) | sreg ;\r
-                                               BaseCode = Opcode & 0xe1f8 ;\r
-\r
-                                               switch (leng)\r
-                                               {\r
-                                                       case 0:\r
-                                                               Size = 'B';\r
-                                                               Regname = regnamesshort[0];\r
-                                                               RegnameECX = regnamesshort[ECX];\r
-                                                               break;\r
-                                                       case 1:\r
-                                                               Size = 'W';\r
-                                                               Regname = regnamesword[0];\r
-                                                               RegnameECX = regnamesword[ECX];\r
-                                                               break;\r
-                                                       case 2:\r
-                                                               Size = 'L';\r
-                                                               Regname = regnameslong[0];\r
-                                                               RegnameECX = regnameslong[ECX];\r
-                                                               break;\r
-                                               }\r
-\r
-                                               if (OpcodeArray[ BaseCode ] == -2)\r
-                                               {\r
-                                                       Align();\r
-                                                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-                                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                                       if (Size != 'L')\r
-                                                               TimingCycles += 6 ;\r
-                                                       else\r
-                                                               TimingCycles += 8 ;\r
-\r
-                                                       fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-                                                       fprintf(fp, "\t\t and   ebx,byte 7\n");\r
-                                                       fprintf(fp, "\t\t shr   ecx,byte 9\n");\r
-\r
-                                                       if (ir == 0)\r
-                                                       {\r
-                                                               Immediate8();\r
-                                                       }\r
-                                                       else\r
-                                                       {\r
-                                                               fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                                                               EffectiveAddressRead(0,'L',ECX,ECX,"-B--S-B",FALSE);\r
-                                                               fprintf(fp, "\t\t and   ecx,byte 63\n");\r
-                                                       }\r
-\r
-                                                       EffectiveAddressRead(0,Size,EBX,EAX,"-BC-S-B",FALSE);\r
-\r
-                                                       /* shift 0 - no time, no shift and clear carry */\r
-\r
-                                                       Label = GenerateLabel(0,1);\r
-                                                       fprintf(fp, "\t\t jecxz %s\n",Label);\r
-\r
-                                                       /* allow 2 cycles per shift */\r
-\r
-                                                       fprintf(fp, "\t\t mov   edx,ecx\n");\r
-                                                       fprintf(fp, "\t\t add   edx,edx\n");\r
-                                                       fprintf(fp, "\t\t sub   dword [%s],edx\n",ICOUNT);\r
-\r
-                                                       if (dr == 0)\r
-                                                               fprintf(fp, "\t\t ror   %s,cl\n",Regname);\r
-                                                       else\r
-                                                               fprintf(fp, "\t\t rol   %s,cl\n",Regname);\r
-\r
-                                                       fprintf(fp, "\t\t setc  ch\n");\r
-\r
-                                                       fprintf(fp, "%s:\n",Label);\r
-\r
-                                                       SetFlags(Size,EAX,TRUE,FALSE,FALSE);\r
-/*                     fprintf(fp, "\t\t and   dl,254\n");  Test clears Carry */\r
-                                                       fprintf(fp, "\t\t or    dl,ch\n");\r
-\r
-                                                       EffectiveAddressWrite(0,Size,EBX,EAX,"--C-S-B",TRUE);\r
-\r
-                                                       Completed();\r
-                                               }\r
-\r
-                                               OpcodeArray[Opcode] = BaseCode ;\r
-                                       }\r
-}\r
-\r
-void rol_ror_ea(void)\r
-{\r
-       int Opcode, BaseCode ;\r
-       int dr, mode, sreg ;\r
-       int Dest ;\r
-       char allow[] = "--2345678-------" ;\r
-\r
-       for (dr = 0 ; dr < 2 ; dr++)\r
-               for (mode = 0 ; mode < 8 ; mode++)\r
-                       for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                       {\r
-                               Opcode = 0xe6c0 | (dr<<8) | (mode<<3) | sreg ;\r
-                               BaseCode = Opcode & 0xfff8 ;\r
-\r
-                               if (mode == 7)\r
-                                       BaseCode |= sreg ;\r
-\r
-                               Dest = EAtoAMN(BaseCode, FALSE);\r
-\r
-                               if (allow[Dest&0xf] != '-')\r
-                               {\r
-                                       if (OpcodeArray[ BaseCode ] == -2)\r
-                                       {\r
-                                               Align();\r
-                                               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                                               if ((Dest >= 2) && (Dest <=10))\r
-                                                       SavePreviousPC();\r
-\r
-                                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                               TimingCycles += 8 ;\r
-\r
-                                               fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                                               EffectiveAddressRead(Dest&0xf,'W',ECX,EAX,"--C-SDB",FALSE);\r
-\r
-                                               if (dr == 0)\r
-                                                       fprintf(fp, "\t\t ror   ax,1\n");\r
-                                               else\r
-                                                       fprintf(fp, "\t\t rol   ax,1\n");\r
-\r
-                                               fprintf(fp, "\t\t setc  bl\n");\r
-                                               SetFlags('W',EAX,TRUE,FALSE,FALSE);\r
-/*                             fprintf(fp, "\t\t and   dl,254\n");  Test clears Carry */\r
-                                               fprintf(fp, "\t\t or    dl,bl\n");\r
-\r
-                                               EffectiveAddressWrite(Dest&0xf,'W',ECX,EAX,"---DS-B",TRUE);\r
-\r
-                                               Completed();\r
-                                       }\r
-\r
-                                       OpcodeArray[Opcode] = BaseCode ;\r
-                               }\r
-                       }\r
-}\r
-\r
-/*\r
- * Logical Shift Left / Right\r
- *\r
- */\r
-\r
-void lsl_lsr(void)\r
-{\r
-       int Opcode, BaseCode ;\r
-       int dreg, dr, leng, ir, sreg ;\r
-       char Size=' ';\r
-       char * Regname="" ;\r
-       char * RegnameECX="" ;\r
-       char * RegnameEDX="" ;\r
-       char * Label ;\r
-\r
-       for (dreg = 0 ; dreg < 8 ; dreg++)\r
-               for (dr = 0 ; dr < 2 ; dr++)\r
-                       for (leng = 0 ; leng < 3 ; leng++)\r
-                               for (ir = 0 ; ir < 2 ; ir++)\r
-                                       for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                                       {\r
-                                               Opcode = 0xe008 | (dreg<<9) | (dr<<8) | (leng<<6) | (ir<<5) | sreg ;\r
-                                               BaseCode = Opcode & 0xe1f8 ;\r
-\r
-                                               switch (leng)\r
-                                               {\r
-                                                       case 0:\r
-                                                               Size = 'B';\r
-                                                               Regname = regnamesshort[0];\r
-                                                               RegnameECX = regnamesshort[ECX];\r
-                                                               RegnameEDX = regnamesshort[EDX];\r
-                                                               break;\r
-                                                       case 1:\r
-                                                               Size = 'W';\r
-                                                               Regname = regnamesword[0];\r
-                                                               RegnameECX = regnamesword[ECX];\r
-                                                               RegnameEDX = regnamesword[EDX];\r
-                                                               break;\r
-                                                       case 2:\r
-                                                               Size = 'L';\r
-                                                               Regname = regnameslong[0];\r
-                                                               RegnameECX = regnameslong[ECX];\r
-                                                               RegnameEDX = regnameslong[EDX];\r
-                                                               break;\r
-                                               }\r
-\r
-                                               if (OpcodeArray[ BaseCode ] == -2)\r
-                                               {\r
-                                                       Align();\r
-                                                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-                                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                                       if (Size != 'L')\r
-                                                               TimingCycles += 6 ;\r
-                                                       else\r
-                                                               TimingCycles += 8 ;\r
-\r
-                                                       fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-                                                       fprintf(fp, "\t\t and   ebx,byte 7\n");\r
-                                                       fprintf(fp, "\t\t shr   ecx,byte 9\n");\r
-\r
-                                                       if (ir == 0)\r
-                                                       {\r
-                                                               Immediate8();\r
-                                                       }\r
-                                                       else\r
-                                                       {\r
-                                                               fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                                                               EffectiveAddressRead(0,'L',ECX,ECX,"-B--S-B",FALSE);\r
-                                                               fprintf(fp, "\t\t and   ecx,byte 63\n");\r
-                                                       }\r
-\r
-                                                       /* and 2 cycles per shift */\r
-\r
-                                                       fprintf(fp, "\t\t mov   edx,ecx\n");\r
-                                                       fprintf(fp, "\t\t add   edx,edx\n");\r
-                                                       fprintf(fp, "\t\t sub   dword [%s],edx\n",ICOUNT);\r
-\r
-                                                       EffectiveAddressRead(0,Size,EBX,EAX,"-BC-S-B",FALSE);\r
-\r
-                                                       /* ASG: on the 68k, the shift count is mod 64; on the x86, the */\r
-                                                       /* shift count is mod 32; we need to check for shifts of 32-63 */\r
-                                                       /* and produce zero */\r
-                                                       Label = GenerateLabel(0,1);\r
-                                                       fprintf(fp, "\t\t test  cl,0x20\n");\r
-                                                       fprintf(fp, "\t\t jnz   %s_BigShift\n",Label);\r
-\r
-                                                       fprintf(fp, "%s_Continue:\n",Label);\r
-                                                       if (dr == 0)\r
-                                                               fprintf(fp, "\t\t shr   %s,cl\n",Regname);\r
-                                                       else\r
-                                                               fprintf(fp, "\t\t shl   %s,cl\n",Regname);\r
-\r
-                                                       SetFlags(Size,EAX,FALSE,FALSE,FALSE);\r
-\r
-                                                       /* Clear Overflow flag */\r
-                                                       fprintf(fp, "\t\t xor   dh,dh\n");\r
-\r
-                                                       EffectiveAddressWrite(0,Size,EBX,EAX,"--CDS-B",TRUE);\r
-\r
-                                                       /* if shift count is zero clear carry */\r
-\r
-                                                       fprintf(fp, "\t\t jecxz %s\n",Label);\r
-\r
-                                                       fprintf(fp, "\t\t mov   [%s],edx\n",REG_X);\r
-                                                       Completed();\r
-\r
-                                                       Align();\r
-                                                       fprintf(fp, "%s:\n",Label);\r
-                                                       fprintf(fp, "\t\t and   dl,254\t\t;clear C flag\n");\r
-                                                       Completed();\r
-\r
-                                                       fprintf(fp, "%s_BigShift:\n",Label);\r
-                                                       if (dr == 0)\r
-                                                       {\r
-                                                               fprintf(fp, "\t\t shr   %s,16\n",Regname);\r
-                                                               fprintf(fp, "\t\t shr   %s,16\n",Regname);\r
-                                                       }\r
-                                                       else\r
-                                                       {\r
-                                                               fprintf(fp, "\t\t shl   %s,16\n",Regname);\r
-                                                               fprintf(fp, "\t\t shl   %s,16\n",Regname);\r
-                                                       }\r
-                                                       fprintf(fp, "\t\t jmp   %s_Continue\n",Label);\r
-                                               }\r
-\r
-                                               OpcodeArray[Opcode] = BaseCode ;\r
-                                       }\r
-}\r
-\r
-void lsl_lsr_ea(void)\r
-{\r
-       int Opcode, BaseCode ;\r
-       int dr, mode, sreg ;\r
-       int Dest ;\r
-       char allow[] = "--2345678-------" ;\r
-\r
-       for (dr = 0 ; dr < 2 ; dr++)\r
-               for (mode = 0 ; mode < 8 ; mode++)\r
-                       for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                       {\r
-                               Opcode = 0xe2c0 | (dr<<8) | (mode<<3) | sreg ;\r
-                               BaseCode = Opcode & 0xfff8 ;\r
-\r
-                               if (mode == 7)\r
-                                       BaseCode |= sreg ;\r
-\r
-                               Dest = EAtoAMN(BaseCode, FALSE);\r
-\r
-                               if (allow[Dest&0xf] != '-')\r
-                               {\r
-                                       if (OpcodeArray[ BaseCode ] == -2)\r
-                                       {\r
-\r
-                                               Align();\r
-                                               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                                               if ((Dest >= 2) && (Dest <=10))\r
-                                                       SavePreviousPC();\r
-\r
-                                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                               TimingCycles += 8 ;\r
-\r
-                                               fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                                               EffectiveAddressRead(Dest&0xf,'W',ECX,EAX,"--C-SDB",FALSE);\r
-\r
-                                               if (dr == 0)\r
-                                                       fprintf(fp, "\t\t shr   ax,1\n");\r
-                                               else\r
-                                                       fprintf(fp, "\t\t shl   ax,1\n");\r
-\r
-                                               SetFlags('W',EAX,FALSE,TRUE,FALSE);\r
-\r
-                                               /* Clear Overflow flag */\r
-\r
-                                               fprintf(fp, "\t\t xor   dh,dh\n");\r
-\r
-                                               EffectiveAddressWrite(Dest&0xf,'W',ECX,EAX,"---DS-B",TRUE);\r
-                                               Completed();\r
-                                       }\r
-\r
-                                       OpcodeArray[Opcode] = BaseCode ;\r
-                               }\r
-                       }\r
-}\r
-\r
-/*\r
- * Rotate Left / Right though Extend\r
- *\r
- */\r
-\r
-void roxl_roxr(void)\r
-{\r
-       int Opcode, BaseCode ;\r
-       int dreg, dr, leng, ir, sreg ;\r
-       char Size=' ' ;\r
-       char * Regname="" ;\r
-       char * RegnameECX="" ;\r
-       char * Label ;\r
-\r
-       for (dreg = 0 ; dreg < 8 ; dreg++)\r
-               for (dr = 0 ; dr < 2 ; dr++)\r
-                       for (leng = 0 ; leng < 3 ; leng++)\r
-                               for (ir = 0 ; ir < 2 ; ir++)\r
-                                       for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                                       {\r
-                                               Opcode = 0xe010 | (dreg<<9) | (dr<<8) | (leng<<6) | (ir<<5) | sreg ;\r
-                                               BaseCode = Opcode & 0xe1f8 ;\r
-\r
-                                               switch (leng)\r
-                                               {\r
-                                                       case 0:\r
-                                                               Size = 'B';\r
-                                                               Regname = regnamesshort[0];\r
-                                                               RegnameECX = regnamesshort[ECX];\r
-                                                               break;\r
-                                                       case 1:\r
-                                                               Size = 'W';\r
-                                                               Regname = regnamesword[0];\r
-                                                               RegnameECX = regnamesword[ECX];\r
-                                                               break;\r
-                                                       case 2:\r
-                                                               Size = 'L';\r
-                                                               Regname = regnameslong[0];\r
-                                                               RegnameECX = regnameslong[ECX];\r
-                                                               break;\r
-                                               }\r
-\r
-                                               if (OpcodeArray[ BaseCode ] == -2)\r
-                                               {\r
-                                                       Align();\r
-                                                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-                                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                                       if (Size != 'L')\r
-                                                               TimingCycles += 6 ;\r
-                                                       else\r
-                                                               TimingCycles += 8 ;\r
-\r
-                                                       fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-                                                       fprintf(fp, "\t\t and   ebx,byte 7\n");\r
-                                                       fprintf(fp, "\t\t shr   ecx,byte 9\n");\r
-\r
-                                                       if (ir == 0)\r
-                                                       {\r
-                                                               Immediate8();\r
-                                                       }\r
-                                                       else\r
-                                                       {\r
-                                                               fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                                                               EffectiveAddressRead(0,'L',ECX,ECX,"-B--S-B",FALSE);\r
-                                                               fprintf(fp, "\t\t and   ecx,byte 63\n");\r
-                                                       }\r
-\r
-                                                       /* allow 2 cycles per shift */\r
-\r
-                                                       fprintf(fp, "\t\t mov   edx,ecx\n");\r
-                                                       fprintf(fp, "\t\t add   edx,edx\n");\r
-                                                       fprintf(fp, "\t\t sub   dword [%s],edx\n",ICOUNT);\r
-\r
-                                                       EffectiveAddressRead(0,Size,EBX,EAX,"-BC-SDB",FALSE);\r
-\r
-                                                       /* move X into C so RCR & RCL can be used */\r
-                                                       /* RCR & RCL only set the carry flag            */\r
-\r
-                                                       CopyX();\r
-\r
-                                                       if (dr == 0)\r
-                                                               fprintf(fp, "\t\t rcr   %s,cl\n",Regname);\r
-                                                       else\r
-                                                               fprintf(fp, "\t\t rcl   %s,cl\n",Regname);\r
-\r
-                                                       fprintf(fp, "\t\t setc  ch\n");\r
-                                                       SetFlags(Size,EAX,TRUE,FALSE,FALSE);\r
-/*                     fprintf(fp, "\t\t and   dl,254\n"); Test Clears Carry */\r
-\r
-                                                       EffectiveAddressWrite(0,Size,EBX,EAX,"--CDS-B",TRUE);\r
-\r
-                                                       /* if shift count is zero clear carry */\r
-\r
-                                                       Label = GenerateLabel(0,1);\r
-                                                       fprintf(fp, "\t\t test  cl,cl\n");\r
-                                                       fprintf(fp, "\t\t jz    %s\n",Label);\r
-\r
-                                                       /* Add in Carry Flag */\r
-\r
-                                                       fprintf(fp, "\t\t or    dl,ch\n");\r
-                                                       fprintf(fp, "\t\t mov   [%s],dl\n",REG_X);\r
-                                                       Completed();\r
-\r
-\r
-                                                       /* copy X onto C when shift is zero */\r
-\r
-                                                       Align();\r
-                                                       fprintf(fp, "%s:\n",Label);\r
-                                                       fprintf(fp, "\t\t mov   ecx,[%s]\n",REG_X);\r
-                                                       fprintf(fp, "\t\t and   ecx,byte 1\n");\r
-                                                       fprintf(fp, "\t\t or    edx,ecx\n");\r
-                                                       Completed();\r
-                                               }\r
-\r
-                                               OpcodeArray[Opcode] = BaseCode ;\r
-                                       }\r
-}\r
-\r
-void roxl_roxr_ea(void)\r
-{\r
-       int Opcode, BaseCode ;\r
-       int dr, mode, sreg ;\r
-       int Dest ;\r
-       char allow[] = "--2345678-------" ;\r
-\r
-       for (dr = 0 ; dr < 2 ; dr++)\r
-               for (mode = 0 ; mode < 8 ; mode++)\r
-                       for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                       {\r
-                               Opcode = 0xe4c0 | (dr<<8) | (mode<<3) | sreg ;\r
-                               BaseCode = Opcode & 0xfff8 ;\r
-\r
-                               if (mode == 7)\r
-                                       BaseCode |= sreg ;\r
-\r
-                               Dest = EAtoAMN(BaseCode, FALSE);\r
-\r
-                               if (allow[Dest&0xf] != '-')\r
-                               {\r
-                                       if (OpcodeArray[ BaseCode ] == -2)\r
-                                       {\r
-                                               Align();\r
-                                               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                                               if ((Dest >= 2) && (Dest <=10))\r
-                                                       SavePreviousPC();\r
-\r
-                                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                               TimingCycles += 8 ;\r
-\r
-                                               fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                                               EffectiveAddressRead(Dest&0xf,'W',ECX,EAX,"--C-SDB",FALSE);\r
-\r
-                                               /* move X into C so RCR & RCL can be used */\r
-                                               /* RCR & RCL only set the carry flag            */\r
-\r
-                                               CopyX();\r
-\r
-                                               if (dr == 0)\r
-                                                       fprintf(fp, "\t\t rcr   ax,1\n");\r
-                                               else\r
-                                                       fprintf(fp, "\t\t rcl   ax,1\n");\r
-\r
-                                               fprintf(fp, "\t\t setc  bl\n");\r
-                                               SetFlags('W',EAX,TRUE,FALSE,FALSE);\r
-/*                             fprintf(fp, "\t\t and   dl,254\n"); - Intel Clears on Test */\r
-                                               fprintf(fp, "\t\t or    dl,bl\n");\r
-\r
-                                               EffectiveAddressWrite(Dest&0xf,'W',ECX,EAX,"---DS-B",TRUE);\r
-\r
-                                               fprintf(fp, "\t\t mov   [%s],edx\n",REG_X);\r
-                                               Completed();\r
-                                       }\r
-\r
-                                       OpcodeArray[Opcode] = BaseCode ;\r
-                               }\r
-                       }\r
-}\r
-\r
-/*\r
- * Arithmetic Shift Left / Right\r
- *\r
- */\r
-\r
-void asl_asr(void)\r
-{\r
-       int Opcode, BaseCode ;\r
-       int dreg, dr, leng, ir, sreg ;\r
-       char Size=' ';\r
-       char * Sizename="" ;\r
-       char * Regname="" ;\r
-       char * RegnameEDX="" ;\r
-       char * RegnameECX="" ;\r
-       char * Label;\r
-\r
-       /* Normal routines for codes */\r
-\r
-       for (dreg = 0 ; dreg < 8 ; dreg++)\r
-               for (dr = 0 ; dr < 2 ; dr++)\r
-                       for (leng = 0 ; leng < 3 ; leng++)\r
-                               for (ir = 0 ; ir < 2 ; ir++)\r
-                                       for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                                       {\r
-                                               Opcode = 0xe000 | (dreg<<9) | (dr<<8) | (leng<<6) | (ir<<5) | sreg ;\r
-                                               BaseCode = Opcode & 0xe1f8 ;\r
-\r
-                                               switch (leng)\r
-                                               {\r
-                                                       case 0:\r
-                                                               Size = 'B';\r
-                                                               Regname = regnamesshort[0];\r
-                                                               RegnameECX = regnamesshort[ECX];\r
-                                                               RegnameEDX = regnamesshort[EDX];\r
-                                                               break;\r
-                                                       case 1:\r
-                                                               Size = 'W';\r
-                                                               Regname = regnamesword[0];\r
-                                                               RegnameECX = regnamesword[ECX];\r
-                                                               RegnameEDX = regnamesword[EDX];\r
-                                                               break;\r
-                                                       case 2:\r
-                                                               Size = 'L';\r
-                                                               Regname = regnameslong[0];\r
-                                                               RegnameECX = regnameslong[ECX];\r
-                                                               RegnameEDX = regnameslong[EDX];\r
-                                                               break;\r
-                                               }\r
-\r
-                                               if (OpcodeArray[ BaseCode ] == -2)\r
-                                               {\r
-                                                       Align();\r
-                                                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-                                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                                       Label = GenerateLabel(0,1);\r
-\r
-                                                       if (Size != 'L')\r
-                                                               TimingCycles += 6 ;\r
-                                                       else\r
-                                                               TimingCycles += 8 ;\r
-\r
-                                                       fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-                                                       fprintf(fp, "\t\t and   ebx,byte 7\n");\r
-                                                       fprintf(fp, "\t\t shr   ecx,byte 9\n");\r
-\r
-                                                       EffectiveAddressRead(0,Size,EBX,EAX,"-BC-S-B",FALSE);\r
-\r
-                                                       if (ir == 0)\r
-                                                       {\r
-                                                               Immediate8();\r
-                                                       }\r
-                                                       else\r
-                                                       {\r
-                                                               fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                                                               EffectiveAddressRead(0,'L',ECX,ECX,"-B--S-B",FALSE);\r
-                                                               fprintf(fp, "\t\t and   ecx,byte 63\n");\r
-                                                               fprintf(fp, "\t\t jz   short %s\n",Label);\r
-                                                       }\r
-\r
-                                                       /* allow 2 cycles per shift */\r
-\r
-                                                       fprintf(fp, "\t\t mov   edx,ecx\n");\r
-                                                       fprintf(fp, "\t\t add   edx,edx\n");\r
-                                                       fprintf(fp, "\t\t sub   dword [%s],edx\n",ICOUNT);\r
-\r
-                                                       if (dr == 0)\r
-                                                       {\r
-                                                               /* ASR */\r
-\r
-                                                               /* ASG: on the 68k, the shift count is mod 64; on the x86, the */\r
-                                                               /* shift count is mod 32; we need to check for shifts of 32-63 */\r
-                                                               /* and effectively shift 31 */\r
-                                                               fprintf(fp, "\t\t shrd  edx,ecx,6\n");\r
-                                                               fprintf(fp, "\t\t sar   edx,31\n");\r
-                                                               fprintf(fp, "\t\t and   edx,31\n");\r
-                                                               fprintf(fp, "\t\t or    ecx,edx\n");\r
-\r
-                                                               fprintf(fp, "\t\t sar   %s,cl\n",Regname);\r
-\r
-                                                               /* Mode 0 write does not affect Flags */\r
-                                                               EffectiveAddressWrite(0,Size,EBX,EAX,"---DS-B",TRUE);\r
-\r
-                                                               /* Update Flags */\r
-                                                               fprintf(fp, "\t\t lahf\n");\r
-\r
-#ifdef STALLCHECK\r
-                                               ClearRegister(EDX);\r
-                                                               fprintf(fp, "\t\t mov   dl,ah\n");\r
-#else\r
-                                                               fprintf(fp, "\t\t movzx edx,ah\n");\r
-#endif\r
-\r
-                                                               fprintf(fp, "\t\t mov   [%s],edx\n",REG_X);\r
-                                                       }\r
-                                                       else\r
-                                                       {\r
-                                                               /* ASL */\r
-\r
-                                                               /* Check to see if Overflow should be set */\r
-\r
-                                                               fprintf(fp,"\t\t mov   edi,eax\t\t; Save It\n");\r
-\r
-                                                               ClearRegister(EDX);\r
-                                                               fprintf(fp,"\t\t stc\n");\r
-                                                               fprintf(fp,"\t\t rcr   %s,1\t\t; d=1xxxx\n",RegnameEDX);\r
-                                                               fprintf(fp,"\t\t sar   %s,cl\t\t; d=1CCxx\n",RegnameEDX);\r
-                                                               fprintf(fp,"\t\t and   eax,edx\n");\r
-                                                               fprintf(fp,"\t\t jz    short %s_V\t\t; No Overflow\n",Label);\r
-                                                               fprintf(fp,"\t\t cmp   eax,edx\n");\r
-                                                               fprintf(fp,"\t\t je    short %s_V\t\t; No Overflow\n",Label);\r
-\r
-                                                               /* Set Overflow */\r
-                                                               fprintf(fp,"\t\t mov   edx,0x800\n");\r
-                                                               fprintf(fp,"\t\t jmp   short %s_OV\n",Label);\r
-\r
-                                                               fprintf(fp,"%s_V:\n",Label);\r
-                                                               ClearRegister(EDX);\r
-\r
-                                                               fprintf(fp,"%s_OV:\n",Label);\r
-\r
-                                                               /* more than 31 shifts and long */\r
-\r
-                                                               if ((ir==1) && (leng==2))\r
-                                                               {\r
-                                                                       fprintf(fp,"\t\t test  cl,0x20\n");\r
-                                                                       fprintf(fp,"\t\t jnz   short %s_32\n\n",Label);\r
-                                                               }\r
-\r
-                                                               fprintf(fp,"\t\t mov   eax,edi\t\t; Restore It\n");\r
-\r
-                                                               fprintf(fp, "\t\t sal   %s,cl\n",Regname);\r
-\r
-                                                               EffectiveAddressWrite(0,Size,EBX,EAX,"---DS-B",TRUE);\r
-                                                               fprintf(fp, "\t\t lahf\n");\r
-                                                               fprintf(fp, "\t\t mov   dl,ah\n");\r
-                                                               fprintf(fp, "\t\t mov   [%s],edx\n",REG_X);\r
-                                                       }\r
-                                                       Completed();\r
-\r
-                                                       if (ir != 0)\r
-                                                       {\r
-                                                               Align();\r
-                                                               fprintf(fp, "%s:\n",Label);\r
-\r
-\r
-                                                               if (dr == 0)\r
-                                                               {\r
-                                                                       /* ASR - Test clears V and C */\r
-                                                                       SetFlags(Size,EAX,TRUE,FALSE,FALSE);\r
-                                                               }\r
-                                                               else\r
-                                                               {\r
-                                                                       /* ASL - Keep existing Carry flag, Clear V */\r
-                                                                       fprintf(fp, "\t\t mov   ebx,edx\n");\r
-                                                                       fprintf(fp, "\t\t and   ebx,byte 1\n");\r
-                                                                       SetFlags(Size,EAX,TRUE,FALSE,FALSE);\r
-                                                                       fprintf(fp, "\t\t or    edx,ebx\n");\r
-\r
-                                                                       if (leng==2)\r
-                                                                       {\r
-                                                                               Completed();\r
-\r
-                                                                               /* > 31 Shifts */\r
-\r
-                                                                               fprintf(fp, "%s_32:\n",Label);\r
-                                                                               fprintf(fp, "\t\t mov   dl,40h\n");      // Zero flag\r
-                                                                               ClearRegister(EAX);\r
-                                                                               EffectiveAddressWrite(0,Size,EBX,EAX,"----S-B",TRUE);\r
-                                                                       }\r
-                                                               }\r
-\r
-                                                               Completed();\r
-                                                       }\r
-                                               }\r
-\r
-                                               OpcodeArray[Opcode] = BaseCode ;\r
-                                       }\r
-\r
-       /* End with special routines for ASL.x #1,Dx  */\r
-       /* To do correct V setting, ASL needs quite a */\r
-       /* bit of additional code. A Shift of one has */\r
-       /* correct flags on Intel, and is very common */\r
-       /* in 68000 programs.                                                            */\r
-\r
-       for (leng = 0 ; leng < 3 ; leng++)\r
-               for (sreg = 0 ; sreg < 8 ; sreg++)\r
-               {\r
-                       Opcode = 0xe300 | (leng<<6) | sreg ;\r
-                       BaseCode = Opcode & 0xe3c8 ;\r
-\r
-                       switch (leng)\r
-                       {\r
-                               case 0:\r
-                                       Sizename = "byte";\r
-                                       break;\r
-                               case 1:\r
-                                       Sizename = "word";\r
-                                       break;\r
-                               case 2:\r
-                                       Sizename = "long";\r
-                                       break;\r
-                       }\r
-\r
-                       if (sreg == 0)\r
-                       {\r
-                               Align();\r
-                               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                               Label = GenerateLabel(0,1);\r
-\r
-                               if (Size != 'L')\r
-                                       TimingCycles += 6 ;\r
-                               else\r
-                                       TimingCycles += 8 ;\r
-\r
-                               fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                               fprintf(fp, "\t\t sal   %s [%s+ecx*4],1\n",Sizename,REG_DAT);\r
-                               SetFlags('L',EAX,FALSE,TRUE,FALSE);\r
-                               Completed();\r
-\r
-                       }\r
-\r
-                       OpcodeArray[Opcode] = BaseCode ;\r
-               }\r
-}\r
-\r
-void asl_asr_ea(void)\r
-{\r
-       int Opcode, BaseCode ;\r
-       int dr, mode, sreg ;\r
-       int Dest ;\r
-       char allow[] = "--2345678-------" ;\r
-\r
-       for (dr = 0 ; dr < 2 ; dr++)\r
-               for (mode = 0 ; mode < 8 ; mode++)\r
-                       for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                       {\r
-                               Opcode = 0xe0c0 | (dr<<8) | (mode<<3) | sreg ;\r
-                               BaseCode = Opcode & 0xfff8 ;\r
-\r
-                               if (mode == 7)\r
-                                       BaseCode |= sreg ;\r
-\r
-                               Dest = EAtoAMN(BaseCode, FALSE);\r
-\r
-                               if (allow[Dest&0xf] != '-')\r
-                               {\r
-                                       if (OpcodeArray[ BaseCode ] == -2)\r
-                                       {\r
-\r
-                                               Align();\r
-                                               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                                               if ((Dest >= 2) && (Dest <=10))\r
-                                                       SavePreviousPC();\r
-\r
-                                               fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-                                               TimingCycles += 8 ;\r
-\r
-                                               fprintf(fp, "\t\t and   ecx,byte 7\n");\r
-                                               EffectiveAddressRead(Dest&0xf,'W',ECX,EAX,"--C-SDB",FALSE);\r
-\r
-                                               if (dr == 0)\r
-                                                       fprintf(fp, "\t\t sar   ax,1\n");\r
-                                               else\r
-                                                       fprintf(fp, "\t\t sal   ax,1\n");\r
-\r
-                                               SetFlags('W',EAX,FALSE,TRUE,TRUE);\r
-\r
-                                               EffectiveAddressWrite(Dest&0xf,'W',ECX,EAX,"----S-B",FALSE);\r
-                                               Completed();\r
-                                       }\r
-\r
-                                       OpcodeArray[Opcode] = BaseCode ;\r
-                               }\r
-                       }\r
-}\r
-\r
-/*\r
- * Divide Commands\r
- */\r
-\r
-void divides(void)\r
-{\r
-       int dreg, type, mode, sreg ;\r
-       int Opcode, BaseCode ;\r
-       int Dest ;\r
-       char allow[] = "0-23456789ab-----" ;\r
-       char TrapLabel[16];\r
-       int Cycles;\r
-\r
-       int divide_cycles[12] =\r
-       {\r
-               38,0,42,42,44,46,50,46,50,46,48,42\r
-       };\r
-\r
-       for (dreg = 0 ; dreg < 8 ; dreg++)\r
-               for (type = 0 ; type < 2 ; type++)\r
-                       for (mode = 0 ; mode < 8 ; mode++)\r
-                               for (sreg = 0 ; sreg < 8 ; sreg++)\r
-                               {\r
-                                       Opcode = 0x80c0 | (dreg<<9) | (type<<8) | (mode<<3) | sreg ;\r
-                                       BaseCode = Opcode & 0x81f8 ;\r
-                                       if (mode == 7)\r
-                                       {\r
-                                               BaseCode |= sreg ;\r
-                                       }\r
-\r
-                                       Dest = EAtoAMN(Opcode, FALSE);\r
-                                       if (allow[Dest&0x0f] != '-')\r
-                                       {\r
-                                               if (OpcodeArray[ BaseCode ] == -2)\r
-                                               {\r
-                                                       Align();\r
-                                                       fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-                                                       if ((Dest >= 2) && (Dest <=10))\r
-                                                               SavePreviousPC();\r
-\r
-                                                       fprintf(fp, "\t\t add   esi,byte 2\n\n");\r
-\r
-\r
-                                                       /* Save EDX (in case of overflow) */\r
-\r
-                                                       fprintf(fp, "\t\t and   edx,byte -2\n");\r
-                                                       fprintf(fp, "\t\t mov   [%s],edx\n",REG_CCR);\r
-\r
-\r
-                                                       /* Cycle Timing (if succeeds OK) */\r
-\r
-                                                       Cycles = divide_cycles[Dest & 0x0f] + 95 + (type * 17);\r
-\r
-                                                       if (Cycles > 127)\r
-                                                               fprintf(fp, "\t\t sub   dword [%s],%d\n",ICOUNT,Cycles);\r
-                                                       else\r
-                                                               fprintf(fp, "\t\t sub   dword [%s],byte %d\n",ICOUNT,Cycles);\r
-\r
-                                                       if (mode < 7)\r
-                                                       {\r
-                                                               fprintf(fp, "\t\t mov   ebx,ecx\n");\r
-                                                               fprintf(fp, "\t\t and   ebx,byte 7\n");\r
-                                                       }\r
-\r
-                                                       fprintf(fp, "\t\t shr   ecx, byte 9\n");\r
-                                                       fprintf(fp, "\t\t and   ecx, byte 7\n");\r
-\r
-                                                       sprintf(TrapLabel, "%s", GenerateLabel(0,1) ) ;\r
-\r
-                                                       EffectiveAddressRead(Dest,'W',EBX,EAX,"A-C-SDB",FALSE); /* source */\r
-\r
-                                                       fprintf(fp, "\t\t test  ax,ax\n");\r
-                                                       fprintf(fp, "\t\t je    near %s_ZERO\t\t;do div by zero trap\n", TrapLabel);\r
-\r
-                                                       if (type == 1) /* signed */\r
-                                                       {\r
-                                                               fprintf(fp, "\t\t movsx ebx,ax\n");\r
-                                                       }\r
-                                                       else\r
-                                                       {\r
-                                                               fprintf(fp, "\t\t movzx ebx,ax\n");\r
-                                                       }\r
-\r
-                                                       EffectiveAddressRead(0,'L',ECX,EAX,"ABC-SDB",FALSE); /* dest */\r
-\r
-                                                       if (type == 1) /* signed */\r
-                                                       {\r
-                                                               fprintf(fp, "\t\t cdq\n");                       /* EDX:EAX = 64 bit signed */\r
-                                                               fprintf(fp, "\t\t idiv  ebx\n");                 /* EBX = 32 bit */\r
-\r
-                                                               /* Check for Overflow */\r
-\r
-                                                               fprintf(fp, "\t\t movsx ebx,ax\n");\r
-                                                               fprintf(fp, "\t\t cmp   eax,ebx\n");\r
-                                                               fprintf(fp, "\t\t jne   short %s_OVER\n",TrapLabel);\r
-                                                       }\r
-                                                       else\r
-                                                       {\r
-                                                               ClearRegister(EDX);\r
-                                                               fprintf(fp, "\t\t div   ebx\n");\r
-\r
-                                                               /* Check for Overflow */\r
-\r
-                                                               fprintf(fp, "\t\t test  eax, 0FFFF0000H\n");\r
-                                                               fprintf(fp, "\t\t jnz   short %s_OVER\n",TrapLabel);\r
-                                                       }\r
-\r
-                                                       /* Sort out Result */\r
-\r
-                                                       fprintf(fp, "\t\t shl   edx, byte 16\n");\r
-                                                       fprintf(fp, "\t\t mov   dx,ax\n");\r
-                                                       fprintf(fp, "\t\t mov   [%s+ECX*4],edx\n",REG_DAT);\r
-                                                       SetFlags('W',EDX,TRUE,FALSE,FALSE);\r
-\r
-                                                       Completed();\r
-\r
-\r
-                                                       /* Overflow */\r
-\r
-                                                       Align();\r
-                                                       fprintf(fp, "%s_OVER:\n",TrapLabel);\r
-                                                       fprintf(fp, "\t\t mov   edx,[%s]\n",REG_CCR);\r
-                                                       fprintf(fp, "\t\t or    edx,0x0800\t\t;V flag\n");\r
-                                                       Completed();\r
-\r
-\r
-                                                       /* Division by Zero */\r
-\r
-                                                       Align();\r
-                                                       fprintf(fp, "%s_ZERO:\t\t ;Do divide by zero trap\n", TrapLabel);\r
-\r
-                                                       /* Correct cycle counter for error */\r
-\r
-                                                       fprintf(fp, "\t\t add   dword [%s],byte %d\n",ICOUNT,95 + (type * 17));\r
-                                                       fprintf(fp, "\t\t mov   al,5\n");\r
-                                                       Exception(-1,BaseCode);\r
-                                                       Completed();\r
-                                               }\r
-\r
-                                               OpcodeArray[Opcode] = BaseCode ;\r
-                                       }\r
-                               }\r
-}\r
-\r
-\r
-/*\r
- * 68010 Extra Opcodes\r
- *\r
- * move from CCR is done above\r
- *\r
- */\r
-\r
-void ReturnandDeallocate(void)\r
-{\r
-       int     BaseCode = 0x4e74 ;\r
-\r
-       if (OpcodeArray[BaseCode] == -2)\r
-       {\r
-               Align();\r
-               fprintf(fp, "%s:\n",GenerateLabel(BaseCode,0));\r
-\r
-               CheckCPUtype(1);\r
-\r
-               SavePreviousPC();\r
-\r
-               TimingCycles += 16;\r
-\r
-               OpcodeArray[BaseCode] = BaseCode ;\r
-\r
-               /* Get Return Address */\r
-\r
-               fprintf(fp, "\t\t mov   eax,[%s]\n",REG_A7);\r
-               Memory_Read('L',EAX,"---D--B",1);\r
-\r
-\r
-               /* Get Displacement */\r
-\r
-               Memory_Fetch('W',EBX,TRUE);\r
-\r
-\r
-               /* Set PC = New Address */\r
-\r
-               fprintf(fp, "\t\t mov   esi,eax\n");\r
-\r
-\r
-               /* Correct Stack for Return Address and Displacement */\r
-\r
-               fprintf(fp, "\t\t add   ebx,byte 4\n");\r
-               fprintf(fp, "\t\t add   dword [%s],ebx\n",REG_A7);\r
-\r
-               MemoryBanking(BaseCode);\r
-               Completed();\r
-       }\r
-}\r
-\r
-void MoveControlRegister(void)\r
-{\r
-       int  Direction;\r
-       int  BaseCode = 0x4e7a ;\r
-\r
-       for (Direction=0;Direction<2;Direction++)\r
-       {\r
-               Align();\r
-               fprintf(fp, "%s:\n",GenerateLabel(BaseCode+Direction,0));\r
-\r
-               TimingCycles += 4; /* Assume same as move usp */\r
-\r
-               CheckCPUtype(1);\r
-\r
-               fprintf(fp, "\t\t test  byte [%s],20h \t\t\t; Supervisor Mode ?\n",REG_SRH);\r
-               fprintf(fp, "\t\t jz    short OP%d_%4.4x_Trap\n",CPU,BaseCode+Direction);\r
-\r
-               fprintf(fp, "\t\t add   esi,byte 2\n");\r
-               if (CPU==2)\r
-                       fprintf(fp, "\t\t xor   esi,2\n");      /* ASG */\r
-#ifdef STALLCHECK\r
-               ClearRegister(EBX);\r
-               fprintf(fp, "\t\t mov   bx,[esi+ebp]\n");\r
-#else\r
-               fprintf(fp, "\t\t movzx ebx,word [esi+ebp]\n");\r
-#endif\r
-               if (CPU==2)\r
-                       fprintf(fp, "\t\t xor   esi,2\n");      /* ASG */\r
-\r
-               fprintf(fp, "\t\t add   esi,byte 2\n");\r
-               fprintf(fp, "\t\t mov   eax,ebx\n");\r
-               fprintf(fp, "\t\t mov   ecx,ebx\n");\r
-\r
-               /* Sort out Register */\r
-\r
-               fprintf(fp, "\t\t shr   ebx,12\n");\r
-\r
-               /* Sort out Control Register ID */\r
-\r
-               fprintf(fp, "\t\t and   eax,byte 1\n");\r
-               fprintf(fp, "\t\t shr   ecx,10\n");\r
-               fprintf(fp, "\t\t and   ecx,2\n");\r
-               fprintf(fp, "\t\t or    ecx,eax\n");\r
-\r
-               if (Direction==0)\r
-               {\r
-                       /* from Control */\r
-\r
-                       fprintf(fp, "\t\t mov   eax,[%s+ecx*4]\n",REG_SFC);\r
-                       fprintf(fp, "\t\t mov   %s,eax\n",REG_DAT_EBX);\r
-               }\r
-               else\r
-               {\r
-                       /* To Control */\r
-\r
-                       fprintf(fp, "\t\t mov   eax,%s\n",REG_DAT_EBX);\r
-\r
-                       /* Mask out for SFC & DFC */\r
-\r
-                       fprintf(fp, "\t\t test  cl,2\n");\r
-                       fprintf(fp, "\t\t jne   short OP%d_%4.4x_Mask\n",CPU,BaseCode+Direction);\r
-                       fprintf(fp, "\t\t and   eax,byte 7\n");\r
-                       fprintf(fp, "OP%d_%4.4x_Mask:\n",CPU,BaseCode+Direction);\r
-\r
-                       /* Write to control */\r
-\r
-                       fprintf(fp, "\t\t mov   [%s+ecx*4],eax\n",REG_SFC);\r
-               }\r
-\r
-               Completed();\r
-\r
-               /* Not Supervisor Mode */\r
-\r
-               Align();\r
-               fprintf(fp, "OP%d_%4.4x_Trap:\n",CPU,BaseCode+Direction);\r
-               Exception(8,BaseCode+Direction);\r
-\r
-               OpcodeArray[BaseCode+Direction] = BaseCode+Direction;\r
-       }\r
-}\r
-\r
-void MoveAddressSpace(void)\r
-{\r
-}\r
-\r
-/*\r
- * Generate Jump Table\r
- *\r
- */\r
-\r
-void JumpTable(void)\r
-{\r
-       int Opcode,l,op;\r
-\r
-       fprintf(fp, "DD OP%d_1000\n",CPU);\r
-\r
-       l = 0 ;\r
-       for (Opcode=0x0;Opcode<0x10000;)\r
-       {\r
-\r
-               op = OpcodeArray[Opcode];\r
-\r
-               fprintf(fp, "DD ");\r
-\r
-               l = 1 ;\r
-               while (op == OpcodeArray[Opcode+l] && ((Opcode+l) & 0xfff) != 0)\r
-               {\r
-                       l++ ;\r
-               }\r
-\r
-               Opcode += l ;\r
-\r
-               if (l > 255)\r
-               {\r
-                       if (op > -1)\r
-                               fprintf(fp, "OP%d_%4.4x - OP%d_1000\n",CPU,op,CPU);\r
-                       else\r
-                               fprintf(fp, "ILLEGAL - OP%d_1000\n",CPU);\r
-\r
-                       fprintf(fp, "DW %d\n", l);\r
-               }\r
-               else\r
-               {\r
-                       if (op > -1)\r
-                               fprintf(fp, "(OP%d_%4.4x - OP%d_1000) + (%d * 1000000h)\n",CPU,op,CPU,l);\r
-                       else\r
-                               fprintf(fp, "(ILLEGAL - OP%d_1000) + (%d * 1000000h)\n",CPU,l);\r
-               }\r
-       }\r
-}\r
-\r
-void CodeSegmentBegin(void)\r
-{\r
-\r
-/* Messages */\r
-\r
-       fprintf(fp, "; Make68K - V%s - Copyright 1998, Mike Coates (mame@btinternet.com)\n", VERSION);\r
-       fprintf(fp, ";                               & Darren Olafson (deo@mail.island.net)\n\n");\r
-\r
-/* Needed code to make it work! */\r
-\r
-       fprintf(fp, "\t\t BITS 32\n\n");\r
-\r
-       fprintf(fp, "\t\t GLOBAL %s_RUN\n",CPUtype);\r
-       fprintf(fp, "\t\t GLOBAL %s_RESET\n",CPUtype);\r
-       fprintf(fp, "\t\t GLOBAL %s_regs\n",CPUtype);\r
-       fprintf(fp, "\t\t GLOBAL %s_COMPTABLE\n",CPUtype);\r
-       fprintf(fp, "\t\t GLOBAL %s_OPCODETABLE\n",CPUtype);\r
-\r
-       /* ASG - only one interface to memory now */\r
-       fprintf(fp, "\t\t EXTERN _m68k_ICount\n");\r
-       fprintf(fp, "\t\t EXTERN _a68k_memory_intf\n");\r
-       fprintf(fp, "\t\t EXTERN _mem_amask\n");\r
-\r
-       fprintf(fp, "; Vars Mame declares / needs access to\n\n");\r
-\r
-       fprintf(fp, "\t\t EXTERN _mame_debug\n");\r
-       fprintf(fp, "\t\t EXTERN _illegal_op\n");\r
-       fprintf(fp, "\t\t EXTERN _illegal_pc\n");\r
-\r
-       fprintf(fp, "\t\t EXTERN _OP_ROM\n");\r
-       fprintf(fp, "\t\t EXTERN _OP_RAM\n");\r
-\r
-       fprintf(fp, "\t\t EXTERN _opcode_entry\n");\r
-       fprintf(fp, "\t\t EXTERN _cur_mrhard\n");\r
-\r
-//#ifdef MAME_DEBUG\r
-       fprintf(fp, "\t\t EXTERN _m68k_illegal_opcode\n");\r
-//#endif\r
-\r
-#ifdef OS2\r
-       fprintf(fp, "\t\t SECTION maincode USE32 FLAT CLASS=CODE\n\n");\r
-#else\r
-       fprintf(fp, "\t\t SECTION .text\n\n");\r
-#endif\r
-\r
-\r
-\r
-/* Reset routine */\r
-\r
-       fprintf(fp, "%s_RESET:\n",CPUtype);\r
-\r
-       fprintf(fp, "\t\t pushad\n\n");\r
-\r
-       fprintf(fp, "; Build Jump Table (not optimised!)\n\n");\r
-\r
-       fprintf(fp, "\t\t lea   edi,[%s_OPCODETABLE]\t\t; Jump Table\n", CPUtype);\r
-       fprintf(fp, "\t\t lea   esi,[%s_COMPTABLE]\t\t; RLE Compressed Table\n", CPUtype);\r
-\r
-       /* Reference Point in EBP */\r
-\r
-       fprintf(fp, "\t\t mov   ebp,[esi]\n");\r
-       fprintf(fp, "\t\t add   esi,byte 4\n");\r
-\r
-       fprintf(fp, "RESET0:\n");\r
-       fprintf(fp, "\t\t mov   eax,[esi]\n");\r
-       fprintf(fp, "\t\t mov   ecx,eax\n");\r
-       fprintf(fp, "\t\t and   eax,0xffffff\n");\r
-       fprintf(fp, "\t\t add   eax,ebp\n");\r
-       fprintf(fp, "\t\t add   esi,byte 4\n");\r
-\r
-       /* if count is zero, then it's a word RLE length */\r
-\r
-       fprintf(fp, "\t\t shr   ecx,24\n");\r
-       fprintf(fp, "\t\t jne   short RESET1\n");\r
-\r
-#ifdef STALLCHECK\r
-       ClearRegister(ECX);\r
-       fprintf(fp, "\t\t mov   cx,[esi]\t\t; Repeats\n");\r
-#else\r
-       fprintf(fp, "\t\t movzx ecx,word [esi]\t\t; Repeats\n");\r
-#endif\r
-\r
-       fprintf(fp, "\t\t add   esi,byte 2\n");\r
-       fprintf(fp, "\t\t jecxz RESET2\t\t; Finished!\n");\r
-\r
-       fprintf(fp, "RESET1:\n");\r
-       fprintf(fp, "\t\t mov   [edi],eax\n");\r
-       fprintf(fp, "\t\t add   edi,byte 4\n");\r
-       fprintf(fp, "\t\t dec   ecx\n");\r
-       fprintf(fp, "\t\t jnz   short RESET1\n");\r
-       fprintf(fp, "\t\t jmp   short RESET0\n");\r
-\r
-       fprintf(fp, "RESET2:\n");\r
-       fprintf(fp, "\t\t popad\n");\r
-       fprintf(fp, "\t\t ret\n\n");\r
-\r
-/* Emulation Entry Point */\r
-\r
-       Align();\r
-\r
-       fprintf(fp, "%s_RUN:\n",CPUtype);\r
-\r
-       fprintf(fp, "\t\t pushad\n");\r
-       fprintf(fp, "\t\t mov   esi,[%s]\n",REG_PC);\r
-       fprintf(fp, "\t\t mov   edx,[%s]\n",REG_CCR);\r
-       fprintf(fp, "\t\t mov   ebp,dword [_OP_ROM]\n");\r
-\r
-       fprintf(fp,"; Check for Interrupt waiting\n\n");\r
-       fprintf(fp,"\t\t test  [%s],byte 07H\n",REG_IRQ);\r
-       fprintf(fp,"\t\t jne   near interrupt\n\n");\r
-\r
-       fprintf(fp, "IntCont:\n");\r
-\r
-       /* See if was only called to check for Interrupt */\r
-\r
-       fprintf(fp, "\t\t test  dword [%s],-1\n",ICOUNT);\r
-       fprintf(fp, "\t\t js    short MainExit\n\n");\r
-\r
-       if(CPU==2)\r
-       {\r
-                 /* 32 Bit */\r
-               fprintf(fp, "\t\t mov   eax,2\n");              /* ASG */\r
-               fprintf(fp, "\t\t xor   eax,esi\n");                                                    /* ASG */\r
-#ifdef STALLCHECK\r
-               ClearRegister(ECX);\r
-               fprintf(fp, "\t\t mov   cx,[eax+ebp]\n");\r
-#else\r
-               fprintf(fp, "\t\t movzx ecx,word [eax+ebp]\n");\r
-#endif\r
-       }\r
-       else\r
-       {\r
-                 /* 16 Bit Fetch */\r
-#ifdef STALLCHECK\r
-               ClearRegister(ECX);\r
-               fprintf(fp, "\t\t mov   cx,[esi+ebp]\n");\r
-#else\r
-               fprintf(fp, "\t\t movzx ecx,word [esi+ebp]\n");\r
-#endif\r
-       }\r
-       fprintf(fp, "\t\t jmp   [%s_OPCODETABLE+ecx*4]\n", CPUtype);\r
-\r
-       Align();\r
-\r
-       fprintf(fp, "MainExit:\n");\r
-       fprintf(fp, "\t\t mov   [%s],esi\t\t; Save PC\n",REG_PC);\r
-       fprintf(fp, "\t\t mov   [%s],edx\n",REG_CCR);\r
-       fprintf(fp, "\t\t test  byte [%s],20H\n",REG_SRH);\r
-       fprintf(fp, "\t\t mov   eax,[%s]\t\t; Get A7\n",REG_A7);\r
-       fprintf(fp, "\t\t jne   short ME1\t\t; Mode ?\n");\r
-       fprintf(fp, "\t\t mov   [%s],eax\t\t;Save in USP\n",REG_USP);\r
-       fprintf(fp, "\t\t jmp   short MC68Kexit\n");\r
-       fprintf(fp, "ME1:\n");\r
-       fprintf(fp, "\t\t mov   [%s],eax\n",REG_ISP);\r
-       fprintf(fp, "MC68Kexit:\n");\r
-\r
-       /* If in Debug mode make normal SR register */\r
-\r
-#ifdef MAME_DEBUG\r
-\r
-       ReadCCR('W', ECX);\r
-       fprintf(fp, "\t\t mov   [%s],eax\n\n",REG_S);\r
-\r
-#endif\r
-\r
-       fprintf(fp, "\t\t popad\n");\r
-       fprintf(fp, "\t\t ret\n");\r
-\r
-/* Check for Pending Interrupts */\r
-\r
-       Align();\r
-       fprintf(fp, "; Interrupt check\n\n");\r
-\r
-       fprintf(fp, "interrupt:\n");\r
-\r
-       /* check to exclude interrupts */\r
-\r
-       fprintf(fp, "\t\t mov   eax,[%s]\n",REG_IRQ);\r
-       fprintf(fp, "\t\t and   eax,byte 07H\n");\r
-\r
-       fprintf(fp, "\t\t cmp   al,7\t\t ; Always take 7\n");\r
-       fprintf(fp, "\t\t je    short procint\n\n");\r
-\r
-       fprintf(fp, "\t\t mov   ebx,[%s]\t\t; int mask\n",REG_SRH);\r
-       fprintf(fp, "\t\t and   ebx,byte 07H\n");\r
-       fprintf(fp, "\t\t cmp   eax,ebx\n");\r
-       fprintf(fp, "\t\t jle   near IntCont\n\n");\r
-\r
-       /* Take pending Interrupt */\r
-\r
-       Align();\r
-       fprintf(fp, "procint:\n");\r
-       fprintf(fp, "\t\t and   byte [%s],78h\t\t; remove interrupt & stop\n\n",REG_IRQ);\r
-\r
-       /* Get Interrupt Vector from callback */\r
-\r
-       fprintf(fp, "\t\t push  eax\t\t; save level\n\n");\r
-\r
-       if (SavedRegs[EBX] == '-')\r
-       {\r
-               fprintf(fp, "\t\t push  EBX\n");\r
-       }\r
-       else\r
-       {\r
-               fprintf(fp, "\t\t mov   ebx,eax\n");\r
-       }\r
-\r
-       if (SavedRegs[ESI] == '-')\r
-       {\r
-               fprintf(fp, "\t\t mov   [%s],ESI\n",REG_PC);\r
-       }\r
-\r
-       if (SavedRegs[EDX] == '-')\r
-       {\r
-               fprintf(fp, "\t\t mov   [%s],edx\n",REG_CCR);\r
-       }\r
-\r
-/* ----- Win32 uses FASTCALL (By Kenjo)----- */\r
-\r
-#ifdef FASTCALL\r
-       fprintf(fp, "\t\t mov   %s, eax\t\t; irq line #\n",FASTCALL_FIRST_REG);\r
-       fprintf(fp, "\t\t call  dword [%s]\t; get the IRQ level\n", REG_IRQ_CALLBACK);\r
-#else\r
-       fprintf(fp, "\t\t push  eax\t\t; irq line #\n");\r
-       fprintf(fp, "\t\t call  dword [%s]\t; get the IRQ level\n", REG_IRQ_CALLBACK);\r
-       fprintf(fp, "\t\t lea   esp,[esp+4]\n");\r
-#endif\r
-\r
-       if (SavedRegs[EDX] == '-')\r
-       {\r
-               fprintf(fp, "\t\t mov   edx,[%s]\n",REG_CCR);\r
-       }\r
-\r
-       if (SavedRegs[ESI] == '-')\r
-       {\r
-               fprintf(fp, "\t\t mov   esi,[%s]\n",REG_PC);\r
-       }\r
-\r
-       /* Do we want to use normal vector number ? */\r
-\r
-\r
-       fprintf(fp, "\t\t test  eax,eax\n");\r
-       fprintf(fp, "\t\t jns   short AUTOVECTOR\n");\r
-\r
-       /* Only need EBX restored if default vector to be used */\r
-\r
-       if (SavedRegs[EBX] == '-')\r
-       {\r
-               fprintf(fp, "\t\t pop   EBX\n");\r
-       }\r
-\r
-       /* Just get default vector */\r
-\r
-       fprintf(fp, "\t\t mov   eax,ebx\n");\r
-\r
-       fprintf(fp, "\t\t add   eax,byte 24\t\t; Vector\n\n");\r
-\r
-       fprintf(fp, "AUTOVECTOR:\n\n");\r
-\r
-       Exception(-1,0xFFFF);\r
-\r
-       fprintf(fp, "\t\t pop   eax\t\t; set Int mask\n");\r
-       fprintf(fp, "\t\t mov   bl,byte [%s]\n",REG_SRH);\r
-       fprintf(fp, "\t\t and   bl,0F8h\n");\r
-       fprintf(fp, "\t\t or    bl,al\n");\r
-       fprintf(fp, "\t\t mov   byte [%s],bl\n\n",REG_SRH);\r
-       fprintf(fp, "\t\t jmp   IntCont\n\n");\r
-\r
-/* Exception Routine */\r
-\r
-       Align();\r
-       fprintf(fp, "Exception:\n");\r
-       fprintf(fp, "\t\t push  edx\t\t; Save flags\n");\r
-       fprintf(fp, "\t\t and   eax,0FFH\t\t; Zero Extend IRQ Vector\n");\r
-\r
-       fprintf(fp, "\t\t push  eax\t\t; Save for Later\n");\r
-\r
-       /*  Update Cycle Count */\r
-\r
-       fprintf(fp, "\t\t mov   al,[exception_cycles+eax]\t\t; Get Cycles\n");\r
-       fprintf(fp, "\t\t sub   [%s],eax\t\t; Decrement ICount\n",ICOUNT);\r
-\r
-       ReadCCR('W',ECX);\r
-\r
-       fprintf(fp, "\t\t mov   edi,[%s]\t\t; Get A7\n",REG_A7);\r
-\r
-       fprintf(fp, "\t\t test  ah,20H\t; Which Mode ?\n");\r
-       fprintf(fp, "\t\t jne   short ExSuperMode\t\t; Supervisor\n");\r
-\r
-       fprintf(fp, "\t\t or    byte [%s],20H\t; Set Supervisor Mode\n",REG_SRH);\r
-       fprintf(fp, "\t\t mov   [%s],edi\t\t; Save in USP\n",REG_USP);\r
-       fprintf(fp, "\t\t mov   edi,[%s]\t\t; Get ISP\n",REG_ISP);\r
-\r
-       /* Write SR first (since it's in a register) */\r
-\r
-       fprintf(fp, "ExSuperMode:\n");\r
-       fprintf(fp, "\t\t sub   edi,byte 6\n");\r
-       fprintf(fp, "\t\t mov   [%s],edi\t\t; Put in A7\n",REG_A7);\r
-       Memory_Write('W',EDI,EAX,"----S-B",2);\r
-\r
-       /* Then write PC */\r
-\r
-       fprintf(fp, "\t\t add   edi,byte 2\n");\r
-       Memory_Write('L',EDI,ESI,"------B",0);\r
-\r
-       /* Get new PC */\r
-\r
-       fprintf(fp, "\t\t pop   eax\t\t;Level\n");\r
-       fprintf(fp, "\t\t shl   eax,2\n");\r
-       fprintf(fp, "\t\t add   eax,[%s]\n",REG_VBR);     /* 68010+ Vector Base */\r
-\r
-       /* Direct Read */\r
-\r
-       Memory_Read('L',EAX,"------B",0);\r
-\r
-       fprintf(fp, "\t\t mov   esi,eax\t\t;Set PC\n");\r
-       fprintf(fp, "\t\t pop   edx\t\t; Restore flags\n");\r
-\r
-       /* Sort out any bank changes */\r
-       MemoryBanking(1);\r
-\r
-       fprintf(fp, "\t\t ret\n");\r
-}\r
-\r
-void CodeSegmentEnd(void)\r
-{\r
-#ifdef OS2\r
-       fprintf(fp, "\t\t SECTION maindata USE32 FLAT CLASS=DATA\n\n");\r
-#else\r
-       fprintf(fp, "\t\t SECTION .data\n");\r
-#endif\r
-\r
-       fprintf(fp, "\n\t\t align 16\n");\r
-       fprintf(fp, "%s_ICount\n",CPUtype);\r
-       fprintf(fp, "asm_count\t DD 0\n\n");\r
-\r
-       /* Memory structure for 68000 registers  */\r
-       /* Same layout as structure in CPUDEFS.H */\r
-\r
-       fprintf(fp, "\n\n; Register Structure\n\n");\r
-       fprintf(fp, "%s_regs\n",CPUtype);\r
-\r
-       fprintf(fp, "R_D0\t DD 0\t\t\t ; Data Registers\n");\r
-       fprintf(fp, "R_D1\t DD 0\n");\r
-       fprintf(fp, "R_D2\t DD 0\n");\r
-       fprintf(fp, "R_D3\t DD 0\n");\r
-       fprintf(fp, "R_D4\t DD 0\n");\r
-       fprintf(fp, "R_D5\t DD 0\n");\r
-       fprintf(fp, "R_D6\t DD 0\n");\r
-       fprintf(fp, "R_D7\t DD 0\n\n");\r
-\r
-       fprintf(fp, "R_A0\t DD 0\t\t\t ; Address Registers\n");\r
-       fprintf(fp, "R_A1\t DD 0\n");\r
-       fprintf(fp, "R_A2\t DD 0\n");\r
-       fprintf(fp, "R_A3\t DD 0\n");\r
-       fprintf(fp, "R_A4\t DD 0\n");\r
-       fprintf(fp, "R_A5\t DD 0\n");\r
-       fprintf(fp, "R_A6\t DD 0\n");\r
-       fprintf(fp, "R_A7\t DD 0\n\n");\r
-\r
-       fprintf(fp, "R_ISP\t DD 0\t\t\t ; Supervisor Stack\n");\r
-       fprintf(fp, "R_SR_H\t DD 0\t\t\t ; Status Register High TuSuuIII\n");\r
-       fprintf(fp, "R_CCR\t DD 0\t\t\t ; CCR Register in Intel Format\n");\r
-       fprintf(fp, "R_XC\t DD 0\t\t\t ; Extended Carry uuuuuuuX\n");\r
-\r
-       fprintf(fp, "R_PC\t DD 0\t\t\t ; Program Counter\n");\r
-       fprintf(fp, "R_IRQ\t DD 0\t\t\t ; IRQ Request Level\n\n");\r
-       fprintf(fp, "R_SR\t DD 0\t\t\t ; Motorola Format SR\n\n");\r
-\r
-       fprintf(fp, "R_IRQ_CALLBACK\t DD 0\t\t\t ; irq callback (get vector)\n\n");\r
-\r
-       fprintf(fp, "R_PPC\t DD 0\t\t\t ; Previous Program Counter\n");\r
-\r
-       fprintf(fp, "R_RESET_CALLBACK\t DD 0\t\t\t ; Reset Callback\n");\r
-\r
-       fprintf(fp, "R_SFC\t DD 0\t\t\t ; Source Function Call\n");\r
-       fprintf(fp, "R_DFC\t DD 0\t\t\t ; Destination Function Call\n");\r
-       fprintf(fp, "R_USP\t DD 0\t\t\t ; User Stack\n");\r
-       fprintf(fp, "R_VBR\t DD 0\t\t\t ; Vector Base\n");\r
-\r
-       fprintf(fp, "asmbank\t DD 0\n\n");\r
-       fprintf(fp, "CPUversion\t DD 0\n\n");\r
-       fprintf(fp, "FullPC\t DD 0\n\n");\r
-\r
-       /* Extra space for variables mame uses for debugger */\r
-\r
-       fprintf(fp, "\t\t DD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");\r
-       fprintf(fp, "\t\t DD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");\r
-       fprintf(fp, "\t\t DD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");\r
-       fprintf(fp, "\t\t DD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");\r
-       fprintf(fp, "\t\t DD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");\r
-       fprintf(fp, "\t\t DD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");\r
-       fprintf(fp, "\t\t DD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");\r
-       fprintf(fp, "\t\t DD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n\n");\r
-\r
-       /* Safe Memory Locations */\r
-\r
-       fprintf(fp, "\t\t ALIGN 16\n");\r
-\r
-       fprintf(fp, "\n\nIntelFlag\t\t\t\t; Intel Flag Lookup Table\n");\r
-       fprintf(fp, "\t\t DD 0000h,0001h,0800h,0801h,0040h,0041h,0840h,0841h\n");\r
-       fprintf(fp, "\t\t DD 0080h,0081h,0880h,0881h,00C0h,00C1h,08C0h,08C1h\n");\r
-       fprintf(fp, "\t\t DD 0100h,0101h,0900h,0901h,0140h,0141h,0940h,0941h\n");\r
-       fprintf(fp, "\t\t DD 0180h,0181h,0980h,0981h,01C0h,01C1h,09C0h,09C1h\n");\r
-\r
-#if 0\r
-       fprintf(fp, "\n\nImmTable\n");\r
-       fprintf(fp, "\t\t DD 8,1,2,3,4,5,6,7\n\n");\r
-#endif\r
-\r
-\r
-\r
-       /* Exception Timing Table */\r
-\r
-       fprintf(fp, "exception_cycles\n");\r
-       fprintf(fp, "\t\t DB 0, 0, 0, 0, 38, 42, 44, 38, 38, 0, 38, 38, 0, 0, 0, 0\n");\r
-       fprintf(fp, "\t\t DB 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46\n");\r
-       fprintf(fp, "\t\t DB 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38\n\n");\r
-\r
-       fprintf(fp, "; RLE Compressed Jump Table\n\n");\r
-\r
-       fprintf(fp, "%s_COMPTABLE\n\n", CPUtype);\r
-\r
-       fprintf(fp, "%cinclude '%s'\n\n",'%', comptab);\r
-\r
-       fprintf(fp, "\t\tDW   0,0,0\n\n");\r
-\r
-\r
-/* If Win32, put the table area in .data section (Kenjo) */\r
-\r
-#ifdef WIN32\r
-\r
-       fprintf(fp, "%s_OPCODETABLE\tTIMES  65536  DD 0\n\n", CPUtype);\r
-\r
-#else\r
-\r
-#ifdef OS2\r
-       fprintf(fp, "\t\t SECTION tempdata USE32 FLAT CLASS=BSS\n\n");\r
-#else\r
-       fprintf(fp, "\t\t SECTION .bss\n");\r
-#endif\r
-\r
-       fprintf(fp, "%s_OPCODETABLE\tRESD  65536\n\n", CPUtype);\r
-\r
-#endif\r
-\r
-}\r
-\r
-void EmitCode(void)\r
-{\r
-       CodeSegmentBegin();\r
-\r
-       /* Instructions */\r
-\r
-       moveinstructions();                               /* 1000 to 3FFF MOVE.X */\r
-       immediate();                                            /* 0### XXX.I */\r
-       bitdynamic();                                                     /* 0### dynamic bit operations */\r
-       movep();                                                                         /* 0### Move Peripheral */\r
-       bitstatic();                                            /* 08## static bit operations */\r
-       LoadEffectiveAddress();                  /* 4### */\r
-       PushEffectiveAddress();                  /* ???? */\r
-       movesr();                                                       /* 4#C# */\r
-       opcode5();                                                                /* 5000 to 5FFF ADDQ,SUBQ,Scc and DBcc */\r
-       branchinstructions();                           /* 6000 to 6FFF Bcc,BSR */\r
-       moveq();                                                 /* 7000 to 7FFF MOVEQ */\r
-       abcd_sbcd();                                            /* 8### Decimal Add/Sub */\r
-       typelogicalmath();                                              /* Various ranges */\r
-       addx_subx();\r
-       divides();\r
-       swap();\r
-       not();                                                          /* also neg negx clr */\r
-       moveusp();\r
-       chk();\r
-       exg();\r
-       cmpm();\r
-       mul();\r
-       ReturnandRestore();\r
-       rts();\r
-       jmp_jsr();\r
-       nbcd();\r
-       tas();\r
-       trap();\r
-       trapv();\r
-       reset();\r
-       nop();\r
-       stop();\r
-       ext();\r
-       ReturnFromException();\r
-       tst();\r
-       movem_reg_ea();\r
-       movem_ea_reg();\r
-       link();\r
-       unlinkasm();\r
-       asl_asr();                                                /* E### Shift Commands */\r
-       asl_asr_ea();\r
-       roxl_roxr();\r
-       roxl_roxr_ea();\r
-       lsl_lsr();\r
-       lsl_lsr_ea();\r
-       rol_ror();\r
-       rol_ror_ea();\r
-       LineA();                                                 /* A000 to AFFF Line A */\r
-       LineF();                                                        /* F000 to FFFF Line F */\r
-       illegal_opcode();\r
-\r
-       ReturnandDeallocate();                    /* 68010 Commands */\r
-       MoveControlRegister();\r
-       MoveAddressSpace();\r
-\r
-       if(CPU==2)                                              /* 68020 Commands */\r
-       {\r
-               divl();\r
-               mull();\r
-               bfext();\r
-       }\r
-\r
-       CodeSegmentEnd();\r
-}\r
-\r
-int main(int argc, char **argv)\r
-{\r
-       int dwLoop;\r
-\r
-       printf("\nMake68K - V%s - Copyright 1998, Mike Coates (mame@btinternet.com)\n", VERSION);\r
-       printf("                            1999, & Darren Olafson (deo@mail.island.net)\n");\r
-       printf("                            2000\n");\r
-\r
-       if (argc != 4 && argc != 5)\r
-       {\r
-               printf("Usage: %s outfile jumptable-outfile type [ppro]\n", argv[0]);\r
-               exit(1);\r
-       }\r
-\r
-       printf("Building 680%s              2001\n\n",argv[3]);\r
-\r
-       for (dwLoop=0;dwLoop<65536;)  OpcodeArray[dwLoop++] = -2;\r
-\r
-       codebuf=malloc(64);\r
-       if (!codebuf)\r
-       {\r
-               printf ("Memory allocation error\n");\r
-               exit(3);\r
-       }\r
-\r
-       /* Emit the code */\r
-       fp = fopen(argv[1], "w");\r
-       if (!fp)\r
-       {\r
-               fprintf(stderr, "Can't open %s for writing\n", argv[1]);\r
-               exit(1);\r
-       }\r
-\r
-       comptab = argv[2];\r
-\r
-\r
-       CPUtype = malloc(64);\r
-#ifdef OS2\r
-       sprintf(CPUtype,"M680%s",argv[3]);\r
-#else\r
-       sprintf(CPUtype,"_M680%s",argv[3]);\r
-#endif\r
-\r
-       if(argv[3][0]=='2') CPU = 2;\r
-       if(argc > 4 && !stricmp(argv[4], "ppro"))\r
-       {\r
-                 ppro = 1;\r
-                 printf("Generating ppro opcodes\n");\r
-       }\r
-\r
-       EmitCode();\r
-\r
-       fclose(fp);\r
-\r
-       printf("\n%d Unique Opcodes\n",Opcount);\r
-\r
-       /* output Jump table to separate file */\r
-       fp = fopen(argv[2], "w");\r
-       if (!fp)\r
-       {\r
-               fprintf(stderr, "Can't open %s for writing\n", argv[2]);\r
-               exit(1);\r
-       }\r
-\r
-       JumpTable();\r
-\r
-       fclose(fp);\r
-\r
-       exit(0);\r
-}\r
index 1195593..7b12343 100644 (file)
@@ -125,21 +125,6 @@ typedef union
        signed int SD;\r
 } famec_union32;\r
 \r
-/* The memory blocks must be in native (Motorola) format */\r
-struct M68K_PROGRAM {\r
-       unsigned low_addr;\r
-       unsigned high_addr;\r
-       unsigned offset;\r
-};\r
-\r
-/* The memory blocks must be in native (Motorola) format */\r
-struct M68K_DATA {\r
-       unsigned low_addr;\r
-       unsigned high_addr;\r
-       void    *mem_handler;\r
-       void    *data;\r
-};\r
-\r
 /* M68K CPU CONTEXT */\r
 typedef struct\r
 {\r
index d3cd539..8c71c07 100644 (file)
@@ -626,35 +626,6 @@ static const s32 exception_cycle_table[256] =
 };\r
 \r
 \r
-/********************/\r
-/* helper functions */\r
-/********************/\r
-\r
-\r
-#if 0\r
-static void famec_SetFetch(u32 low_adr, u32 high_adr, u32 fetch_adr)\r
-{\r
-    u32 i, j;\r
-\r
-       i = (low_adr >> M68K_FETCHSFT) & M68K_FETCHMASK;\r
-       j = (high_adr >> M68K_FETCHSFT) & M68K_FETCHMASK;\r
-\r
-       while (i <= j)\r
-               g_m68kcontext->Fetch[i++] = fetch_adr;\r
-}\r
-\r
-static void famec_SetBanks(void)\r
-{\r
-       u32 i=0;\r
-       while(m68kcontext.fetch[i].low_addr != (u32)-1)\r
-       {\r
-               famec_SetFetch(m68kcontext.fetch[i].low_addr,m68kcontext.fetch[i].high_addr,m68kcontext.fetch[i].offset);\r
-               i++;\r
-       }\r
-}\r
-#endif\r
-\r
-\r
 /***********************/\r
 /* core main functions */\r
 /***********************/\r