--- np2/i286c/i286c.mcr 2003/11/30 11:20:55 1.11 +++ np2/i286c/i286c.mcr 2003/12/19 23:33:49 1.18 @@ -1,13 +1,15 @@ -#if defined(ARM) && defined(BYTESEX_LITTLE) -#define INHIBIT_WORDP(m) (((m) & 1) || ((m) >= 0xa0000)) +#if defined(X11) && (defined(i386) || defined(__i386__)) +#define INHIBIT_WORDP(m) ((m) >= (I286_MEMWRITEMAX - 1)) +#elif (defined(ARM) || defined(X11)) && defined(BYTESEX_LITTLE) +#define INHIBIT_WORDP(m) (((m) & 1) || ((m) >= I286_MEMWRITEMAX)) #else #define INHIBIT_WORDP(m) (1) #endif -#define __CBW(src) (UINT16)((char)(src)) -#define __CBD(src) ((char)(src)) -#define WORD2LONG(src) ((short)(src)) +#define __CBW(src) (UINT16)((SINT8)(src)) +#define __CBD(src) ((SINT8)(src)) +#define WORD2LONG(src) ((SINT16)(src)) #define SEGMENTPTR(s) (((UINT16 *)&I286_SEGREG) + (s)) @@ -22,32 +24,29 @@ #if defined(I286C_TEST) -extern BYTE BYTESZPF(UINT r); -extern BYTE BYTESZPCF(UINT r); +extern UINT8 BYTESZPF(UINT r); +extern UINT8 BYTESZPCF(UINT r); #define BYTESZPCF2(a) BYTESZPCF((a) & 0x1ff) -extern BYTE WORDSZPF(UINT32 r); -extern BYTE WORDSZPCF(UINT32 r); +extern UINT8 WORDSZPF(UINT32 r); +extern UINT8 WORDSZPCF(UINT32 r); #elif !defined(MEMOPTIMIZE) -extern BYTE _szpcflag8[0x200]; -extern BYTE _szpflag16[0x10000]; -#define BYTESZPF(a) (_szpcflag8[(a)]) -#define BYTESZPCF(a) (_szpcflag8[(a)]) -#define BYTESZPCF2(a) (_szpcflag8[(a) & 0x1ff]) +extern UINT8 _szpflag16[0x10000]; +#define BYTESZPF(a) (iflags[(a)]) +#define BYTESZPCF(a) (iflags[(a)]) +#define BYTESZPCF2(a) (iflags[(a) & 0x1ff]) #define WORDSZPF(a) (_szpflag16[(a)]) #define WORDSZPCF(a) (_szpflag16[LOW16(a)] + (((a) >> 16) & 1)) #else -extern BYTE _szpcflag8[0x200]; - -#define BYTESZPF(a) (_szpcflag8[(a)]) -#define BYTESZPCF(a) (_szpcflag8[(a)]) -#define BYTESZPCF2(a) (_szpcflag8[(a) & 0x1ff]) -#define WORDSZPF(a) ((_szpcflag8[(a) & 0xff] & P_FLAG) + \ +#define BYTESZPF(a) (iflags[(a)]) +#define BYTESZPCF(a) (iflags[(a)]) +#define BYTESZPCF2(a) (iflags[(a) & 0x1ff]) +#define WORDSZPF(a) ((iflags[(a) & 0xff] & P_FLAG) + \ (((a))?0:Z_FLAG) + (((a) >> 8) & S_FLAG)) -#define WORDSZPCF(a) ((_szpcflag8[(a) & 0xff] & P_FLAG) + \ +#define WORDSZPCF(a) ((iflags[(a) & 0xff] & P_FLAG) + \ ((LOW16(a))?0:Z_FLAG) + (((a) >> 8) & S_FLAG) + \ (((a) >> 16) & 1)) @@ -57,20 +56,20 @@ extern BYTE _szpcflag8[0x200]; // ---- reg position #if !defined(MEMOPTIMIZE) || (MEMOPTIMIZE < 2) -extern BYTE *_reg8_b53[256]; -extern BYTE *_reg8_b20[256]; +extern UINT8 *_reg8_b53[256]; +extern UINT8 *_reg8_b20[256]; #define REG8_B53(op) _reg8_b53[(op)] #define REG8_B20(op) _reg8_b20[(op)] #else #if defined(BYTESEX_LITTLE) #define REG8_B53(op) \ - (((BYTE *)&I286_REG) + (((op) >> 2) & 6) + (((op) >> 5) & 1)) + (((UINT8 *)&I286_REG) + (((op) >> 2) & 6) + (((op) >> 5) & 1)) #define REG8_B20(op) \ - (((BYTE *)&I286_REG) + (((op) & 3) * 2) + (((op) >> 2) & 1)) + (((UINT8 *)&I286_REG) + (((op) & 3) * 2) + (((op) >> 2) & 1)) #else -#define REG8_B53(op) (((BYTE *)&I286_REG) + (((op) >> 2) & 6) + \ +#define REG8_B53(op) (((UINT8 *)&I286_REG) + (((op) >> 2) & 6) + \ ((((op) >> 5) & 1) ^ 1)) -#define REG8_B20(op) (((BYTE *)&I286_REG) + (((op) & 3) * 2) + \ +#define REG8_B20(op) (((UINT8 *)&I286_REG) + (((op) & 3) * 2) + \ ((((op) >> 2) & 1) ^ 1)) #endif #endif @@ -109,13 +108,14 @@ extern UINT calc_a(UINT op, UINT32 *seg) #define SWAPBYTE(p, q) { \ - BYTE tmp = (p); \ + REG8 tmp; \ + tmp = (p); \ (p) = (q); \ (q) = tmp; \ } #define SWAPWORD(p, q) { \ - UINT16 tmp; \ + REG16 tmp; \ tmp = (p); \ (p) = (q); \ (q) = tmp; \ @@ -212,7 +212,7 @@ extern UINT calc_a(UINT op, UINT32 *seg) #define ADDWORD(r, d, s) \ (r) = (s) + (d); \ I286_OV = ((r) ^ (s)) & ((r) ^ (d)) & 0x8000; \ - I286_FLAGL = (BYTE)(((r) ^ (d) ^ (s)) & A_FLAG); \ + I286_FLAGL = (UINT8)(((r) ^ (d) ^ (s)) & A_FLAG); \ I286_FLAGL |= WORDSZPCF(r); @@ -231,13 +231,13 @@ extern UINT calc_a(UINT op, UINT32 *seg) #define ADCBYTE(r, d, s) \ (r) = (I286_FLAGL & 1) + (s) + (d); \ I286_OV = ((r) ^ (s)) & ((r) ^ (d)) & 0x80; \ - I286_FLAGL = (BYTE)(((r) ^ (d) ^ (s)) & A_FLAG); \ + I286_FLAGL = (UINT8)(((r) ^ (d) ^ (s)) & A_FLAG); \ I286_FLAGL |= BYTESZPCF(r); #define ADCWORD(r, d, s) \ (r) = (I286_FLAGL & 1) + (s) + (d); \ I286_OV = ((r) ^ (s)) & ((r) ^ (d)) & 0x8000; \ - I286_FLAGL = (BYTE)(((r) ^ (d) ^ (s)) & A_FLAG); \ + I286_FLAGL = (UINT8)(((r) ^ (d) ^ (s)) & A_FLAG); \ I286_FLAGL |= WORDSZPCF(r); @@ -245,13 +245,13 @@ extern UINT calc_a(UINT op, UINT32 *seg) #define SBBBYTE(r, d, s) \ (r) = (d) - (s) - (I286_FLAGL & 1); \ I286_OV = ((d) ^ (r)) & ((d) ^ (s)) & 0x80; \ - I286_FLAGL = (BYTE)(((r) ^ (d) ^ (s)) & A_FLAG); \ + I286_FLAGL = (UINT8)(((r) ^ (d) ^ (s)) & A_FLAG); \ I286_FLAGL |= BYTESZPCF2(r); #define SBBWORD(r, d, s) \ (r) = (d) - (s) - (I286_FLAGL & 1); \ I286_OV = ((d) ^ (r)) & ((d) ^ (s)) & 0x8000; \ - I286_FLAGL = (BYTE)(((r) ^ (d) ^ (s)) & A_FLAG); \ + I286_FLAGL = (UINT8)(((r) ^ (d) ^ (s)) & A_FLAG); \ I286_FLAGL |= WORDSZPCF(r); @@ -271,7 +271,7 @@ extern UINT calc_a(UINT op, UINT32 *seg) #define SUBBYTE(r, d, s) \ (r) = (d) - (s); \ I286_OV = ((d) ^ (r)) & ((d) ^ (s)) & 0x80; \ - I286_FLAGL = (BYTE)(((r) ^ (d) ^ (s)) & A_FLAG); \ + I286_FLAGL = (UINT8)(((r) ^ (d) ^ (s)) & A_FLAG); \ I286_FLAGL |= BYTESZPCF2(r); #define SUBWORD(r, d, s) \ @@ -296,19 +296,19 @@ extern UINT calc_a(UINT op, UINT32 *seg) #define NEGBYTE(d, s) \ (d) = 0 - (s); \ I286_OV = ((d) & (s)) & 0x80; \ - I286_FLAGL = (BYTE)(((d) ^ (s)) & A_FLAG); \ + I286_FLAGL = (UINT8)(((d) ^ (s)) & A_FLAG); \ I286_FLAGL |= BYTESZPCF2(d); #define NEGWORD(d, s) \ (d) = 0 - (s); \ I286_OV = ((d) & (s)) & 0x8000; \ - I286_FLAGL = (BYTE)(((d) ^ (s)) & A_FLAG); \ + I286_FLAGL = (UINT8)(((d) ^ (s)) & A_FLAG); \ I286_FLAGL |= WORDSZPCF(d); #define BYTE_MUL(r, d, s) \ I286_FLAGL &= (Z_FLAG | S_FLAG | A_FLAG | P_FLAG); \ - (r) = (BYTE)(d) * (BYTE)(s); \ + (r) = (UINT8)(d) * (UINT8)(s); \ I286_OV = (r) >> 8; \ if (I286_OV) { \ I286_FLAGL |= C_FLAG; \ @@ -325,7 +325,7 @@ extern UINT calc_a(UINT op, UINT32 *seg) #define BYTE_IMUL(r, d, s) \ I286_FLAGL &= (Z_FLAG | S_FLAG | A_FLAG | P_FLAG); \ - (r) = (char)(d) * (char)(s); \ + (r) = (SINT8)(d) * (SINT8)(s); \ I286_OV = ((r) + 0x80) & 0xffffff00; \ if (I286_OV) { \ I286_FLAGL |= C_FLAG; \ @@ -333,7 +333,7 @@ extern UINT calc_a(UINT op, UINT32 *seg) #define WORD_IMUL(r, d, s) \ I286_FLAGL &= (Z_FLAG | S_FLAG | A_FLAG | P_FLAG); \ - (r) = (short)(d) * (short)(s); \ + (r) = (SINT16)(d) * (SINT16)(s); \ I286_OV = ((r) + 0x8000) & 0xffff0000; \ if (I286_OV) { \ I286_FLAGL |= C_FLAG; \ @@ -346,8 +346,8 @@ extern UINT calc_a(UINT op, UINT32 *seg) (s)++; \ I286_OV = (s) & (b ^ (s)) & 0x80; \ I286_FLAGL &= C_FLAG; \ - I286_FLAGL |= (BYTE)((b ^ (s)) & A_FLAG); \ - I286_FLAGL |= BYTESZPF((BYTE)(s)); \ + I286_FLAGL |= (UINT8)((b ^ (s)) & A_FLAG); \ + I286_FLAGL |= BYTESZPF((UINT8)(s)); \ } #define INCWORD(s) { \ @@ -355,7 +355,7 @@ extern UINT calc_a(UINT op, UINT32 *seg) (s)++; \ I286_OV = (s) & (b ^ (s)) & 0x8000; \ I286_FLAGL &= C_FLAG; \ - I286_FLAGL |= (BYTE)((b ^ (s)) & A_FLAG); \ + I286_FLAGL |= (UINT8)((b ^ (s)) & A_FLAG); \ I286_FLAGL |= WORDSZPF((UINT16)(s)); \ } @@ -366,8 +366,8 @@ extern UINT calc_a(UINT op, UINT32 *seg) b--; \ I286_OV = (s) & (b ^ (s)) & 0x80; \ I286_FLAGL &= C_FLAG; \ - I286_FLAGL |= (BYTE)((b ^ (s)) & A_FLAG); \ - I286_FLAGL |= BYTESZPF((BYTE)b); \ + I286_FLAGL |= (UINT8)((b ^ (s)) & A_FLAG); \ + I286_FLAGL |= BYTESZPF((UINT8)b); \ (s) = b; \ } @@ -376,7 +376,7 @@ extern UINT calc_a(UINT op, UINT32 *seg) b--; \ I286_OV = (s) & (b ^ (s)) & 0x8000; \ I286_FLAGL &= C_FLAG; \ - I286_FLAGL |= (BYTE)((b ^ (s)) & A_FLAG); \ + I286_FLAGL |= (UINT8)((b ^ (s)) & A_FLAG); \ I286_FLAGL |= WORDSZPF((UINT16)b); \ (s) = b; \ } @@ -390,7 +390,7 @@ extern UINT calc_a(UINT op, UINT32 *seg) (r) = (UINT16)d; \ I286_OV = d & (d ^ s) & 0x8000; \ I286_FLAGL &= C_FLAG; \ - I286_FLAGL |= (BYTE)((d ^ s) & A_FLAG); \ + I286_FLAGL |= (UINT8)((d ^ s) & A_FLAG); \ I286_FLAGL |= WORDSZPF((UINT16)d); \ I286_WORKCLOCK(clock); \ } @@ -402,7 +402,7 @@ extern UINT calc_a(UINT op, UINT32 *seg) (r) = (UINT16)d; \ I286_OV = s & (d ^ s) & 0x8000; \ I286_FLAGL &= C_FLAG; \ - I286_FLAGL |= (BYTE)((d ^ s) & A_FLAG); \ + I286_FLAGL |= (UINT8)((d ^ s) & A_FLAG); \ I286_FLAGL |= WORDSZPF((UINT16)d); \ I286_WORKCLOCK(clock); \ } @@ -418,7 +418,7 @@ extern UINT calc_a(UINT op, UINT32 *seg) reg = i286_memoryread_w(I286_SP + SS_BASE); \ I286_SP += 2; -#if defined(ARM) && defined(BYTESEX_LITTLE) +#if (defined(ARM) || defined(X11)) && defined(BYTESEX_LITTLE) #define REGPUSH(reg, clock) { \ UINT32 addr; \ @@ -500,5 +500,5 @@ extern UINT calc_a(UINT op, UINT32 *seg) } -#define INT_NUM(a, b) i286_intnum(a, b) +#define INT_NUM(a, b) i286c_intnum((a), (REG16)(b))