Previous 15994 Revisions Next

r9861 Friday 31st December, 2010 at 16:54:22 UTC by Phill Harvey-Smith
Updates to i86 CPU core to fix problem with cirtain combinations of instructions
being flagged as illegal on the i186.

Update to wd17xx to re-add multiple sector writes as required by rmnimbus

Minor updates to the rmnimbus driver to return it to a working state.
[src/emu/cpu/i86]instr186.h instr86.c table186.h
[src/mess/drivers]rmnimbus.c
[src/mess/includes]rmnimbus.h
[src/mess/machine]rmnimbus.c scsibus.c wd17xx.c

src/emu/cpu/i86/instr186.h
r9860r9861
2323static void PREFIX186(_outsw)(i8086_state *cpustate);
2424
2525/* changed instructions */
26static void PREFIX(_pop_ss)(i8086_state *cpustate);
27static void PREFIX(_es)(i8086_state *cpustate);
28static void PREFIX(_cs)(i8086_state *cpustate);
29static void PREFIX(_ss)(i8086_state *cpustate);
30static void PREFIX(_ds)(i8086_state *cpustate);
31static void PREFIX(_mov_sregw)(i8086_state *cpustate);
2632static void PREFIX186(_repne)(i8086_state *cpustate);
2733static void PREFIX186(_repe)(i8086_state *cpustate);
34static void PREFIX186(_sti)(i8086_state *cpustate);
src/emu/cpu/i86/instr86.c
r9860r9861
1010 * timing value should move to separate array
1111 */
1212
13/*
14   PHS - 2010-12-29
15   
16   Moved several instruction stubs so that they are compiled separately for
17   the 8086 and 80186. The instructions affected are :
18   
19   _pop_ss, _es, _cs, _ss, _ds, _mov_sregw and _sti
20   
21   This is because they call the next instruction directly as it cannot be
22   interrupted. If they are not compiled separately when executing on an
23   80186, the wrong set of instructions are used (the 8086 set). This has
24   the serious effect of ignoring the next instruction, as invalid, *IF*
25   it is an 80186 specific instruction.
26
27*/
28
1329#undef ICOUNT
1430
1531#define ICOUNT cpustate->icount
r9860r9861
821837   ICOUNT -= timing.push_seg;
822838}
823839
824static void PREFIX86(_pop_ss)(i8086_state *cpustate)    /* Opcode 0x17 */
825{
826#ifdef I80286
827   UINT16 tmp;
828   POP(tmp);
829   i80286_data_descriptor(cpustate, SS, tmp);
830#else
831   POP(cpustate->sregs[SS]);
832   cpustate->base[SS] = SegBase(SS);
833#endif
834   ICOUNT -= timing.pop_seg;
835   PREFIX(_instruction)[FETCHOP](cpustate); /* no interrupt before next instruction */
836}
837
838840static void PREFIX86(_sbb_br8)(i8086_state *cpustate)    /* Opcode 0x18 */
839841{
840842    DEF_br8(dst,src);
r9860r9861
956958   cpustate->regs.w[AX]=dst;
957959}
958960
959static void PREFIX86(_es)(i8086_state *cpustate)    /* Opcode 0x26 */
960{
961   cpustate->seg_prefix = TRUE;
962   cpustate->prefix_seg = ES;
963   ICOUNT -= timing.override;
964   PREFIX(_instruction)[FETCHOP](cpustate);
965}
966
967961static void PREFIX86(_daa)(i8086_state *cpustate)    /* Opcode 0x27 */
968962{
969963   if (AF || ((cpustate->regs.b[AL] & 0xf) > 9))
r9860r9861
10321026   cpustate->regs.w[AX]=dst;
10331027}
10341028
1035static void PREFIX86(_cs)(i8086_state *cpustate)    /* Opcode 0x2e */
1036{
1037    cpustate->seg_prefix = TRUE;
1038   cpustate->prefix_seg = CS;
1039   ICOUNT -= timing.override;
1040   PREFIX(_instruction)[FETCHOP](cpustate);
1041}
1042
10431029static void PREFIX86(_das)(i8086_state *cpustate)    /* Opcode 0x2f */
10441030{
10451031   UINT8 tmpAL=cpustate->regs.b[AL];
r9860r9861
11091095   cpustate->regs.w[AX]=dst;
11101096}
11111097
1112static void PREFIX86(_ss)(i8086_state *cpustate)    /* Opcode 0x36 */
1113{
1114   cpustate->seg_prefix = TRUE;
1115   cpustate->prefix_seg = SS;
1116   ICOUNT -= timing.override;
1117   PREFIX(_instruction)[FETCHOP](cpustate);
1118}
1119
11201098static void PREFIX86(_aaa)(i8086_state *cpustate)    /* Opcode 0x37 */
11211099{
11221100   UINT8 ALcarry=1;
r9860r9861
11801158    SUBW(dst,src);
11811159}
11821160
1183static void PREFIX86(_ds)(i8086_state *cpustate)    /* Opcode 0x3e */
1184{
1185   cpustate->seg_prefix = TRUE;
1186   cpustate->prefix_seg = DS;
1187   ICOUNT -= timing.override;
1188   PREFIX(_instruction)[FETCHOP](cpustate);
1189}
1190
11911161static void PREFIX86(_aas)(i8086_state *cpustate)    /* Opcode 0x3f */
11921162{
11931163   UINT8 ALcarry=1;
r9860r9861
18801850   RegWord(ModRM)=cpustate->eo;   /* HJB 12/13/98 effective offset (no segment part) */
18811851}
18821852
1883static void PREFIX86(_mov_sregw)(i8086_state *cpustate)    /* Opcode 0x8e */
1884{
1885   unsigned ModRM = FETCH;
1886    WORD src = GetRMWord(ModRM);
1887
1888   ICOUNT -= (ModRM >= 0xc0) ? timing.mov_sr : timing.mov_sm;
1889#ifdef I80286
1890    switch (ModRM & 0x38)
1891    {
1892    case 0x00:  /* mov es,ew */
1893      i80286_data_descriptor(cpustate,ES,src);
1894      break;
1895    case 0x18:  /* mov ds,ew */
1896      i80286_data_descriptor(cpustate,DS,src);
1897      break;
1898    case 0x10:  /* mov ss,ew */
1899      i80286_data_descriptor(cpustate,SS,src);
1900      PREFIX(_instruction)[FETCHOP](cpustate);
1901      break;
1902    case 0x08:  /* mov cs,ew */
1903      break;  /* doesn't do a jump far */
1904    }
1905#else
1906    switch (ModRM & 0x38)
1907    {
1908    case 0x00:  /* mov es,ew */
1909      cpustate->sregs[ES] = src;
1910      cpustate->base[ES] = SegBase(ES);
1911      break;
1912    case 0x18:  /* mov ds,ew */
1913      cpustate->sregs[DS] = src;
1914      cpustate->base[DS] = SegBase(DS);
1915      break;
1916    case 0x10:  /* mov ss,ew */
1917      cpustate->sregs[SS] = src;
1918      cpustate->base[SS] = SegBase(SS); /* no interrupt allowed before next instr */
1919      PREFIX(_instruction)[FETCHOP](cpustate);
1920      break;
1921    case 0x08:  /* mov cs,ew */
1922      break;  /* doesn't do a jump far */
1923    }
1924#endif
1925}
1926
19271853static void PREFIX86(_popw)(i8086_state *cpustate)    /* Opcode 0x8f */
19281854{
19291855   unsigned ModRM = FETCH;
r9860r9861
27222648}
27232649#endif
27242650
2651static void PREFIX(_pop_ss)(i8086_state *cpustate)    /* Opcode 0x17 */
2652{
2653#ifdef I80286
2654   UINT16 tmp;
2655   POP(tmp);
2656   i80286_data_descriptor(cpustate, SS, tmp);
2657#else
2658   POP(cpustate->sregs[SS]);
2659   cpustate->base[SS] = SegBase(SS);
2660#endif
2661   ICOUNT -= timing.pop_seg;
2662   PREFIX(_instruction)[FETCHOP](cpustate); /* no interrupt before next instruction */
2663}
2664
2665static void PREFIX(_es)(i8086_state *cpustate)    /* Opcode 0x26 */
2666{
2667   cpustate->seg_prefix = TRUE;
2668   cpustate->prefix_seg = ES;
2669   ICOUNT -= timing.override;
2670   PREFIX(_instruction)[FETCHOP](cpustate);
2671}
2672
2673static void PREFIX(_cs)(i8086_state *cpustate)    /* Opcode 0x2e */
2674{
2675    cpustate->seg_prefix = TRUE;
2676   cpustate->prefix_seg = CS;
2677   ICOUNT -= timing.override;
2678   PREFIX(_instruction)[FETCHOP](cpustate);
2679}
2680
2681static void PREFIX(_ss)(i8086_state *cpustate)    /* Opcode 0x36 */
2682{
2683   cpustate->seg_prefix = TRUE;
2684   cpustate->prefix_seg = SS;
2685   ICOUNT -= timing.override;
2686   PREFIX(_instruction)[FETCHOP](cpustate);
2687}
2688
2689static void PREFIX(_ds)(i8086_state *cpustate)    /* Opcode 0x3e */
2690{
2691   cpustate->seg_prefix = TRUE;
2692   cpustate->prefix_seg = DS;
2693   ICOUNT -= timing.override;
2694   PREFIX(_instruction)[FETCHOP](cpustate);
2695}
2696
2697static void PREFIX(_mov_sregw)(i8086_state *cpustate)    /* Opcode 0x8e */
2698{
2699   unsigned ModRM = FETCH;
2700    WORD src = GetRMWord(ModRM);
2701
2702   ICOUNT -= (ModRM >= 0xc0) ? timing.mov_sr : timing.mov_sm;
2703#ifdef I80286
2704    switch (ModRM & 0x38)
2705    {
2706    case 0x00:  /* mov es,ew */
2707      i80286_data_descriptor(cpustate,ES,src);
2708      break;
2709    case 0x18:  /* mov ds,ew */
2710      i80286_data_descriptor(cpustate,DS,src);
2711      break;
2712    case 0x10:  /* mov ss,ew */
2713      i80286_data_descriptor(cpustate,SS,src);
2714      PREFIX(_instruction)[FETCHOP](cpustate);
2715      break;
2716    case 0x08:  /* mov cs,ew */
2717      break;  /* doesn't do a jump far */
2718    }
2719#else
2720    switch (ModRM & 0x38)
2721    {
2722    case 0x00:  /* mov es,ew */
2723      cpustate->sregs[ES] = src;
2724      cpustate->base[ES] = SegBase(ES);
2725      break;
2726    case 0x18:  /* mov ds,ew */
2727      cpustate->sregs[DS] = src;
2728      cpustate->base[DS] = SegBase(DS);
2729      break;
2730    case 0x10:  /* mov ss,ew */
2731      cpustate->sregs[SS] = src;
2732      cpustate->base[SS] = SegBase(SS); /* no interrupt allowed before next instr */
2733      PREFIX(_instruction)[FETCHOP](cpustate);
2734      break;
2735    case 0x08:  /* mov cs,ew */
2736      break;  /* doesn't do a jump far */
2737    }
2738#endif
2739}
2740
27252741static void PREFIX(_repne)(i8086_state *cpustate)    /* Opcode 0xf2 */
27262742{
27272743    PREFIX(rep)(cpustate, 0);
r9860r9861
27322748   PREFIX(rep)(cpustate, 1);
27332749}
27342750
2751static void PREFIX(_sti)(i8086_state *cpustate)    /* Opcode 0xfb */
2752{
2753   ICOUNT -= timing.flag_ops;
2754   SetIF(1);
2755   PREFIX(_instruction)[FETCHOP](cpustate); /* no interrupt before next instruction */
2756
2757   /* if an interrupt is pending, signal an interrupt */
2758   if (cpustate->irq_state)
2759      PREFIX86(_interrupt)(cpustate, (UINT32)-1);
2760}
2761
27352762#ifndef I80186
27362763static void PREFIX86(_hlt)(i8086_state *cpustate)    /* Opcode 0xf4 */
27372764{
r9860r9861
30223049   SetIF(0);
30233050}
30243051
3025static void PREFIX86(_sti)(i8086_state *cpustate)    /* Opcode 0xfb */
3026{
3027   ICOUNT -= timing.flag_ops;
3028   SetIF(1);
3029   PREFIX(_instruction)[FETCHOP](cpustate); /* no interrupt before next instruction */
3030
3031   /* if an interrupt is pending, signal an interrupt */
3032   if (cpustate->irq_state)
3033      PREFIX(_interrupt)(cpustate, (UINT32)-1);
3034}
3035
30363052static void PREFIX86(_cld)(i8086_state *cpustate)    /* Opcode 0xfc */
30373053{
30383054   ICOUNT -= timing.flag_ops;
src/emu/cpu/i86/table186.h
r9860r9861
2323    PREFIX86(_adc_ald8),          /* 0x14 */
2424    PREFIX86(_adc_axd16),         /* 0x15 */
2525    PREFIX86(_push_ss),           /* 0x16 */
26    PREFIX86(_pop_ss),            /* 0x17 */
26    PREFIX186(_pop_ss),           /* 0x17 */
2727    PREFIX86(_sbb_br8),           /* 0x18 */
2828    PREFIX86(_sbb_wr16),          /* 0x19 */
2929    PREFIX86(_sbb_r8b),           /* 0x1a */
r9860r9861
3838    PREFIX86(_and_r16w),          /* 0x23 */
3939    PREFIX86(_and_ald8),          /* 0x24 */
4040    PREFIX86(_and_axd16),         /* 0x25 */
41    PREFIX86(_es),                /* 0x26 */
41    PREFIX186(_es),               /* 0x26 */
4242    PREFIX86(_daa),               /* 0x27 */
4343    PREFIX86(_sub_br8),           /* 0x28 */
4444    PREFIX86(_sub_wr16),          /* 0x29 */
r9860r9861
4646    PREFIX86(_sub_r16w),          /* 0x2b */
4747    PREFIX86(_sub_ald8),          /* 0x2c */
4848    PREFIX86(_sub_axd16),         /* 0x2d */
49    PREFIX86(_cs),                /* 0x2e */
50    PREFIX86(_das),      /* 0x2f */
49    PREFIX186(_cs),               /* 0x2e */
50    PREFIX86(_das),            /* 0x2f */
5151    PREFIX86(_xor_br8),           /* 0x30 */
5252    PREFIX86(_xor_wr16),          /* 0x31 */
5353    PREFIX86(_xor_r8b),           /* 0x32 */
5454    PREFIX86(_xor_r16w),          /* 0x33 */
5555    PREFIX86(_xor_ald8),          /* 0x34 */
5656    PREFIX86(_xor_axd16),         /* 0x35 */
57    PREFIX86(_ss),                /* 0x36 */
58    PREFIX86(_aaa),      /* 0x37 */
57    PREFIX186(_ss),               /* 0x36 */
58    PREFIX86(_aaa),            /* 0x37 */
5959    PREFIX86(_cmp_br8),           /* 0x38 */
6060    PREFIX86(_cmp_wr16),          /* 0x39 */
6161    PREFIX86(_cmp_r8b),           /* 0x3a */
6262    PREFIX86(_cmp_r16w),          /* 0x3b */
6363    PREFIX86(_cmp_ald8),          /* 0x3c */
6464    PREFIX86(_cmp_axd16),         /* 0x3d */
65    PREFIX86(_ds),                /* 0x3e */
66    PREFIX86(_aas),      /* 0x3f */
65    PREFIX186(_ds),                /* 0x3e */
66    PREFIX86(_aas),            /* 0x3f */
6767    PREFIX86(_inc_ax),            /* 0x40 */
6868    PREFIX86(_inc_cx),            /* 0x41 */
6969    PREFIX86(_inc_dx),            /* 0x42 */
r9860r9861
142142    PREFIX86(_mov_r16w),          /* 0x8b */
143143    PREFIX86(_mov_wsreg),         /* 0x8c */
144144    PREFIX86(_lea),               /* 0x8d */
145    PREFIX86(_mov_sregw),         /* 0x8e */
145    PREFIX186(_mov_sregw),        /* 0x8e */
146146    PREFIX86(_popw),              /* 0x8f */
147147    PREFIX86(_nop),               /* 0x90 */
148148    PREFIX86(_xchg_axcx),         /* 0x91 */
r9860r9861
251251    PREFIX86(_clc),               /* 0xf8 */
252252    PREFIX86(_stc),               /* 0xf9 */
253253    PREFIX86(_cli),               /* 0xfa */
254    PREFIX86(_sti),               /* 0xfb */
254    PREFIX186(_sti),              /* 0xfb */
255255    PREFIX86(_cld),               /* 0xfc */
256256    PREFIX86(_std),               /* 0xfd */
257257    PREFIX86(_fepre),             /* 0xfe */
r9860r9861
514514   case 0xf8:    PREFIX86(_clc)(cpustate); break;\
515515   case 0xf9:    PREFIX86(_stc)(cpustate); break;\
516516   case 0xfa:    PREFIX86(_cli)(cpustate); break;\
517   case 0xfb:    PREFIX86(_sti)(cpustate); break;\
517   case 0xfb:    PREFIX186(_sti)(cpustate); break;\
518518   case 0xfc:    PREFIX86(_cld)(cpustate); break;\
519519   case 0xfd:    PREFIX86(_std)(cpustate); break;\
520520   case 0xfe:    PREFIX86(_fepre)(cpustate); break;\
src/mess/machine/scsibus.c
r9860r9861
1313
1414/* LOGLEVEL 0=no logging, 1=just commands and data, 2=everything ! */
1515
16#define LOGLEVEL         
16#define LOGLEVEL         1
1717
1818#define LOG(level,...)      if(LOGLEVEL>=level) logerror(__VA_ARGS__)
1919
r9860r9861
7373{
7474    bus->data_last = (bus->bytes_left >= DATA_BUF_SIZE) ? DATA_BUF_SIZE : bus->bytes_left;
7575
76    LOG(1,"SCSIBUS:scsibus_read_data bus->bytes_left=%04X, bus->data_last=%04X, bus->xfer_count=%04X\n",bus->bytes_left,bus->data_last,bus->xfer_count);
76    LOG(2,"SCSIBUS:scsibus_read_data bus->bytes_left=%04X, bus->data_last=%04X, bus->xfer_count=%04X\n",bus->bytes_left,bus->data_last,bus->xfer_count);
7777
7878    if (bus->data_last > 0)
7979    {
r9860r9861
539539{
540540    scsibus_t   *bus = get_token(device);
541541
542    LOG(1,"scsi_change_phase() from=%s, to=%s\n",phasenames[bus->phase],phasenames[newphase]);
542    LOG(2,"scsi_change_phase() from=%s, to=%s\n",phasenames[bus->phase],phasenames[newphase]);
543543
544544    bus->phase=newphase;
545545    bus->cmd_idx=0;
src/mess/machine/wd17xx.c
r9860r9861
125125    2010-March-22 Curt Coder:
126126    - Implemented immediate and index pulse interrupts.
127127
128   2010-Dec-31 Phill Harvey-Smith
129   - Copied multi-sector write code from r7263, for some reason this had been
130     silently removed, but is required for the rmnimbus driver.
131
128132    TODO:
129        - Multiple record write
130133        - What happens if a track is read that doesn't have any id's on it?
131134         (e.g. unformatted disc)
132135
r9860r9861
10301033
10311034   /* set new timer */
10321035   timer_adjust_oneshot(w->timer_cmd, ATTOTIME_IN_USEC(usecs), 0);
1036   
1037   /* Kill onshot read/write sector timers */
1038   timer_adjust_oneshot(w->timer_rs, attotime_never, 0);
1039   timer_adjust_oneshot(w->timer_ws, attotime_never, 0);
10331040}
10341041
10351042
r9860r9861
18321839
18331840                        w->data_offset = 0;
18341841
1835                        wd17xx_complete_command(device, DELAY_DATADONE);
1842                  /* Check we should handle the next sector for a multi record write */
1843                  if ( w->command_type == TYPE_II && w->command == FDC_WRITE_SEC && ( w->write_cmd & FDC_MULTI_REC ) )
1844                  {
1845                     w->sector++;
1846                     if (wd17xx_locate_sector(device))
1847                     {
1848                        w->data_count = w->sector_length;
1849
1850                        w->status |= STA_2_BUSY;
1851                        w->busy_count = 0;
1852
1853                        wd17xx_timed_data_request(device);
1854                     }
1855                  }
1856                  else
1857                  {
1858                     wd17xx_complete_command(device, DELAY_DATADONE);
1859                     if (VERBOSE)
1860                        logerror("wd17xx_data_w(): multi data write completed\n");
1861                  }
1862//                       wd17xx_complete_command(device, DELAY_DATADONE);
18361863                }
18371864                else
18381865                {
src/mess/machine/rmnimbus.c
r9860r9861
4343#define LATCH_INTS          1
4444#define LOG_PORTS           0
4545#define LOG_INTERRUPTS      0
46#define LOG_INTERRUPTS_EXT  1
46#define LOG_INTERRUPTS_EXT 
4747#define LOG_TIMER           0
4848#define LOG_OPTIMIZATION    0
4949#define LOG_DMA             0
5050#define CPU_RESUME_TRIGGER   7123
5151#define LOG_KEYBOARD        0
5252#define LOG_SIO             0
53#define LOG_DISK_FDD        1
53#define LOG_DISK_FDD       
5454#define LOG_DISK_HDD        0
55#define LOG_DISK            1
55#define LOG_DISK           
5656#define LOG_PC8031          0
5757#define LOG_PC8031_186      0
5858#define LOG_PC8031_PORT     0
r9860r9861
647647   if ((LOG_DMA) && (diff & 0x6811))
648648      logerror("%05X:ERROR! - unsupported DMA mode %04X\n",
649649         cpu_get_pc(machine->device(MAINCPU_TAG)), new_control);
650
650#if 0
651651   /* if we're going live, set a timer */
652652   if ((diff & 0x0002) && (new_control & 0x0002))
653653   {
r9860r9861
671671         d->finished = 0;
672672      }
673673   }
674#endif
674675
675676   if (LOG_DMA) logerror("Initiated DMA %d - count = %04X, source = %04X, dest = %04X\n", which, d->count, d->source, d->dest);
676677   if (DEBUG_SET(DMA_BREAK))
r9860r9861
12391240      debug_console_register_command(machine, "nimbus_irq", CMDFLAG_NONE, 0, 0, 2, execute_debug_irq);
12401241      debug_console_register_command(machine, "nimbus_intmasks", CMDFLAG_NONE, 0, 0, 0, execute_debug_intmasks);
12411242      debug_console_register_command(machine, "nimbus_debug", CMDFLAG_NONE, 0, 0, 1, nimbus_debug);
1242
1243     
12431244      /* set up the instruction hook */
12441245      machine->device(MAINCPU_TAG)->debug()->set_instruction_hook(instruction_hook);
12451246   }
r9860r9861
20922093static void fdc_reset(running_machine *machine)
20932094{
20942095   rmnimbus_state *state = machine->driver_data<rmnimbus_state>();
2095    state->nimbus_drives.reg400=0;
2096    running_device *fdc = machine->device(FDC_TAG);
2097   
2098   state->nimbus_drives.reg400=0;
20962099    state->nimbus_drives.reg410_in=0;
20972100    state->nimbus_drives.reg410_out=0;
20982101    state->nimbus_drives.int_ff=0;
2102   wd17xx_set_pause_time(fdc,FDC_PAUSE);
20992103}
21002104
21012105static void set_disk_int(running_machine *machine, int state)
src/mess/includes/rmnimbus.h
r9860r9861
287287/* Floppy/Fixed drive interface */
288288
289289#define FDC_TAG                 "wd2793"
290#define FDC_PAUSE            10000
290291
291292extern const wd17xx_interface nimbus_wd17xx_interface;
292293
src/mess/drivers/rmnimbus.c
r9860r9861
5252   DEVCB_NULL,
5353   DEVCB_NULL,
5454   DEVCB_NULL,
55   FLOPPY_STANDARD_5_25_DSHD,
55   FLOPPY_STANDARD_5_25_DSSD_35,
5656   FLOPPY_OPTIONS_NAME(pc),
5757   NULL
5858};

Previous 15994 Revisions Next


© 1998-2018 The MESS Team