--- np2/i286c/i286c.mcr 2003/10/17 12:49:52 1.4 +++ np2/i286c/i286c.mcr 2003/11/21 06:51:11 1.7 @@ -13,11 +13,36 @@ #define STRING_DIR ((I286_FLAG & D_FLAG)?-1:1) #define STRING_DIRx2 ((I286_FLAG & D_FLAG)?-2:2) -#if defined(CPUW2TEST) +#if !defined(MEMOPTIMIZE) +#define WORDSZPF(a) szpflag_w[(a)] +#else #define WORDSZPF(a) ((szpcflag[(a) & 0xff] & P_FLAG) | \ (((a))?0:Z_FLAG) | (((a) >> 8) & S_FLAG)) +#endif + +#if !defined(MEMOPTIMIZE) || (MEMOPTIMIZE < 2) +#define REG8_B53(op) _reg8_b53[(op)] +#define REG8_B20(op) _reg8_b20[(op)] #else -#define WORDSZPF(a) szpflag_w[(a)] +#if defined(BYTESEX_LITTLE) +#define REG8_B53(op) \ + (((BYTE *)&I286_REG) + (((op) >> 2) & 6) + (((op) >> 5) & 1)) +#define REG8_B20(op) \ + (((BYTE *)&I286_REG) + (((op) & 3) * 2) + (((op) >> 2) & 1)) +#else +#define REG8_B53(op) (((BYTE *)&I286_REG) + (((op) >> 2) & 6) + \ + ((((op) >> 5) & 1) ^ 1)) +#define REG8_B20(op) (((BYTE *)&I286_REG) + (((op) & 3) * 2) + \ + ((((op) >> 2) & 1) ^ 1)) +#endif +#endif + +#if !defined(MEMOPTIMIZE) || (MEMOPTIMIZE < 2) +#define REG16_B53(op) _reg16_b53[(op)] +#define REG16_B20(op) _reg16_b20[(op)] +#else +#define REG16_B53(op) (((UINT16 *)&I286_REG) + (((op) >> 3) & 7)) +#define REG16_B20(op) (((UINT16 *)&I286_REG) + ((op) & 7)) #endif #define SWAPBYTE(p, q) { \ @@ -36,9 +61,9 @@ #define I286IRQCHECKTERM \ - if (nevent.remainclock > 0) { \ - nevent.baseclock -= nevent.remainclock; \ - nevent.remainclock = 0; \ + if (I286_REMCLOCK > 0) { \ + I286_BASECLOCK -= I286_REMCLOCK; \ + I286_REMCLOCK = 0; \ } @@ -47,7 +72,7 @@ DS_FIX = DS_BASE; -#define I286_CLOCK(clock) nevent.remainclock -= (clock); +#define I286_WORKCLOCK(c) I286_REMCLOCK -= (c) #define GET_PCBYTE(b) \ @@ -72,48 +97,48 @@ #define PREPART_EA_REG8(b, d_s) \ GET_PCBYTE((b)) \ - (d_s) = *(reg8_b53[(b)]); + (d_s) = *(REG8_B53(b)); #define PREPART_EA_REG8P(b, d_s) \ GET_PCBYTE((b)) \ - (d_s) = reg8_b53[(b)]; + (d_s) = REG8_B53(b); #define PREPART_EA_REG16(b, d_s) \ GET_PCBYTE((b)) \ - (d_s) = *(reg16_b53[(b)]); + (d_s) = *(REG16_B53(b)); #define PREPART_EA_REG16P(b, d_s) \ GET_PCBYTE((b)) \ - (d_s) = reg16_b53[(b)]; + (d_s) = REG16_B53(b); #define PREPART_REG8_EA(b, s, d, regclk, memclk) \ GET_PCBYTE((b)) \ if ((b) >= 0xc0) { \ - I286_CLOCK(regclk) \ - (s) = *(reg8_b20[b]); \ + I286_WORKCLOCK(regclk); \ + (s) = *(REG8_B20(b)); \ } \ else { \ - I286_CLOCK(memclk) \ + I286_WORKCLOCK(memclk); \ (s) = i286_memoryread(c_calc_ea_dst[(b)]()); \ } \ - (d) = reg8_b53[(b)]; + (d) = REG8_B53(b); #define PREPART_REG16_EA(b, s, d, regclk, memclk) \ GET_PCBYTE(b) \ if (b >= 0xc0) { \ - I286_CLOCK(regclk) \ - s = *(reg16_b20[b]); \ + I286_WORKCLOCK(regclk); \ + s = *(REG16_B20(b)); \ } \ else { \ - I286_CLOCK(memclk) \ + I286_WORKCLOCK(memclk); \ s = i286_memoryread_w(c_calc_ea_dst[b]()); \ } \ - d = reg16_b53[b]; + d = REG16_B53(b); #define ADDBYTE(r, d, s) \ @@ -338,7 +363,7 @@ I286_FLAGL &= C_FLAG; \ I286_FLAGL |= (BYTE)(((w) ^ bak) & A_FLAG); \ I286_FLAGL |= WORDSZPF(w); \ - I286_CLOCK(clock); \ + I286_WORKCLOCK(clock); \ } @@ -350,12 +375,12 @@ I286_FLAGL &= C_FLAG; \ I286_FLAGL |= (BYTE)((w ^ bak) & A_FLAG); \ I286_FLAGL |= WORDSZPF(w); \ - I286_CLOCK(clock); \ + I286_WORKCLOCK(clock); \ } #define REGPUSH(reg, clock) { \ - I286_CLOCK(clock); \ + I286_WORKCLOCK(clock); \ I286_SP -= 2; \ i286_memorywrite_w(I286_SP + SS_BASE, reg); \ } @@ -370,16 +395,21 @@ UINT16 sp = reg; \ I286_SP -= 2; \ i286_memorywrite_w(I286_SP + SS_BASE, sp); \ - I286_CLOCK(clock); \ + I286_WORKCLOCK(clock); \ } #define REGPOP(reg, clock) { \ - I286_CLOCK(clock); \ + I286_WORKCLOCK(clock); \ reg = i286_memoryread_w(I286_SP + SS_BASE); \ I286_SP += 2; \ } +#define SP_POP(reg, clock) { \ + I286_WORKCLOCK(clock); \ + reg = i286_memoryread_w(I286_SP + SS_BASE); \ + } + #define REGPOP0(reg) \ reg = i286_memoryread_w(I286_SP + SS_BASE); \ @@ -388,26 +418,26 @@ #define JMPSHORT(clock) { \ - I286_CLOCK(clock); \ + I286_WORKCLOCK(clock); \ I286_IP += __CBW(i286_memoryread(CS_BASE + I286_IP)); \ I286_IP++; \ } #define JMPNOP(clock) { \ - I286_CLOCK(clock); \ + I286_WORKCLOCK(clock); \ I286_IP++; \ } #define MOVIMM8(reg) { \ - I286_CLOCK(2) \ + I286_WORKCLOCK(2); \ GET_PCBYTE(reg) \ } #define MOVIMM16(reg) { \ - I286_CLOCK(2) \ + I286_WORKCLOCK(2); \ GET_PCWORD(reg) \ }