First commit with most sources
This commit is contained in:
161
cpu/cpu.h
Normal file
161
cpu/cpu.h
Normal file
@@ -0,0 +1,161 @@
|
||||
/****************************************************************************
|
||||
* *
|
||||
* Third Year Project *
|
||||
* *
|
||||
* An IBM PC Emulator *
|
||||
* For Unix and X Windows *
|
||||
* *
|
||||
* By David Hedley *
|
||||
* *
|
||||
* *
|
||||
* This program is Copyrighted. Consult the file COPYRIGHT for more details *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
/* This is CPU.H it contains definitions for cpu.c */
|
||||
|
||||
|
||||
#ifndef CPU_H
|
||||
#define CPU_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "mytypes.h"
|
||||
|
||||
#define AX 0
|
||||
#define CX 1
|
||||
#define DX 2
|
||||
#define BX 3
|
||||
#define SP 4
|
||||
#define BP 5
|
||||
#define SI 6
|
||||
#define DI 7
|
||||
|
||||
#define AL 0
|
||||
#define CL 1
|
||||
#define DL 2
|
||||
#define BL 3
|
||||
#define AH 4
|
||||
#define CH 5
|
||||
#define DH 6
|
||||
#define BH 7
|
||||
|
||||
#define SPL 8
|
||||
#define SPH 9
|
||||
#define BPL 10
|
||||
#define BPH 11
|
||||
#define SIL 12
|
||||
#define SIH 13
|
||||
#define DIL 14
|
||||
#define DIH 15
|
||||
|
||||
|
||||
#define ES 0
|
||||
#define CS 1
|
||||
#define SS 2
|
||||
#define DS 3
|
||||
|
||||
|
||||
/* parameter x = result, y = source 1, z = source 2 */
|
||||
|
||||
#define SetCFB_Add(x,y) (CF = (BYTE)(x) < (BYTE)(y))
|
||||
#define SetCFW_Add(x,y) (CF = (WORD)(x) < (WORD)(y))
|
||||
#define SetCFB_Sub(y,z) (CF = (BYTE)(y) > (BYTE)(z))
|
||||
#define SetCFW_Sub(y,z) (CF = (WORD)(y) > (WORD)(z))
|
||||
#define SetZFB(x) (ZF = !(BYTE)(x))
|
||||
#define SetZFW(x) (ZF = !(WORD)(x))
|
||||
#define SetTF(x) (TF = (x))
|
||||
#define SetIF(x) (IF = (x))
|
||||
#define SetDF(x) (DF = (x))
|
||||
#define SetAF(x,y,z) (AF = ((x) ^ ((y) ^ (z))) & 0x10)
|
||||
#define SetPF(x) (PF = parity_table[(BYTE)(x)])
|
||||
#define SetOFW_Add(x,y,z) (OF = ((x) ^ (y)) & ((x) ^ (z)) & 0x8000)
|
||||
#define SetOFB_Add(x,y,z) (OF = ((x) ^ (y)) & ((x) ^ (z)) & 0x80)
|
||||
#define SetOFW_Sub(x,y,z) (OF = ((z) ^ (y)) & ((z) ^ (x)) & 0x8000)
|
||||
#define SetOFB_Sub(x,y,z) (OF = ((z) ^ (y)) & ((z) ^ (x)) & 0x80)
|
||||
#define SetSFW(x) (SF = (x) & 0x8000)
|
||||
#define SetSFB(x) (SF = (x) & 0x80)
|
||||
|
||||
|
||||
#define GetMemInc(Seg,Off) ((Seg)[(Off)++])
|
||||
|
||||
#if defined(TEST) && defined(BSD386)
|
||||
# define SegToMemPtr(Seg) (sregs[Seg] == 0xa000 ? (BYTE *)0xe00a0000 : \
|
||||
sregs[Seg] == 0xb800 ? (BYTE *)0xe00b8000 : \
|
||||
&memory[sregs[Seg] << 4])
|
||||
#else
|
||||
# define SegToMemPtr(Seg) (&memory[sregs[Seg] << 4])
|
||||
#endif
|
||||
|
||||
|
||||
#define PutMemB(Seg,Off,x) ((Seg)[(WORD)(Off)] = (BYTE)(x))
|
||||
#define GetMemB(Seg,Off) ((BYTE)(Seg)[(WORD)(Off)])
|
||||
|
||||
#define CalcAll()
|
||||
|
||||
#define CompressFlags() (WORD)(CF | (PF << 2) | (!(!AF) << 4) | (ZF << 6) \
|
||||
| (!(!SF) << 7) | (TF << 8) | (IF << 9) \
|
||||
| (DF << 10) | (!(!OF) << 11))
|
||||
|
||||
#define ExpandFlags(f) \
|
||||
{ \
|
||||
CF = (f) & 1; \
|
||||
PF = ((f) & 4) == 4; \
|
||||
AF = (f) & 16; \
|
||||
ZF = ((f) & 64) == 64; \
|
||||
SF = (f) & 128; \
|
||||
TF = ((f) & 256) == 256; \
|
||||
IF = ((f) & 512) == 512; \
|
||||
DF = ((f) & 1024) == 1024; \
|
||||
OF = (f) & 2048; \
|
||||
}
|
||||
|
||||
|
||||
/* ChangeE(x) changes x to little endian from the machine's natural endian
|
||||
format and back again. Obviously there is nothing to do for little-endian
|
||||
machines... */
|
||||
|
||||
#if defined(LITTLE_ENDIAN)
|
||||
# define ChangeE(x) (WORD)(x)
|
||||
#else
|
||||
# define ChangeE(x) (WORD)(((x) << 8) | ((BYTE)((x) >> 8)))
|
||||
#endif
|
||||
|
||||
#if defined(LITTLE_ENDIAN) && !defined(ALIGNED_ACCESS)
|
||||
# define ReadWord(x) (*(x))
|
||||
# define WriteWord(x,y) (*(x) = (y))
|
||||
# define CopyWord(x,y) (*x = *y)
|
||||
# define PutMemW(Seg,Off,x) (*(WORD *)((Seg)+(WORD)(Off)) = (WORD)(x))
|
||||
# define GetMemW(Seg,Off) (*(WORD *)((Seg)+(WORD)(Off)))
|
||||
#else
|
||||
# define ReadWord(x) ((WORD)(*((BYTE *)(x))) + ((WORD)(*((BYTE *)(x)+1)) << 8))
|
||||
# define WriteWord(x,y) (*(BYTE *)(x) = (BYTE)(y), *((BYTE *)(x)+1) = (BYTE)((y) >> 8))
|
||||
# define CopyWord(x,y) (*(BYTE *)(x) = *(BYTE *)(y), *((BYTE *)(x)+1) = *((BYTE *)(y)+1))
|
||||
# define PutMemW(Seg,Off,x) (Seg[Off] = (BYTE)(x), Seg[(WORD)(Off)+1] = (BYTE)((x) >> 8))
|
||||
# define GetMemW(Seg,Off) ((WORD)Seg[Off] + ((WORD)Seg[(WORD)(Off)+1] << 8))
|
||||
#endif
|
||||
|
||||
extern WORD wregs[8]; /* Always little-endian */
|
||||
extern BYTE *bregs[16]; /* Points to bytes within wregs[] */
|
||||
extern unsigned sregs[4]; /* Always native machine word order */
|
||||
|
||||
extern unsigned ip; /* Always native machine word order */
|
||||
|
||||
/* All the byte flags will either be 1 or 0 */
|
||||
extern BYTE CF, PF, ZF, TF, IF, DF;
|
||||
|
||||
/* All the word flags may be either none-zero (true) or zero (false) */
|
||||
extern unsigned AF, OF, SF;
|
||||
|
||||
extern BYTE *c_cs,*c_ds,*c_es,*c_ss,*c_stack;
|
||||
|
||||
extern volatile int int_pending;
|
||||
extern volatile int int_blocked;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
84
cpu/global.h
Normal file
84
cpu/global.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/****************************************************************************
|
||||
* *
|
||||
* Third Year Project *
|
||||
* *
|
||||
* An IBM PC Emulator *
|
||||
* For Unix and X Windows *
|
||||
* *
|
||||
* By David Hedley *
|
||||
* *
|
||||
* *
|
||||
* This program is Copyrighted. Consult the file COPYRIGHT for more details *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
/* This is GLOBAL.H It contains definitions for the program wide functions */
|
||||
|
||||
|
||||
#ifndef GLOBAL_H
|
||||
#define GLOBAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "mytypes.h"
|
||||
|
||||
#ifdef ME
|
||||
# include "uprotos.h"
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
# define FALSE 0
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
# define TRUE (!FALSE)
|
||||
#endif
|
||||
|
||||
#define MEMORY_SIZE (1024*1024+65536)
|
||||
|
||||
#ifdef INLINE_FUNCTIONS
|
||||
# define INLINE inline
|
||||
# define INLINE2 inline
|
||||
#else
|
||||
# define INLINE
|
||||
# define INLINE2
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
# define D(x) x
|
||||
#else
|
||||
# define D(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG2
|
||||
# define D2(x) x
|
||||
#else
|
||||
# define D2(x)
|
||||
#endif
|
||||
|
||||
#ifdef _HPUX_SOURCE
|
||||
#ifndef __hpux
|
||||
#define __hpux
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern BYTE *memory;
|
||||
extern char *progname;
|
||||
|
||||
void init_cpu(void);
|
||||
void execute(void);
|
||||
void exit_emu(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
0
cpu/hardware.c
Normal file
0
cpu/hardware.c
Normal file
48
cpu/hardware.h
Normal file
48
cpu/hardware.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/****************************************************************************
|
||||
* *
|
||||
* Third Year Project *
|
||||
* *
|
||||
* An IBM PC Emulator *
|
||||
* For Unix and X Windows *
|
||||
* *
|
||||
* By David Hedley *
|
||||
* *
|
||||
* *
|
||||
* This program is Copyrighted. Consult the file COPYRIGHT for more details *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef HARDWARE_H
|
||||
#define HARDWARE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "mytypes.h"
|
||||
|
||||
#define PIC_TIMER 1
|
||||
#define PIC_KEYBOARD 2
|
||||
|
||||
#define TICKSPERSEC (1193180.0/65536.0)
|
||||
|
||||
int port60_buffer_ok(int);
|
||||
void put_scancode(BYTE *, int);
|
||||
void init_timer(void);
|
||||
|
||||
void disable(void);
|
||||
void enable(void);
|
||||
|
||||
void starttimer(void);
|
||||
void stoptimer(void);
|
||||
|
||||
BYTE read_port(unsigned);
|
||||
void write_port(unsigned, BYTE);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
411
cpu/i186.h
Normal file
411
cpu/i186.h
Normal file
@@ -0,0 +1,411 @@
|
||||
/* i186 instruction implement */
|
||||
|
||||
static INLINE2 void i_pusha(void)
|
||||
{
|
||||
/* Opcode 0x60 */
|
||||
|
||||
unsigned tmp;
|
||||
unsigned tmp2;
|
||||
|
||||
tmp = (WORD)ReadWord(&wregs[SP]);
|
||||
PushWordReg(AX);
|
||||
PushWordReg(CX);
|
||||
PushWordReg(DX);
|
||||
PushWordReg(BX);
|
||||
tmp2 = (WORD)ReadWord(&wregs[SP]);
|
||||
tmp2 -= 2;
|
||||
WriteWord(&wregs[SP], (WORD)tmp2);
|
||||
PutMemW(c_stack, (WORD)tmp2, (WORD)tmp);
|
||||
PushWordReg(BP);
|
||||
PushWordReg(SI);
|
||||
PushWordReg(DI);
|
||||
}
|
||||
|
||||
static INLINE2 void i_popa(void)
|
||||
{
|
||||
/* Opcode 0x61 */
|
||||
|
||||
unsigned tmp;
|
||||
|
||||
PopWordReg(DI);
|
||||
PopWordReg(SI);
|
||||
PopWordReg(BP);
|
||||
tmp = (WORD)ReadWord(&wregs[SP]);
|
||||
tmp += 2;
|
||||
WriteWord(&wregs[SP], (WORD)tmp);
|
||||
PopWordReg(BX);
|
||||
PopWordReg(DX);
|
||||
PopWordReg(CX);
|
||||
PopWordReg(AX);
|
||||
}
|
||||
|
||||
static INLINE2 void i_bound(void)
|
||||
{
|
||||
/* Opcode 0x62 */
|
||||
|
||||
unsigned ModRM = (unsigned)GetMemInc(c_cs, ip);
|
||||
}
|
||||
|
||||
static INLINE2 void i_push_d16(void)
|
||||
{
|
||||
/* Opcode 0x68 */
|
||||
unsigned tmp1;
|
||||
unsigned tmp2;
|
||||
|
||||
tmp1 = GetMemInc(c_cs, ip);
|
||||
tmp1 |= GetMemInc(c_cs, ip) << 8;
|
||||
tmp2 = (WORD)ReadWord(&wregs[SP]);
|
||||
tmp2 -= 2;
|
||||
WriteWord(&wregs[SP], (WORD)tmp2);
|
||||
PutMemW(c_stack, (WORD)tmp2, (WORD)tmp1);
|
||||
}
|
||||
|
||||
static INLINE2 void i_imul_d16(void)
|
||||
{
|
||||
/* Opcode 0x69 */
|
||||
INT32 result;
|
||||
unsigned tmp1;
|
||||
unsigned tmp2;
|
||||
|
||||
unsigned ModRM = GetMemInc(c_cs, ip);
|
||||
WORD *dest = GetModRMRegW(ModRM);
|
||||
tmp1 = *(GetModRMRMW(ModRM));
|
||||
tmp2 = (unsigned)GetMemInc(c_cs, ip);
|
||||
tmp2 |= (unsigned)GetMemInc(c_cs, ip) << 8;
|
||||
|
||||
result = (INT16)(tmp1) * (INT16)(tmp2);
|
||||
|
||||
WriteWord(dest, result);
|
||||
*dest = (INT16)result;
|
||||
|
||||
CF = OF = (result >> 16) > 0;
|
||||
}
|
||||
|
||||
static INLINE2 void i_push_d8(void)
|
||||
{
|
||||
/* Opcode 0x6a */
|
||||
unsigned tmp1;
|
||||
unsigned tmp2;
|
||||
|
||||
tmp1 = GetMemInc(c_cs, ip);
|
||||
tmp2 = (WORD)ReadWord(&wregs[SP]);
|
||||
tmp2 -= 2;
|
||||
WriteWord(&wregs[SP], (WORD)tmp2);
|
||||
PutMemW(c_stack, (WORD)tmp2, (WORD)tmp1);
|
||||
}
|
||||
|
||||
static INLINE2 void i_imul_d8(void)
|
||||
{
|
||||
/* Opcode 0x6b */
|
||||
INT32 result;
|
||||
unsigned tmp1;
|
||||
unsigned tmp2;
|
||||
|
||||
unsigned ModRM = GetMemInc(c_cs, ip);
|
||||
WORD *dest = GetModRMRegW(ModRM);
|
||||
tmp1 = *(GetModRMRMW(ModRM));
|
||||
tmp2 = (unsigned)GetMemInc(c_cs, ip);
|
||||
|
||||
result = (INT16)(tmp1) * (INT16)(tmp2);
|
||||
|
||||
WriteWord(dest, result);
|
||||
*dest = (INT16)result;
|
||||
|
||||
CF = OF = (result >> 16) > 0;
|
||||
}
|
||||
|
||||
static INLINE2 void i_insb(void)
|
||||
{
|
||||
/* Opcode 0x6c */
|
||||
;
|
||||
}
|
||||
|
||||
static INLINE2 void i_insw(void)
|
||||
{
|
||||
/* Opcode 0x6d */
|
||||
;
|
||||
}
|
||||
|
||||
static INLINE2 void i_outsb(void)
|
||||
{
|
||||
/* Opcode 0x6e */
|
||||
;
|
||||
}
|
||||
|
||||
static INLINE2 void i_outsw(void)
|
||||
{
|
||||
/* Opcode 0x6f */
|
||||
;
|
||||
}
|
||||
|
||||
static INLINE2 void i_rotshft_bd8(void)
|
||||
{
|
||||
/* Opcode 0xc0 */
|
||||
|
||||
unsigned ModRM = GetMemInc(c_cs, ip);
|
||||
BYTE *dest = GetModRMRMB(ModRM);
|
||||
unsigned tmp = *dest;
|
||||
unsigned tmp2;
|
||||
unsigned count = GetMemInc(c_cs, ip);
|
||||
|
||||
switch(ModRM & 0x38) {
|
||||
case 0x00: /* ROL r/m8, imm8 */
|
||||
for(; count > 0; count--) {
|
||||
CF = (tmp & 0x80) != 0;
|
||||
tmp = (tmp << 1) + CF;
|
||||
}
|
||||
*dest = (BYTE)tmp;
|
||||
break;
|
||||
case 0x08: /* ROR r/m8, imm8 */
|
||||
for(; count > 0; count--) {
|
||||
CF = (tmp & 0x01) != 0;
|
||||
tmp = (tmp >> 1) + (CF << 7);
|
||||
}
|
||||
*dest = (BYTE)tmp;
|
||||
break;
|
||||
case 0x10: /* RCL r/m8, imm8 */
|
||||
for(; count > 0; count--) {
|
||||
tmp2 = CF;
|
||||
CF = (tmp & 0x80) != 0;
|
||||
tmp = (tmp << 1) + tmp2;
|
||||
}
|
||||
*dest = (BYTE)tmp;
|
||||
break;
|
||||
case 0x18: /* RCR r/m8, imm8 */
|
||||
for(; count > 0; count--) {
|
||||
tmp2 = (tmp >> 1) + (CF << 7);
|
||||
CF = (tmp & 0x01) != 0;
|
||||
tmp = tmp2;
|
||||
}
|
||||
*dest = (BYTE)tmp;
|
||||
break;
|
||||
case 0x20: /* SHL r/m8, imm8 */
|
||||
if(count >= 9) {
|
||||
CF = 0;
|
||||
tmp = 0;
|
||||
} else {
|
||||
CF = ((tmp << (count - 1)) & 0x80) != 0;
|
||||
tmp <<= count;
|
||||
}
|
||||
|
||||
AF = 1;
|
||||
SetZFB(tmp);
|
||||
SetSFB(tmp);
|
||||
SetPF(tmp);
|
||||
|
||||
*dest = (BYTE)tmp;
|
||||
break;
|
||||
case 0x28: /* SHR r/m8, imm8 */
|
||||
if(count >= 9) {
|
||||
CF = 0;
|
||||
tmp = 0;
|
||||
} else {
|
||||
CF = ((tmp >> (count - 1)) & 0x1) != 0;
|
||||
tmp >>= count;
|
||||
}
|
||||
|
||||
SetSFB(tmp);
|
||||
SetPF(tmp);
|
||||
SetZFB(tmp);
|
||||
AF = 1;
|
||||
*dest = (BYTE)tmp;
|
||||
break;
|
||||
case 0x38: /* SAR r/m8, imm8 */
|
||||
tmp2 = tmp & 0x80;
|
||||
CF = (((INT8)tmp >> (count - 1)) & 0x01) != 0;
|
||||
for(; count > 0; count--)
|
||||
tmp = (tmp >> 1) | tmp2;
|
||||
|
||||
SetSFB(tmp);
|
||||
SetPF(tmp);
|
||||
SetZFB(tmp);
|
||||
AF = 1;
|
||||
*dest = (BYTE)tmp;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE2 void i_rotshft_wd8(void)
|
||||
{
|
||||
/* Opcode 0xc1 */
|
||||
unsigned ModRM = GetMemInc(c_cs, ip);
|
||||
WORD *dest = GetModRMRMW(ModRM);
|
||||
unsigned tmp = *dest;
|
||||
unsigned tmp2;
|
||||
unsigned count = GetMemInc(c_cs, ip);
|
||||
|
||||
switch(ModRM & 0x38) {
|
||||
case 0x00: /* ROL r/m16, imm8 */
|
||||
for(; count > 0; count--) {
|
||||
CF = (tmp & 0x80) != 0;
|
||||
tmp = (tmp << 1) + CF;
|
||||
}
|
||||
*dest = (WORD)tmp;
|
||||
break;
|
||||
case 0x08: /* ROR r/m16, imm8 */
|
||||
for(; count > 0; count--) {
|
||||
CF = (tmp & 0x01) != 0;
|
||||
tmp = (tmp >> 1) + (CF << 7);
|
||||
}
|
||||
*dest = (WORD)tmp;
|
||||
break;
|
||||
case 0x10: /* RCL r/m16, imm8 */
|
||||
for(; count > 0; count--) {
|
||||
tmp2 = CF;
|
||||
CF = (tmp & 0x80) != 0;
|
||||
tmp = (tmp << 1) + tmp2;
|
||||
}
|
||||
*dest = (WORD)tmp;
|
||||
break;
|
||||
case 0x18: /* RCR r/m16, imm8 */
|
||||
for(; count > 0; count--) {
|
||||
tmp2 = (tmp >> 1) + (CF << 7);
|
||||
CF = (tmp & 0x01) != 0;
|
||||
tmp = tmp2;
|
||||
}
|
||||
*dest = (WORD)tmp;
|
||||
break;
|
||||
case 0x20: /* SHL r/m16, imm8 */
|
||||
if(count >= 9) {
|
||||
CF = 0;
|
||||
tmp = 0;
|
||||
} else {
|
||||
CF = ((tmp << (count - 1)) & 0x80) != 0;
|
||||
tmp <<= count;
|
||||
}
|
||||
|
||||
AF = 1;
|
||||
SetZFB(tmp);
|
||||
SetSFB(tmp);
|
||||
SetPF(tmp);
|
||||
|
||||
*dest = (WORD)tmp;
|
||||
break;
|
||||
case 0x28: /* SHR r/m16, imm8 */
|
||||
if(count >= 9) {
|
||||
CF = 0;
|
||||
tmp = 0;
|
||||
} else {
|
||||
CF = ((tmp >> (count - 1)) & 0x1) != 0;
|
||||
tmp >>= count;
|
||||
}
|
||||
|
||||
SetSFB(tmp);
|
||||
SetPF(tmp);
|
||||
SetZFB(tmp);
|
||||
AF = 1;
|
||||
*dest = (WORD)tmp;
|
||||
break;
|
||||
case 0x38: /* SAR r/m16, imm8 */
|
||||
tmp2 = tmp & 0x80;
|
||||
CF = (((INT16)tmp >> (count - 1)) & 0x01) != 0;
|
||||
for(; count > 0; count--)
|
||||
tmp = (tmp >> 1) | tmp2;
|
||||
|
||||
SetSFB(tmp);
|
||||
SetPF(tmp);
|
||||
SetZFB(tmp);
|
||||
AF = 1;
|
||||
*dest = (WORD)tmp;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE2 void i_enter(void)
|
||||
{
|
||||
/* Opcode 0xc8 */
|
||||
unsigned size;
|
||||
unsigned level;
|
||||
unsigned tmp;
|
||||
unsigned tmp2;
|
||||
unsigned i;
|
||||
|
||||
|
||||
size = GetMemInc(c_cs, ip);
|
||||
size |= GetMemInc(c_cs, ip) << 8;
|
||||
level = GetMemInc(c_cs, ip);
|
||||
/*
|
||||
PushWordReg(BP);
|
||||
tmp = ReadWord(&wregs[SP]);
|
||||
WriteWord(&wregs[BP], (WORD)tmp);
|
||||
WriteWord(&wregs[SP], (WORD)(tmp - size));
|
||||
for(i = 1; i < level; i++) {
|
||||
tmp = GetMemW(c_stack, ReadWord(&wregs[BP]) - i * 2);
|
||||
tmp2 = (WORD)(ReadWord(&wregs[SP]) - 2);
|
||||
WriteWord(&wregs[SP], tmp2);
|
||||
PutMemW(c_stack, tmp2, tmp);
|
||||
}
|
||||
if(level) {
|
||||
PushWordReg(BP);
|
||||
}
|
||||
*/
|
||||
level %= 32;
|
||||
PushWordReg(BP);
|
||||
tmp = (WORD)ReadWord(&wregs[SP]);
|
||||
|
||||
if(level > 0) {
|
||||
for(i = 1; i < level; i++) {
|
||||
tmp2 = (WORD)ReadWord(&wregs[BP]);
|
||||
tmp2 -= 2;
|
||||
WriteWord(&wregs[BP], (WORD)tmp2);
|
||||
PushWordReg(BP);
|
||||
}
|
||||
tmp2 = (WORD)ReadWord(&wregs[SP]);
|
||||
tmp2 -= 2;
|
||||
WriteWord(&wregs[SP], (WORD)tmp2);
|
||||
PutMemW(c_stack, tmp2, (WORD)tmp);
|
||||
}
|
||||
|
||||
WriteWord(&wregs[BP], (WORD)tmp);
|
||||
WriteWord(&wregs[SP], (WORD)(tmp - size));
|
||||
}
|
||||
|
||||
static INLINE2 void i_leave(void)
|
||||
{
|
||||
/* Opcode 0xc9 */
|
||||
unsigned tmp;
|
||||
|
||||
tmp = ReadWord(&wregs[BP]);
|
||||
WriteWord(&wregs[SP], (WORD)tmp);
|
||||
PopWordReg(BP);
|
||||
}
|
||||
|
||||
static INLINE void i_das(void)
|
||||
{
|
||||
/* Opcode 0x2f */
|
||||
unsigned tmp;
|
||||
|
||||
if(((*bregs[AL] & 0x0f) > 9) || AF) {
|
||||
tmp = *bregs[AL] - 6;
|
||||
*bregs[AL] = tmp;
|
||||
CF = CF | ((tmp & 0x100) ? 1 : 0);
|
||||
AF = 0x10;
|
||||
} else {
|
||||
AF = 0;
|
||||
}
|
||||
if((*bregs[AL] > 0x9f) || CF) {
|
||||
*bregs[AL] = *bregs[AL] - 0x60;
|
||||
CF = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void i_aas(void)
|
||||
{
|
||||
/* Opcode 0x3f */
|
||||
|
||||
if(((*bregs[AL] & 0x0f) > 9) || AF) {
|
||||
*bregs[AL] = (BYTE)(*bregs[AL] - 6);
|
||||
*bregs[AH] = (BYTE)(*bregs[AH] - 1);
|
||||
AF = 0x10;
|
||||
CF = 1;
|
||||
} else {
|
||||
AF = 0;
|
||||
CF = 0;
|
||||
}
|
||||
*bregs[AL] = *bregs[AL] & 0x0f;
|
||||
}
|
||||
545
cpu/instr.h
Normal file
545
cpu/instr.h
Normal file
@@ -0,0 +1,545 @@
|
||||
/****************************************************************************
|
||||
* *
|
||||
* Third Year Project *
|
||||
* *
|
||||
* An IBM PC Emulator *
|
||||
* For Unix and X Windows *
|
||||
* *
|
||||
* By David Hedley *
|
||||
* *
|
||||
* *
|
||||
* This program is Copyrighted. Consult the file COPYRIGHT for more details *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
/* This is INSTR.H It contains the functions corresponding to each individual
|
||||
instruction in the 80x86 set */
|
||||
|
||||
/*
|
||||
added 186 instruction by Tomoyuki 'ZRY' Nakano
|
||||
|
||||
*/
|
||||
|
||||
#ifndef INSTR_H
|
||||
#define INSTR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
static INLINE2 void i_add_br8(void);
|
||||
static INLINE2 void i_add_wr16(void);
|
||||
static INLINE2 void i_add_r8b(void);
|
||||
static INLINE2 void i_add_r16w(void);
|
||||
static INLINE2 void i_add_ald8(void);
|
||||
static INLINE2 void i_add_axd16(void);
|
||||
static INLINE2 void i_push_es(void);
|
||||
static INLINE2 void i_pop_es(void);
|
||||
static INLINE2 void i_or_br8(void);
|
||||
static INLINE2 void i_or_r8b(void);
|
||||
static INLINE2 void i_or_wr16(void);
|
||||
static INLINE2 void i_or_r16w(void);
|
||||
static INLINE2 void i_or_ald8(void);
|
||||
static INLINE2 void i_or_axd16(void);
|
||||
static INLINE2 void i_push_cs(void);
|
||||
static INLINE2 void i_adc_br8(void);
|
||||
static INLINE2 void i_adc_wr16(void);
|
||||
static INLINE2 void i_adc_r8b(void);
|
||||
static INLINE2 void i_adc_r16w(void);
|
||||
static INLINE2 void i_adc_ald8(void);
|
||||
static INLINE2 void i_adc_axd16(void);
|
||||
static INLINE2 void i_push_ss(void);
|
||||
static INLINE2 void i_pop_ss(void);
|
||||
static INLINE2 void i_sbb_br8(void);
|
||||
static INLINE2 void i_sbb_wr16(void);
|
||||
static INLINE2 void i_sbb_r8b(void);
|
||||
static INLINE2 void i_sbb_r16w(void);
|
||||
static INLINE2 void i_sbb_ald8(void);
|
||||
static INLINE2 void i_sbb_axd16(void);
|
||||
static INLINE2 void i_push_ds(void);
|
||||
static INLINE2 void i_pop_ds(void);
|
||||
static INLINE2 void i_and_br8(void);
|
||||
static INLINE2 void i_and_r8b(void);
|
||||
static INLINE2 void i_and_wr16(void);
|
||||
static INLINE2 void i_and_r16w(void);
|
||||
static INLINE2 void i_and_ald8(void);
|
||||
static INLINE2 void i_and_axd16(void);
|
||||
static INLINE2 void i_es(void);
|
||||
static INLINE2 void i_daa(void);
|
||||
static INLINE2 void i_sub_br8(void);
|
||||
static INLINE2 void i_sub_wr16(void);
|
||||
static INLINE2 void i_sub_r8b(void);
|
||||
static INLINE2 void i_sub_r16w(void);
|
||||
static INLINE2 void i_sub_ald8(void);
|
||||
static INLINE2 void i_sub_axd16(void);
|
||||
static INLINE2 void i_cs(void);
|
||||
static INLINE2 void i_xor_br8(void);
|
||||
static INLINE2 void i_xor_r8b(void);
|
||||
static INLINE2 void i_xor_wr16(void);
|
||||
static INLINE2 void i_xor_r16w(void);
|
||||
static INLINE2 void i_xor_ald8(void);
|
||||
static INLINE2 void i_xor_axd16(void);
|
||||
static INLINE2 void i_ss(void);
|
||||
static INLINE2 void i_cmp_br8(void);
|
||||
static INLINE2 void i_cmp_wr16(void);
|
||||
static INLINE2 void i_cmp_r8b(void);
|
||||
static INLINE2 void i_cmp_r16w(void);
|
||||
static INLINE2 void i_cmp_ald8(void);
|
||||
static INLINE2 void i_cmp_axd16(void);
|
||||
static INLINE2 void i_ds(void);
|
||||
static INLINE2 void i_inc_ax(void);
|
||||
static INLINE2 void i_inc_cx(void);
|
||||
static INLINE2 void i_inc_dx(void);
|
||||
static INLINE2 void i_inc_bx(void);
|
||||
static INLINE2 void i_inc_sp(void);
|
||||
static INLINE2 void i_inc_bp(void);
|
||||
static INLINE2 void i_inc_si(void);
|
||||
static INLINE2 void i_inc_di(void);
|
||||
static INLINE2 void i_dec_ax(void);
|
||||
static INLINE2 void i_dec_cx(void);
|
||||
static INLINE2 void i_dec_dx(void);
|
||||
static INLINE2 void i_dec_bx(void);
|
||||
static INLINE2 void i_dec_sp(void);
|
||||
static INLINE2 void i_dec_bp(void);
|
||||
static INLINE2 void i_dec_si(void);
|
||||
static INLINE2 void i_dec_di(void);
|
||||
static INLINE2 void i_push_ax(void);
|
||||
static INLINE2 void i_push_cx(void);
|
||||
static INLINE2 void i_push_dx(void);
|
||||
static INLINE2 void i_push_bx(void);
|
||||
static INLINE2 void i_push_sp(void);
|
||||
static INLINE2 void i_push_bp(void);
|
||||
static INLINE2 void i_push_si(void);
|
||||
static INLINE2 void i_push_di(void);
|
||||
static INLINE2 void i_pop_ax(void);
|
||||
static INLINE2 void i_pop_cx(void);
|
||||
static INLINE2 void i_pop_dx(void);
|
||||
static INLINE2 void i_pop_bx(void);
|
||||
static INLINE2 void i_pop_sp(void);
|
||||
static INLINE2 void i_pop_bp(void);
|
||||
static INLINE2 void i_pop_si(void);
|
||||
static INLINE2 void i_pop_di(void);
|
||||
static INLINE2 void i_jo(void);
|
||||
static INLINE2 void i_jno(void);
|
||||
static INLINE2 void i_jb(void);
|
||||
static INLINE2 void i_jnb(void);
|
||||
static INLINE2 void i_jz(void);
|
||||
static INLINE2 void i_jnz(void);
|
||||
static INLINE2 void i_jbe(void);
|
||||
static INLINE2 void i_jnbe(void);
|
||||
static INLINE2 void i_js(void);
|
||||
static INLINE2 void i_jns(void);
|
||||
static INLINE2 void i_jp(void);
|
||||
static INLINE2 void i_jnp(void);
|
||||
static INLINE2 void i_jl(void);
|
||||
static INLINE2 void i_jnl(void);
|
||||
static INLINE2 void i_jle(void);
|
||||
static INLINE2 void i_jnle(void);
|
||||
static INLINE2 void i_80pre(void);
|
||||
static INLINE2 void i_81pre(void);
|
||||
static INLINE2 void i_83pre(void);
|
||||
static INLINE2 void i_test_br8(void);
|
||||
static INLINE2 void i_test_wr16(void);
|
||||
static INLINE2 void i_xchg_br8(void);
|
||||
static INLINE2 void i_xchg_wr16(void);
|
||||
static INLINE2 void i_mov_br8(void);
|
||||
static INLINE2 void i_mov_r8b(void);
|
||||
static INLINE2 void i_mov_wr16(void);
|
||||
static INLINE2 void i_mov_r16w(void);
|
||||
static INLINE2 void i_mov_wsreg(void);
|
||||
static INLINE2 void i_lea(void);
|
||||
static INLINE2 void i_mov_sregw(void);
|
||||
static INLINE2 void i_notdone(void);
|
||||
static INLINE2 void i_popw(void);
|
||||
static INLINE2 void i_nop(void);
|
||||
static INLINE2 void i_xchg_axcx(void);
|
||||
static INLINE2 void i_xchg_axdx(void);
|
||||
static INLINE2 void i_xchg_axbx(void);
|
||||
static INLINE2 void i_xchg_axsp(void);
|
||||
static INLINE2 void i_xchg_axbp(void);
|
||||
static INLINE2 void i_xchg_axsi(void);
|
||||
static INLINE2 void i_xchg_axdi(void);
|
||||
static INLINE2 void i_cbw(void);
|
||||
static INLINE2 void i_cwd(void);
|
||||
static INLINE2 void i_call_far(void);
|
||||
static INLINE2 void i_pushf(void);
|
||||
static INLINE2 void i_popf(void);
|
||||
static INLINE2 void i_sahf(void);
|
||||
static INLINE2 void i_lahf(void);
|
||||
static INLINE2 void i_mov_aldisp(void);
|
||||
static INLINE2 void i_mov_axdisp(void);
|
||||
static INLINE2 void i_mov_dispal(void);
|
||||
static INLINE2 void i_mov_dispax(void);
|
||||
static INLINE2 void i_movsb(void);
|
||||
static INLINE2 void i_movsw(void);
|
||||
static INLINE2 void i_cmpsb(void);
|
||||
static INLINE2 void i_cmpsw(void);
|
||||
static INLINE2 void i_test_ald8(void);
|
||||
static INLINE2 void i_test_axd16(void);
|
||||
static INLINE2 void i_stosb(void);
|
||||
static INLINE2 void i_stosw(void);
|
||||
static INLINE2 void i_lodsb(void);
|
||||
static INLINE2 void i_lodsw(void);
|
||||
static INLINE2 void i_scasb(void);
|
||||
static INLINE2 void i_scasw(void);
|
||||
static INLINE2 void i_mov_ald8(void);
|
||||
static INLINE2 void i_mov_cld8(void);
|
||||
static INLINE2 void i_mov_dld8(void);
|
||||
static INLINE2 void i_mov_bld8(void);
|
||||
static INLINE2 void i_mov_ahd8(void);
|
||||
static INLINE2 void i_mov_chd8(void);
|
||||
static INLINE2 void i_mov_dhd8(void);
|
||||
static INLINE2 void i_mov_bhd8(void);
|
||||
static INLINE2 void i_mov_axd16(void);
|
||||
static INLINE2 void i_mov_cxd16(void);
|
||||
static INLINE2 void i_mov_dxd16(void);
|
||||
static INLINE2 void i_mov_bxd16(void);
|
||||
static INLINE2 void i_mov_spd16(void);
|
||||
static INLINE2 void i_mov_bpd16(void);
|
||||
static INLINE2 void i_mov_sid16(void);
|
||||
static INLINE2 void i_mov_did16(void);
|
||||
static INLINE2 void i_ret_d16(void);
|
||||
static INLINE2 void i_ret(void);
|
||||
static INLINE2 void i_les_dw(void);
|
||||
static INLINE2 void i_lds_dw(void);
|
||||
static INLINE2 void i_mov_bd8(void);
|
||||
static INLINE2 void i_mov_wd16(void);
|
||||
static INLINE2 void i_retf_d16(void);
|
||||
static INLINE2 void i_retf(void);
|
||||
static INLINE2 void i_int3(void);
|
||||
static INLINE2 void i_int(void);
|
||||
static INLINE2 void i_into(void);
|
||||
static INLINE2 void i_iret(void);
|
||||
static INLINE2 void i_d0pre(void);
|
||||
static INLINE2 void i_d1pre(void);
|
||||
static INLINE2 void i_d2pre(void);
|
||||
static INLINE2 void i_d3pre(void);
|
||||
static INLINE2 void i_aam(void);
|
||||
static INLINE2 void i_aad(void);
|
||||
static INLINE2 void i_xlat(void);
|
||||
static INLINE2 void i_escape(void);
|
||||
static INLINE2 void i_loopne(void);
|
||||
static INLINE2 void i_loope(void);
|
||||
static INLINE2 void i_loop(void);
|
||||
static INLINE2 void i_jcxz(void);
|
||||
static INLINE2 void i_inal(void);
|
||||
static INLINE2 void i_inax(void);
|
||||
static INLINE2 void i_outal(void);
|
||||
static INLINE2 void i_outax(void);
|
||||
static INLINE2 void i_call_d16(void);
|
||||
static INLINE2 void i_jmp_d16(void);
|
||||
static INLINE2 void i_jmp_far(void);
|
||||
static INLINE2 void i_jmp_d8(void);
|
||||
static INLINE2 void i_inaldx(void);
|
||||
static INLINE2 void i_inaxdx(void);
|
||||
static INLINE2 void i_outdxal(void);
|
||||
static INLINE2 void i_outdxax(void);
|
||||
static INLINE2 void i_lock(void);
|
||||
static INLINE2 void i_repne(void);
|
||||
static INLINE2 void i_repe(void);
|
||||
static INLINE2 void i_cmc(void);
|
||||
static INLINE2 void i_f6pre(void);
|
||||
static INLINE2 void i_f7pre(void);
|
||||
static INLINE2 void i_clc(void);
|
||||
static INLINE2 void i_stc(void);
|
||||
static INLINE2 void i_cli(void);
|
||||
static INLINE2 void i_sti(void);
|
||||
static INLINE2 void i_cld(void);
|
||||
static INLINE2 void i_std(void);
|
||||
static INLINE2 void i_fepre(void);
|
||||
static INLINE2 void i_ffpre(void);
|
||||
|
||||
static INLINE2 void i_wait(void);
|
||||
static INLINE2 void i_gobios(void);
|
||||
|
||||
/*
|
||||
i186 instruction
|
||||
|
||||
*/
|
||||
static INLINE2 void i_pusha(void);
|
||||
static INLINE2 void i_popa(void);
|
||||
static INLINE2 void i_bound(void);
|
||||
static INLINE2 void i_push_d16(void);
|
||||
static INLINE2 void i_imul_d16(void);
|
||||
static INLINE2 void i_push_d8(void);
|
||||
static INLINE2 void i_imul_d8(void);
|
||||
static INLINE2 void i_rotshft_bd8(void);
|
||||
static INLINE2 void i_rotshft_wd8(void);
|
||||
static INLINE2 void i_enter(void);
|
||||
static INLINE2 void i_leave(void);
|
||||
static INLINE2 void i_insb(void);
|
||||
static INLINE2 void i_insw(void);
|
||||
static INLINE2 void i_outsb(void);
|
||||
static INLINE2 void i_outsw(void);
|
||||
static INLINE2 void i_das(void);
|
||||
static INLINE2 void i_aas(void);
|
||||
|
||||
|
||||
|
||||
void (*instruction[256])(void) =
|
||||
{
|
||||
i_add_br8, /* 0x00 */
|
||||
i_add_wr16, /* 0x01 */
|
||||
i_add_r8b, /* 0x02 */
|
||||
i_add_r16w, /* 0x03 */
|
||||
i_add_ald8, /* 0x04 */
|
||||
i_add_axd16, /* 0x05 */
|
||||
i_push_es, /* 0x06 */
|
||||
i_pop_es, /* 0x07 */
|
||||
i_or_br8, /* 0x08 */
|
||||
i_or_wr16, /* 0x09 */
|
||||
i_or_r8b, /* 0x0a */
|
||||
i_or_r16w, /* 0x0b */
|
||||
i_or_ald8, /* 0x0c */
|
||||
i_or_axd16, /* 0x0d */
|
||||
i_push_cs, /* 0x0e */
|
||||
i_notdone,
|
||||
i_adc_br8, /* 0x10 */
|
||||
i_adc_wr16, /* 0x11 */
|
||||
i_adc_r8b, /* 0x12 */
|
||||
i_adc_r16w, /* 0x13 */
|
||||
i_adc_ald8, /* 0x14 */
|
||||
i_adc_axd16, /* 0x15 */
|
||||
i_push_ss, /* 0x16 */
|
||||
i_pop_ss, /* 0x17 */
|
||||
i_sbb_br8, /* 0x18 */
|
||||
i_sbb_wr16, /* 0x19 */
|
||||
i_sbb_r8b, /* 0x1a */
|
||||
i_sbb_r16w, /* 0x1b */
|
||||
i_sbb_ald8, /* 0x1c */
|
||||
i_sbb_axd16, /* 0x1d */
|
||||
i_push_ds, /* 0x1e */
|
||||
i_pop_ds, /* 0x1f */
|
||||
i_and_br8, /* 0x20 */
|
||||
i_and_wr16, /* 0x21 */
|
||||
i_and_r8b, /* 0x22 */
|
||||
i_and_r16w, /* 0x23 */
|
||||
i_and_ald8, /* 0x24 */
|
||||
i_and_axd16, /* 0x25 */
|
||||
i_es, /* 0x26 */
|
||||
i_daa, /* 0x27 */
|
||||
i_sub_br8, /* 0x28 */
|
||||
i_sub_wr16, /* 0x29 */
|
||||
i_sub_r8b, /* 0x2a */
|
||||
i_sub_r16w, /* 0x2b */
|
||||
i_sub_ald8, /* 0x2c */
|
||||
i_sub_axd16, /* 0x2d */
|
||||
i_cs, /* 0x2e */
|
||||
i_das, /* 0x2f */
|
||||
i_xor_br8, /* 0x30 */
|
||||
i_xor_wr16, /* 0x31 */
|
||||
i_xor_r8b, /* 0x32 */
|
||||
i_xor_r16w, /* 0x33 */
|
||||
i_xor_ald8, /* 0x34 */
|
||||
i_xor_axd16, /* 0x35 */
|
||||
i_ss, /* 0x36 */
|
||||
i_notdone,
|
||||
i_cmp_br8, /* 0x38 */
|
||||
i_cmp_wr16, /* 0x39 */
|
||||
i_cmp_r8b, /* 0x3a */
|
||||
i_cmp_r16w, /* 0x3b */
|
||||
i_cmp_ald8, /* 0x3c */
|
||||
i_cmp_axd16, /* 0x3d */
|
||||
i_ds, /* 0x3e */
|
||||
i_aas, /* 0x3f */
|
||||
i_inc_ax, /* 0x40 */
|
||||
i_inc_cx, /* 0x41 */
|
||||
i_inc_dx, /* 0x42 */
|
||||
i_inc_bx, /* 0x43 */
|
||||
i_inc_sp, /* 0x44 */
|
||||
i_inc_bp, /* 0x45 */
|
||||
i_inc_si, /* 0x46 */
|
||||
i_inc_di, /* 0x47 */
|
||||
i_dec_ax, /* 0x48 */
|
||||
i_dec_cx, /* 0x49 */
|
||||
i_dec_dx, /* 0x4a */
|
||||
i_dec_bx, /* 0x4b */
|
||||
i_dec_sp, /* 0x4c */
|
||||
i_dec_bp, /* 0x4d */
|
||||
i_dec_si, /* 0x4e */
|
||||
i_dec_di, /* 0x4f */
|
||||
i_push_ax, /* 0x50 */
|
||||
i_push_cx, /* 0x51 */
|
||||
i_push_dx, /* 0x52 */
|
||||
i_push_bx, /* 0x53 */
|
||||
i_push_sp, /* 0x54 */
|
||||
i_push_bp, /* 0x55 */
|
||||
i_push_si, /* 0x56 */
|
||||
i_push_di, /* 0x57 */
|
||||
i_pop_ax, /* 0x58 */
|
||||
i_pop_cx, /* 0x59 */
|
||||
i_pop_dx, /* 0x5a */
|
||||
i_pop_bx, /* 0x5b */
|
||||
i_pop_sp, /* 0x5c */
|
||||
i_pop_bp, /* 0x5d */
|
||||
i_pop_si, /* 0x5e */
|
||||
i_pop_di, /* 0x5f */
|
||||
i_pusha, /* 0x60 added */
|
||||
i_popa, /* 0x61 added */
|
||||
i_bound, /* 0x62 added */
|
||||
i_notdone, /* 0x63 */
|
||||
i_notdone, /* 0x64 */
|
||||
i_notdone, /* 0x65 */
|
||||
i_notdone, /* 0x66 */
|
||||
i_notdone, /* 0x67 */
|
||||
i_push_d16, /* 0x68 added */
|
||||
i_imul_d16, /* 0x69 added */
|
||||
i_push_d8, /* 0x6a added */
|
||||
i_imul_d8, /* 0x6b added */
|
||||
i_insb, /* 0x6c added */
|
||||
i_insw, /* 0x6d added */
|
||||
i_outsb, /* 0x6e added */
|
||||
i_outsw, /* 0x6f added */
|
||||
i_jo, /* 0x70 */
|
||||
i_jno, /* 0x71 */
|
||||
i_jb, /* 0x72 */
|
||||
i_jnb, /* 0x73 */
|
||||
i_jz, /* 0x74 */
|
||||
i_jnz, /* 0x75 */
|
||||
i_jbe, /* 0x76 */
|
||||
i_jnbe, /* 0x77 */
|
||||
i_js, /* 0x78 */
|
||||
i_jns, /* 0x79 */
|
||||
i_jp, /* 0x7a */
|
||||
i_jnp, /* 0x7b */
|
||||
i_jl, /* 0x7c */
|
||||
i_jnl, /* 0x7d */
|
||||
i_jle, /* 0x7e */
|
||||
i_jnle, /* 0x7f */
|
||||
i_80pre, /* 0x80 */
|
||||
i_81pre, /* 0x81 */
|
||||
i_notdone,
|
||||
i_83pre, /* 0x83 */
|
||||
i_test_br8, /* 0x84 */
|
||||
i_test_wr16, /* 0x85 */
|
||||
i_xchg_br8, /* 0x86 */
|
||||
i_xchg_wr16, /* 0x87 */
|
||||
i_mov_br8, /* 0x88 */
|
||||
i_mov_wr16, /* 0x89 */
|
||||
i_mov_r8b, /* 0x8a */
|
||||
i_mov_r16w, /* 0x8b */
|
||||
i_mov_wsreg, /* 0x8c */
|
||||
i_lea, /* 0x8d */
|
||||
i_mov_sregw, /* 0x8e */
|
||||
i_popw, /* 0x8f */
|
||||
i_nop, /* 0x90 */
|
||||
i_xchg_axcx, /* 0x91 */
|
||||
i_xchg_axdx, /* 0x92 */
|
||||
i_xchg_axbx, /* 0x93 */
|
||||
i_xchg_axsp, /* 0x94 */
|
||||
i_xchg_axbp, /* 0x95 */
|
||||
i_xchg_axsi, /* 0x97 */
|
||||
i_xchg_axdi, /* 0x97 */
|
||||
i_cbw, /* 0x98 */
|
||||
i_cwd, /* 0x99 */
|
||||
i_call_far, /* 0x9a */
|
||||
i_wait, /* 0x9b */
|
||||
i_pushf, /* 0x9c */
|
||||
i_popf, /* 0x9d */
|
||||
i_sahf, /* 0x9e */
|
||||
i_lahf, /* 0x9f */
|
||||
i_mov_aldisp, /* 0xa0 */
|
||||
i_mov_axdisp, /* 0xa1 */
|
||||
i_mov_dispal, /* 0xa2 */
|
||||
i_mov_dispax, /* 0xa3 */
|
||||
i_movsb, /* 0xa4 */
|
||||
i_movsw, /* 0xa5 */
|
||||
i_cmpsb, /* 0xa6 */
|
||||
i_cmpsw, /* 0xa7 */
|
||||
i_test_ald8, /* 0xa8 */
|
||||
i_test_axd16, /* 0xa9 */
|
||||
i_stosb, /* 0xaa */
|
||||
i_stosw, /* 0xab */
|
||||
i_lodsb, /* 0xac */
|
||||
i_lodsw, /* 0xad */
|
||||
i_scasb, /* 0xae */
|
||||
i_scasw, /* 0xaf */
|
||||
i_mov_ald8, /* 0xb0 */
|
||||
i_mov_cld8, /* 0xb1 */
|
||||
i_mov_dld8, /* 0xb2 */
|
||||
i_mov_bld8, /* 0xb3 */
|
||||
i_mov_ahd8, /* 0xb4 */
|
||||
i_mov_chd8, /* 0xb5 */
|
||||
i_mov_dhd8, /* 0xb6 */
|
||||
i_mov_bhd8, /* 0xb7 */
|
||||
i_mov_axd16, /* 0xb8 */
|
||||
i_mov_cxd16, /* 0xb9 */
|
||||
i_mov_dxd16, /* 0xba */
|
||||
i_mov_bxd16, /* 0xbb */
|
||||
i_mov_spd16, /* 0xbc */
|
||||
i_mov_bpd16, /* 0xbd */
|
||||
i_mov_sid16, /* 0xbe */
|
||||
i_mov_did16, /* 0xbf */
|
||||
i_rotshft_bd8, /* 0xc0 added */
|
||||
i_rotshft_wd8, /* 0xc1 added */
|
||||
i_ret_d16, /* 0xc2 */
|
||||
i_ret, /* 0xc3 */
|
||||
i_les_dw, /* 0xc4 */
|
||||
i_lds_dw, /* 0xc5 */
|
||||
i_mov_bd8, /* 0xc6 */
|
||||
i_mov_wd16, /* 0xc7 */
|
||||
i_enter, /* 0xc8 added */
|
||||
i_leave, /* 0xc9 added */
|
||||
i_retf_d16, /* 0xca */
|
||||
i_retf, /* 0xcb */
|
||||
i_int3, /* 0xcc */
|
||||
i_int, /* 0xcd */
|
||||
i_into, /* 0xce */
|
||||
i_iret, /* 0xcf */
|
||||
i_d0pre, /* 0xd0 */
|
||||
i_d1pre, /* 0xd1 */
|
||||
i_d2pre, /* 0xd2 */
|
||||
i_d3pre, /* 0xd3 */
|
||||
i_aam, /* 0xd4 */
|
||||
i_aad, /* 0xd5 */
|
||||
i_notdone,
|
||||
i_xlat, /* 0xd7 */
|
||||
i_escape, /* 0xd8 */
|
||||
i_escape, /* 0xd9 */
|
||||
i_escape, /* 0xda */
|
||||
i_escape, /* 0xdb */
|
||||
i_escape, /* 0xdc */
|
||||
i_escape, /* 0xdd */
|
||||
i_escape, /* 0xde */
|
||||
i_escape, /* 0xdf */
|
||||
i_loopne, /* 0xe0 */
|
||||
i_loope, /* 0xe1 */
|
||||
i_loop, /* 0xe2 */
|
||||
i_jcxz, /* 0xe3 */
|
||||
i_inal, /* 0xe4 */
|
||||
i_inax, /* 0xe5 */
|
||||
i_outal, /* 0xe6 */
|
||||
i_outax, /* 0xe7 */
|
||||
i_call_d16, /* 0xe8 */
|
||||
i_jmp_d16, /* 0xe9 */
|
||||
i_jmp_far, /* 0xea */
|
||||
i_jmp_d8, /* 0xeb */
|
||||
i_inaldx, /* 0xec */
|
||||
i_inaxdx, /* 0xed */
|
||||
i_outdxal, /* 0xee */
|
||||
i_outdxax, /* 0xef */
|
||||
i_lock, /* 0xf0 */
|
||||
i_gobios, /* 0xf1 */
|
||||
i_repne, /* 0xf2 */
|
||||
i_repe, /* 0xf3 */
|
||||
i_notdone,
|
||||
i_cmc, /* 0xf5 */
|
||||
i_f6pre, /* 0xf6 */
|
||||
i_f7pre, /* 0xf7 */
|
||||
i_clc, /* 0xf8 */
|
||||
i_stc, /* 0xf9 */
|
||||
i_cli, /* 0xfa */
|
||||
i_sti, /* 0xfb */
|
||||
i_cld, /* 0xfc */
|
||||
i_std, /* 0xfd */
|
||||
i_fepre, /* 0xfe */
|
||||
i_ffpre /* 0xff */
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
55
cpu/mytypes.h
Normal file
55
cpu/mytypes.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/****************************************************************************
|
||||
* *
|
||||
* Third Year Project *
|
||||
* *
|
||||
* An IBM PC Emulator *
|
||||
* For Unix and X Windows *
|
||||
* *
|
||||
* By David Hedley *
|
||||
* *
|
||||
* *
|
||||
* This program is Copyrighted. Consult the file COPYRIGHT for more details *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
/* This is MYTYPES.H It contains definitions for the basic types to ease
|
||||
portability */
|
||||
|
||||
|
||||
#ifndef MYTYPES_H
|
||||
#define MYTYPES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef signed char INT8;
|
||||
typedef unsigned char UINT8;
|
||||
typedef signed short INT16;
|
||||
typedef unsigned short UINT16;
|
||||
|
||||
#ifndef _WINDOWS
|
||||
|
||||
typedef signed long INT32;
|
||||
typedef unsigned long UINT32;
|
||||
|
||||
|
||||
typedef UINT8 BYTE;
|
||||
typedef UINT16 WORD;
|
||||
typedef UINT32 DWORD;
|
||||
|
||||
#else
|
||||
|
||||
#include <windows.h>
|
||||
#define LITTLE_ENDIAN
|
||||
#define ALIGNED_ACCESS
|
||||
//#define BIGCASE
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user