use Paulo's reduced version

git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1853 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Li-Ta Lo 2005-01-11 03:18:39 +00:00
parent 3678ad8e38
commit 8b0356c2c9
24 changed files with 10514 additions and 17195 deletions

View File

@ -50,8 +50,8 @@ int run_bios_int(int num)
X86_CS = MEM_RW((num << 2) + 2);
X86_IP = MEM_RW(num << 2);
//printf("%s: INT %x CS:IP = %x:%x\n", __FUNCTION__,
// num, MEM_RW((num << 2) + 2), MEM_RW(num << 2));
printf("%s: INT %x CS:IP = %x:%x\n", __FUNCTION__,
num, MEM_RW((num << 2) + 2), MEM_RW(num << 2));
return 1;
}
@ -128,7 +128,7 @@ u8 x_inb(u16 port)
val = inb(port);
//printf("inb(0x%04x) = 0x%02x\n", port, val);
printf("inb(0x%04x) = 0x%02x\n", port, val);
return val;
}
@ -139,7 +139,7 @@ u16 x_inw(u16 port)
val = inw(port);
//printf("inw(0x%04x) = 0x%04x\n", port, val);
printf("inw(0x%04x) = 0x%04x\n", port, val);
return val;
}
@ -149,25 +149,26 @@ u32 x_inl(u16 port)
val = inl(port);
//printf("inl(0x%04x) = 0x%08x\n", port, val);
printf("inl(0x%04x) = 0x%08x\n", port, val);
return val;
}
void x_outb(u16 port, u8 val)
{
//printf("outb(0x%02x, 0x%04x)\n", val, port);
printf("outb(0x%02x, 0x%04x)\n",
val, port);
outb(val, port);
}
void x_outw(u16 port, u16 val)
{
//printf("outw(0x%04x, 0x%04x)\n", val, port);
printf("outw(0x%04x, 0x%04x)\n", val, port);
outw(val, port);
}
void x_outl(u16 port, u32 val)
{
//printf("outl(0x%08x, 0x%04x)\n", val, port);
printf("outl(0x%08x, 0x%04x)\n", val, port);
outl(val, port);
}

View File

@ -18,7 +18,7 @@ extern int verbose;
*/
int int42_handler()
{
#if 0
if (verbose && X86_AH != 0x0e) {
printf("int%x\n", current->num);
x86emu_dump_xregs();
@ -472,7 +472,7 @@ int int42_handler()
/* Ignored */
break;
}
#endif
return 1;
}
#endif

View File

@ -6,7 +6,7 @@ void x86emu_dump_xregs();
int int15_handler(void)
{
printf("\nint15 encountered.\n");
x86emu_dump_xregs();
//x86emu_dump_xregs();
X86_EAX = 0;
return 1;
}

View File

@ -19,7 +19,7 @@ int int1A_handler()
if (verbose) {
printf("\nint1a encountered.\n");
x86emu_dump_xregs();
//x86emu_dump_xregs();
}
switch (X86_AX) {

View File

@ -44,7 +44,7 @@ PCITAG findPci(unsigned short bx)
tag->slot = slot;
tag->func = func;
if (pci_get_dev(pacc, bus, slot, func))
if (pci_get_dev(pacc, 0, bus, slot, func))
return tag;
return NULL;
@ -58,7 +58,7 @@ u32 pciSlotBX(PCITAG tag)
u8 pciReadByte(PCITAG tag, u32 idx)
{
struct pci_dev *d;
if ((d = pci_get_dev(pacc, tag->bus, tag->slot, tag->func)))
if ((d = pci_get_dev(pacc, 0, tag->bus, tag->slot, tag->func)))
return pci_read_byte(d, idx);
#ifdef DEBUG_PCI
printf("PCI: device not found while read byte (%x:%x.%x)\n",
@ -70,7 +70,7 @@ u8 pciReadByte(PCITAG tag, u32 idx)
u16 pciReadWord(PCITAG tag, u32 idx)
{
struct pci_dev *d;
if ((d = pci_get_dev(pacc, tag->bus, tag->slot, tag->func)))
if ((d = pci_get_dev(pacc, 0, tag->bus, tag->slot, tag->func)))
return pci_read_word(d, idx);
#ifdef DEBUG_PCI
printf("PCI: device not found while read word (%x:%x.%x)\n",
@ -82,7 +82,7 @@ u16 pciReadWord(PCITAG tag, u32 idx)
u32 pciReadLong(PCITAG tag, u32 idx)
{
struct pci_dev *d;
if ((d = pci_get_dev(pacc, tag->bus, tag->slot, tag->func)))
if ((d = pci_get_dev(pacc, 0, tag->bus, tag->slot, tag->func)))
return pci_read_long(d, idx);
#ifdef DEBUG_PCI
printf("PCI: device not found while read long (%x:%x.%x)\n",
@ -95,7 +95,7 @@ u32 pciReadLong(PCITAG tag, u32 idx)
void pciWriteLong(PCITAG tag, u32 idx, u32 data)
{
struct pci_dev *d;
if ((d = pci_get_dev(pacc, tag->bus, tag->slot, tag->func)))
if ((d = pci_get_dev(pacc, 0, tag->bus, tag->slot, tag->func)))
pci_write_long(d, idx, data);
#ifdef DEBUG_PCI
else
@ -107,7 +107,7 @@ void pciWriteLong(PCITAG tag, u32 idx, u32 data)
void pciWriteWord(PCITAG tag, u32 idx, u16 data)
{
struct pci_dev *d;
if ((d = pci_get_dev(pacc, tag->bus, tag->slot, tag->func)))
if ((d = pci_get_dev(pacc, 0, tag->bus, tag->slot, tag->func)))
pci_write_word(d, idx, data);
#ifdef DEBUG_PCI
else
@ -120,7 +120,7 @@ void pciWriteWord(PCITAG tag, u32 idx, u16 data)
void pciWriteByte(PCITAG tag, u32 idx, u8 data)
{
struct pci_dev *d;
if ((d = pci_get_dev(pacc, tag->bus, tag->slot, tag->func)))
if ((d = pci_get_dev(pacc, 0, tag->bus, tag->slot, tag->func)))
pci_write_long(d, idx, data);
#ifdef DEBUG_PCI
else

View File

@ -76,7 +76,7 @@ void do_int(int num)
if (!ret) {
printf("\nint%x: not implemented\n", num);
x86emu_dump_xregs();
//x86emu_dump_xregs();
}
}
@ -317,10 +317,10 @@ int main(int argc, char **argv)
if (trace) {
printf("Switching to single step mode.\n");
X86EMU_trace_on();
//X86EMU_trace_on();
}
if (debugflag) {
X86EMU_set_debug(debugflag);
//X86EMU_set_debug(debugflag);
}
X86EMU_exec();
/* Cleaning up */

View File

@ -181,6 +181,8 @@ void X86EMU_halt_sys(void);
#define DEBUG_TRACECALL_REGS_F 0x004000
#define DEBUG_DECODE_NOPRINT_F 0x008000
#define DEBUG_SAVE_IP_CS_F 0x010000
#define DEBUG_EXIT 0x020000
#define DEBUG_SAVE_CS_IP 0x040000
#define DEBUG_SYS_F (DEBUG_SVC_F|DEBUG_FS_F|DEBUG_PROC_F)
void X86EMU_trace_regs(void);

View File

@ -2,7 +2,7 @@
*
* Realmode X86 Emulator Library
*
* Copyright (C) 1996-1999 SciTech Software, Inc.
* Copyright (C) 1991-2004 SciTech Software, Inc.
* Copyright (C) David Mosberger-Tang
* Copyright (C) 1999 Egbert Eich
*
@ -36,56 +36,50 @@
* emulator.
*
****************************************************************************/
/* $XFree86: xc/extras/x86emu/src/x86emu/debug.c,v 1.4 2000/04/17 16:29:45 eich Exp $ */
#include "x86emu/x86emui.h"
#ifdef IN_MODULE
#include "xf86_ansic.h"
#else
#include <stdarg.h>
#include <stdlib.h>
#endif
/*----------------------------- Implementation ----------------------------*/
#ifdef DEBUG
static void print_encoded_bytes(u16 s, u16 o);
static void print_decoded_instruction(void);
static int parse_line(char *s, int *ps, int *n);
static void print_encoded_bytes (u16 s, u16 o);
static void print_decoded_instruction (void);
static int parse_line (char *s, int *ps, int *n);
/* should look something like debug's output. */
void X86EMU_trace_regs(void)
void X86EMU_trace_regs (void)
{
if (DEBUG_TRACE()) {
x86emu_dump_regs();
}
if (DEBUG_DECODE() && !DEBUG_DECODE_NOPRINT()) {
printk("%04x:%04x ", M.x86.saved_cs, M.x86.saved_ip);
print_encoded_bytes(M.x86.saved_cs, M.x86.saved_ip);
if (DEBUG_DECODE() && ! DEBUG_DECODE_NOPRINT()) {
printk("%04x:%04x ",M.x86.saved_cs, M.x86.saved_ip);
print_encoded_bytes( M.x86.saved_cs, M.x86.saved_ip);
print_decoded_instruction();
}
}
void X86EMU_trace_xregs(void)
void X86EMU_trace_xregs (void)
{
if (DEBUG_TRACE()) {
x86emu_dump_xregs();
}
}
void x86emu_just_disassemble(void)
void x86emu_just_disassemble (void)
{
/*
* This routine called if the flag DEBUG_DISASSEMBLE is set kind
* of a hack!
*/
printk("%04x:%04x ", M.x86.saved_cs, M.x86.saved_ip);
print_encoded_bytes(M.x86.saved_cs, M.x86.saved_ip);
printk("%04x:%04x ",M.x86.saved_cs, M.x86.saved_ip);
print_encoded_bytes( M.x86.saved_cs, M.x86.saved_ip);
print_decoded_instruction();
}
static void disassemble_forward(u16 seg, u16 off, int n)
static void disassemble_forward (u16 seg, u16 off, int n)
{
X86EMU_sysEnv tregs;
int i;
@ -133,104 +127,103 @@ static void disassemble_forward(u16 seg, u16 off, int n)
* the instruction. XXX --- CHECK THAT MEM IS NOT AFFECTED!!!
* Note the use of a copy of the register structure...
*/
for (i = 0; i < n; i++) {
op1 = (*sys_rdb) (((u32) M.x86.R_CS << 4) + (M.x86.R_IP++));
(x86emu_optab[op1]) (op1);
for (i=0; i<n; i++) {
op1 = (*sys_rdb)(((u32)M.x86.R_CS<<4) + (M.x86.R_IP++));
(x86emu_optab[op1])(op1);
}
/* end major hack mode. */
}
void x86emu_check_ip_access(void)
void x86emu_check_ip_access (void)
{
/* NULL as of now */
}
void x86emu_check_sp_access(void)
void x86emu_check_sp_access (void)
{
}
void x86emu_check_mem_access(u32 dummy)
void x86emu_check_mem_access (u32 dummy)
{
/* check bounds, etc */
}
void x86emu_check_data_access(uint dummy1, uint dummy2)
void x86emu_check_data_access (uint dummy1, uint dummy2)
{
/* check bounds, etc */
}
void x86emu_inc_decoded_inst_len(int x)
void x86emu_inc_decoded_inst_len (int x)
{
M.x86.enc_pos += x;
}
void x86emu_decode_printf(char *x)
void x86emu_decode_printf (char *x)
{
sprintf(M.x86.decoded_buf + M.x86.enc_str_pos, "%s", x);
sprintf(M.x86.decoded_buf+M.x86.enc_str_pos,"%s",x);
M.x86.enc_str_pos += strlen(x);
}
void x86emu_decode_printf2(char *x, int y)
void x86emu_decode_printf2 (char *x, int y)
{
char temp[100];
sprintf(temp, x, y);
sprintf(M.x86.decoded_buf + M.x86.enc_str_pos, "%s", temp);
sprintf(temp,x,y);
sprintf(M.x86.decoded_buf+M.x86.enc_str_pos,"%s",temp);
M.x86.enc_str_pos += strlen(temp);
}
void x86emu_end_instr(void)
void x86emu_end_instr (void)
{
M.x86.enc_str_pos = 0;
M.x86.enc_pos = 0;
}
static void print_encoded_bytes(u16 s, u16 o)
static void print_encoded_bytes (u16 s, u16 o)
{
int i;
char buf1[64];
for (i = 0; i < M.x86.enc_pos; i++) {
sprintf(buf1 + 2 * i, "%02x", fetch_data_byte_abs(s, o + i));
for (i=0; i< M.x86.enc_pos; i++) {
sprintf(buf1+2*i,"%02x", fetch_data_byte_abs(s,o+i));
}
printk("%-20s", buf1);
printk("%-20s",buf1);
}
static void print_decoded_instruction(void)
static void print_decoded_instruction (void)
{
printk("%s", M.x86.decoded_buf);
}
void x86emu_print_int_vect(u16 iv)
void x86emu_print_int_vect (u16 iv)
{
u16 seg, off;
u16 seg,off;
if (iv > 256)
return;
seg = fetch_data_word_abs(0, iv * 4);
off = fetch_data_word_abs(0, iv * 4 + 2);
if (iv > 256) return;
seg = fetch_data_word_abs(0,iv*4);
off = fetch_data_word_abs(0,iv*4+2);
printk("%04x:%04x ", seg, off);
}
void X86EMU_dump_memory(u16 seg, u16 off, u32 amt)
void X86EMU_dump_memory (u16 seg, u16 off, u32 amt)
{
u32 start = off & 0xfffffff0;
u32 end = (off + 16) & 0xfffffff0;
u32 end = (off+16) & 0xfffffff0;
u32 i;
u32 current;
current = start;
while (end <= off + amt) {
printk("%04x:%04x ", seg, start);
for (i = start; i < off; i++)
for (i=start; i< off; i++)
printk(" ");
for (; i < end; i++)
printk("%02x ", fetch_data_byte_abs(seg, i));
for ( ; i< end; i++)
printk("%02x ", fetch_data_byte_abs(seg,i));
printk("\n");
start = end;
end = start + 16;
}
}
void x86emu_single_step(void)
void x86emu_single_step (void)
{
char s[1024];
int ps[10];
@ -251,34 +244,34 @@ void x86emu_single_step(void)
M.x86.debug &= ~DEBUG_DECODE_NOPRINT_F;
M.x86.debug |= DEBUG_TRACE_F;
M.x86.debug &= ~DEBUG_BREAK_F;
print_decoded_instruction();
print_decoded_instruction ();
X86EMU_trace_regs();
}
}
done = 0;
done=0;
offset = M.x86.saved_ip;
while (!done) {
printk("%x:%x -", M.x86.saved_cs, offset);
printk("-");
p = fgets(s, 1023, stdin);
cmd = parse_line(s, ps, &ntok);
switch (cmd) {
switch(cmd) {
case 'u':
disassemble_forward(M.x86.saved_cs, (u16) offset, 10);
disassemble_forward(M.x86.saved_cs,(u16)offset,10);
break;
case 'd':
if (ntok == 2) {
segment = M.x86.saved_cs;
offset = ps[1];
X86EMU_dump_memory(segment, (u16) offset, 16);
X86EMU_dump_memory(segment,(u16)offset,16);
offset += 16;
} else if (ntok == 3) {
segment = ps[1];
offset = ps[2];
X86EMU_dump_memory(segment, (u16) offset, 16);
X86EMU_dump_memory(segment,(u16)offset,16);
offset += 16;
} else {
segment = M.x86.saved_cs;
X86EMU_dump_memory(segment, (u16) offset, 16);
X86EMU_dump_memory(segment,(u16)offset,16);
offset += 16;
}
break;
@ -308,10 +301,11 @@ void x86emu_single_step(void)
}
break;
case 'q':
exit(1);
M.x86.debug |= DEBUG_EXIT;
return;
case 'P':
noDecode = (noDecode) ? 0 : 1;
printk("Toggled decoding to %s\n", (noDecode) ? "FALSE" : "TRUE");
noDecode = (noDecode)?0:1;
printk("Toggled decoding to %s\n",(noDecode)?"FALSE":"TRUE");
break;
case 't':
case 0:
@ -323,7 +317,7 @@ void x86emu_single_step(void)
int X86EMU_trace_on(void)
{
return M.x86.debug |= /*DEBUG_STEP_F | */ DEBUG_DECODE_F | DEBUG_TRACE_F;
return M.x86.debug |= DEBUG_STEP_F | DEBUG_DECODE_F | DEBUG_TRACE_F;
}
int X86EMU_trace_off(void)
@ -331,18 +325,12 @@ int X86EMU_trace_off(void)
return M.x86.debug &= ~(DEBUG_STEP_F | DEBUG_DECODE_F | DEBUG_TRACE_F);
}
int X86EMU_set_debug(int debug)
{
return M.x86.debug = debug;
}
static int parse_line(char *s, int *ps, int *n)
static int parse_line (char *s, int *ps, int *n)
{
int cmd;
*n = 0;
while (*s == ' ' || *s == '\t')
s++;
while(*s == ' ' || *s == '\t') s++;
ps[*n] = *s;
switch (*s) {
case '\n':
@ -354,118 +342,84 @@ static int parse_line(char *s, int *ps, int *n)
}
while (1) {
while (*s != ' ' && *s != '\t' && *s != '\n')
s++;
while (*s != ' ' && *s != '\t' && *s != '\n') s++;
if (*s == '\n')
return cmd;
while (*s == ' ' || *s == '\t')
s++;
while(*s == ' ' || *s == '\t') s++;
sscanf(s, "%x", &ps[*n]);
sscanf(s,"%x",&ps[*n]);
*n += 1;
}
}
#endif /* DEBUG */
void x86emu_dump_regs(void)
void x86emu_dump_regs (void)
{
printk("\tAX=%04x ", M.x86.R_AX);
printk("BX=%04x ", M.x86.R_BX);
printk("CX=%04x ", M.x86.R_CX);
printk("DX=%04x ", M.x86.R_DX);
printk("SP=%04x ", M.x86.R_SP);
printk("BP=%04x ", M.x86.R_BP);
printk("SI=%04x ", M.x86.R_SI);
printk("DI=%04x\n", M.x86.R_DI);
printk("\tDS=%04x ", M.x86.R_DS);
printk("ES=%04x ", M.x86.R_ES);
printk("SS=%04x ", M.x86.R_SS);
printk("CS=%04x ", M.x86.R_CS);
printk("IP=%04x ", M.x86.R_IP);
if (ACCESS_FLAG(F_OF))
printk("OV "); /* CHECKED... */
else
printk("NV ");
if (ACCESS_FLAG(F_DF))
printk("DN ");
else
printk("UP ");
if (ACCESS_FLAG(F_IF))
printk("EI ");
else
printk("DI ");
if (ACCESS_FLAG(F_SF))
printk("NG ");
else
printk("PL ");
if (ACCESS_FLAG(F_ZF))
printk("ZR ");
else
printk("NZ ");
if (ACCESS_FLAG(F_AF))
printk("AC ");
else
printk("NA ");
if (ACCESS_FLAG(F_PF))
printk("PE ");
else
printk("PO ");
if (ACCESS_FLAG(F_CF))
printk("CY ");
else
printk("NC ");
printk("\tAX=%04x ", M.x86.R_AX );
printk("BX=%04x ", M.x86.R_BX );
printk("CX=%04x ", M.x86.R_CX );
printk("DX=%04x ", M.x86.R_DX );
printk("SP=%04x ", M.x86.R_SP );
printk("BP=%04x ", M.x86.R_BP );
printk("SI=%04x ", M.x86.R_SI );
printk("DI=%04x\n", M.x86.R_DI );
printk("\tDS=%04x ", M.x86.R_DS );
printk("ES=%04x ", M.x86.R_ES );
printk("SS=%04x ", M.x86.R_SS );
printk("CS=%04x ", M.x86.R_CS );
printk("IP=%04x ", M.x86.R_IP );
if (ACCESS_FLAG(F_OF)) printk("OV "); /* CHECKED... */
else printk("NV ");
if (ACCESS_FLAG(F_DF)) printk("DN ");
else printk("UP ");
if (ACCESS_FLAG(F_IF)) printk("EI ");
else printk("DI ");
if (ACCESS_FLAG(F_SF)) printk("NG ");
else printk("PL ");
if (ACCESS_FLAG(F_ZF)) printk("ZR ");
else printk("NZ ");
if (ACCESS_FLAG(F_AF)) printk("AC ");
else printk("NA ");
if (ACCESS_FLAG(F_PF)) printk("PE ");
else printk("PO ");
if (ACCESS_FLAG(F_CF)) printk("CY ");
else printk("NC ");
printk("\n");
}
void x86emu_dump_xregs(void)
void x86emu_dump_xregs (void)
{
printk("\tEAX=%08x ", M.x86.R_EAX);
printk("EBX=%08x ", M.x86.R_EBX);
printk("ECX=%08x ", M.x86.R_ECX);
printk("EDX=%08x \n", M.x86.R_EDX);
printk("\tESP=%08x ", M.x86.R_ESP);
printk("EBP=%08x ", M.x86.R_EBP);
printk("ESI=%08x ", M.x86.R_ESI);
printk("EDI=%08x\n", M.x86.R_EDI);
printk("\tDS=%04x ", M.x86.R_DS);
printk("ES=%04x ", M.x86.R_ES);
printk("SS=%04x ", M.x86.R_SS);
printk("CS=%04x ", M.x86.R_CS);
printk("EIP=%08x\n\t", M.x86.R_EIP);
if (ACCESS_FLAG(F_OF))
printk("OV "); /* CHECKED... */
else
printk("NV ");
if (ACCESS_FLAG(F_DF))
printk("DN ");
else
printk("UP ");
if (ACCESS_FLAG(F_IF))
printk("EI ");
else
printk("DI ");
if (ACCESS_FLAG(F_SF))
printk("NG ");
else
printk("PL ");
if (ACCESS_FLAG(F_ZF))
printk("ZR ");
else
printk("NZ ");
if (ACCESS_FLAG(F_AF))
printk("AC ");
else
printk("NA ");
if (ACCESS_FLAG(F_PF))
printk("PE ");
else
printk("PO ");
if (ACCESS_FLAG(F_CF))
printk("CY ");
else
printk("NC ");
printk("\tEAX=%08x ", M.x86.R_EAX );
printk("EBX=%08x ", M.x86.R_EBX );
printk("ECX=%08x ", M.x86.R_ECX );
printk("EDX=%08x \n", M.x86.R_EDX );
printk("\tESP=%08x ", M.x86.R_ESP );
printk("EBP=%08x ", M.x86.R_EBP );
printk("ESI=%08x ", M.x86.R_ESI );
printk("EDI=%08x\n", M.x86.R_EDI );
printk("\tDS=%04x ", M.x86.R_DS );
printk("ES=%04x ", M.x86.R_ES );
printk("SS=%04x ", M.x86.R_SS );
printk("CS=%04x ", M.x86.R_CS );
printk("EIP=%08x\n\t", M.x86.R_EIP );
if (ACCESS_FLAG(F_OF)) printk("OV "); /* CHECKED... */
else printk("NV ");
if (ACCESS_FLAG(F_DF)) printk("DN ");
else printk("UP ");
if (ACCESS_FLAG(F_IF)) printk("EI ");
else printk("DI ");
if (ACCESS_FLAG(F_SF)) printk("NG ");
else printk("PL ");
if (ACCESS_FLAG(F_ZF)) printk("ZR ");
else printk("NZ ");
if (ACCESS_FLAG(F_AF)) printk("AC ");
else printk("NA ");
if (ACCESS_FLAG(F_PF)) printk("PE ");
else printk("PO ");
if (ACCESS_FLAG(F_CF)) printk("CY ");
else printk("NC ");
printk("\n");
}

View File

@ -2,7 +2,7 @@
*
* Realmode X86 Emulator Library
*
* Copyright (C) 1996-1999 SciTech Software, Inc.
* Copyright (C) 1991-2004 SciTech Software, Inc.
* Copyright (C) David Mosberger-Tang
* Copyright (C) 1999 Egbert Eich
*
@ -37,8 +37,6 @@
*
****************************************************************************/
/* $XFree86: xc/extras/x86emu/src/x86emu/decode.c,v 1.9 2001/01/06 20:19:03 tsi Exp $ */
#include "x86emu/x86emui.h"
/*----------------------------- Implementation ----------------------------*/
@ -54,9 +52,9 @@ static void x86emu_intr_handle(void)
if (M.x86.intr & INTR_SYNCH) {
intno = M.x86.intno;
if (_X86EMU_intrTab[intno]) {
(*_X86EMU_intrTab[intno]) (intno);
(*_X86EMU_intrTab[intno])(intno);
} else {
push_word((u16) M.x86.R_FLG);
push_word((u16)M.x86.R_FLG);
CLEAR_FLAG(F_IF);
CLEAR_FLAG(F_TF);
push_word(M.x86.R_CS);
@ -76,7 +74,8 @@ REMARKS:
Raise the specified interrupt to be handled before the execution of the
next instruction.
****************************************************************************/
void x86emu_intr_raise(u8 intrnum)
void x86emu_intr_raise(
u8 intrnum)
{
M.x86.intno = intrnum;
M.x86.intr |= INTR_SYNCH;
@ -93,29 +92,37 @@ void X86EMU_exec(void)
u8 op1;
M.x86.intr = 0;
DB(x86emu_end_instr();
)
DB(x86emu_end_instr();)
for (;;) {
DB(if (CHECK_IP_FETCH())
DB( if (CHECK_IP_FETCH())
x86emu_check_ip_access();)
/* If debugging, save the IP and CS values. */
SAVE_IP_CS(M.x86.R_CS, M.x86.R_IP);
INC_DECODED_INST_LEN(1);
if (M.x86.intr) {
if (M.x86.intr & INTR_HALTED) {
DB(printk("halted\n"); X86EMU_trace_regs();
)
DB( if (M.x86.R_SP != 0) {
printk("halted\n");
X86EMU_trace_regs();
}
else {
if (M.x86.debug)
printk("Service completed successfully\n");
})
return;
}
if (((M.x86.intr & INTR_SYNCH)
&& (M.x86.intno == 0 || M.x86.intno == 2))
|| !ACCESS_FLAG(F_IF)) {
if (((M.x86.intr & INTR_SYNCH) && (M.x86.intno == 0 || M.x86.intno == 2)) ||
!ACCESS_FLAG(F_IF)) {
x86emu_intr_handle();
}
}
op1 = (*sys_rdb) (((u32) M.x86.R_CS << 4) + (M.x86.R_IP++));
(*x86emu_optab[op1]) (op1);
op1 = (*sys_rdb)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP++));
(*x86emu_optab[op1])(op1);
if (M.x86.debug & DEBUG_EXIT) {
M.x86.debug &= ~DEBUG_EXIT;
return;
}
}
}
@ -140,13 +147,16 @@ next instruction.
NOTE: Do not inline this function, as (*sys_rdb) is already inline!
****************************************************************************/
void fetch_decode_modrm(int *mod, int *regh, int *regl)
void fetch_decode_modrm(
int *mod,
int *regh,
int *regl)
{
int fetched;
DB(if (CHECK_IP_FETCH())
DB( if (CHECK_IP_FETCH())
x86emu_check_ip_access();)
fetched = (*sys_rdb) (((u32) M.x86.R_CS << 4) + (M.x86.R_IP++));
fetched = (*sys_rdb)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP++));
INC_DECODED_INST_LEN(1);
*mod = (fetched >> 6) & 0x03;
*regh = (fetched >> 3) & 0x07;
@ -167,9 +177,9 @@ u8 fetch_byte_imm(void)
{
u8 fetched;
DB(if (CHECK_IP_FETCH())
DB( if (CHECK_IP_FETCH())
x86emu_check_ip_access();)
fetched = (*sys_rdb) (((u32) M.x86.R_CS << 4) + (M.x86.R_IP++));
fetched = (*sys_rdb)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP++));
INC_DECODED_INST_LEN(1);
return fetched;
}
@ -188,9 +198,9 @@ u16 fetch_word_imm(void)
{
u16 fetched;
DB(if (CHECK_IP_FETCH())
DB( if (CHECK_IP_FETCH())
x86emu_check_ip_access();)
fetched = (*sys_rdw) (((u32) M.x86.R_CS << 4) + (M.x86.R_IP));
fetched = (*sys_rdw)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP));
M.x86.R_IP += 2;
INC_DECODED_INST_LEN(2);
return fetched;
@ -210,9 +220,9 @@ u32 fetch_long_imm(void)
{
u32 fetched;
DB(if (CHECK_IP_FETCH())
DB( if (CHECK_IP_FETCH())
x86emu_check_ip_access();)
fetched = (*sys_rdl) (((u32) M.x86.R_CS << 4) + (M.x86.R_IP));
fetched = (*sys_rdl)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP));
M.x86.R_IP += 4;
INC_DECODED_INST_LEN(4);
return fetched;
@ -290,13 +300,14 @@ Byte value read from the absolute memory location.
NOTE: Do not inline this function as (*sys_rdX) is already inline!
****************************************************************************/
u8 fetch_data_byte(uint offset)
u8 fetch_data_byte(
uint offset)
{
#ifdef DEBUG
if (CHECK_DATA_ACCESS())
x86emu_check_data_access((u16) get_data_segment(), offset);
x86emu_check_data_access((u16)get_data_segment(), offset);
#endif
return (*sys_rdb) ((get_data_segment() << 4) + offset);
return (*sys_rdb)((get_data_segment() << 4) + offset);
}
/****************************************************************************
@ -308,13 +319,14 @@ Word value read from the absolute memory location.
NOTE: Do not inline this function as (*sys_rdX) is already inline!
****************************************************************************/
u16 fetch_data_word(uint offset)
u16 fetch_data_word(
uint offset)
{
#ifdef DEBUG
if (CHECK_DATA_ACCESS())
x86emu_check_data_access((u16) get_data_segment(), offset);
x86emu_check_data_access((u16)get_data_segment(), offset);
#endif
return (*sys_rdw) ((get_data_segment() << 4) + offset);
return (*sys_rdw)((get_data_segment() << 4) + offset);
}
/****************************************************************************
@ -326,13 +338,14 @@ Long value read from the absolute memory location.
NOTE: Do not inline this function as (*sys_rdX) is already inline!
****************************************************************************/
u32 fetch_data_long(uint offset)
u32 fetch_data_long(
uint offset)
{
#ifdef DEBUG
if (CHECK_DATA_ACCESS())
x86emu_check_data_access((u16) get_data_segment(), offset);
x86emu_check_data_access((u16)get_data_segment(), offset);
#endif
return (*sys_rdl) ((get_data_segment() << 4) + offset);
return (*sys_rdl)((get_data_segment() << 4) + offset);
}
/****************************************************************************
@ -345,13 +358,15 @@ Byte value read from the absolute memory location.
NOTE: Do not inline this function as (*sys_rdX) is already inline!
****************************************************************************/
u8 fetch_data_byte_abs(uint segment, uint offset)
u8 fetch_data_byte_abs(
uint segment,
uint offset)
{
#ifdef DEBUG
if (CHECK_DATA_ACCESS())
x86emu_check_data_access(segment, offset);
#endif
return (*sys_rdb) (((u32) segment << 4) + offset);
return (*sys_rdb)(((u32)segment << 4) + offset);
}
/****************************************************************************
@ -364,13 +379,15 @@ Word value read from the absolute memory location.
NOTE: Do not inline this function as (*sys_rdX) is already inline!
****************************************************************************/
u16 fetch_data_word_abs(uint segment, uint offset)
u16 fetch_data_word_abs(
uint segment,
uint offset)
{
#ifdef DEBUG
if (CHECK_DATA_ACCESS())
x86emu_check_data_access(segment, offset);
#endif
return (*sys_rdw) (((u32) segment << 4) + offset);
return (*sys_rdw)(((u32)segment << 4) + offset);
}
/****************************************************************************
@ -383,13 +400,15 @@ Long value read from the absolute memory location.
NOTE: Do not inline this function as (*sys_rdX) is already inline!
****************************************************************************/
u32 fetch_data_long_abs(uint segment, uint offset)
u32 fetch_data_long_abs(
uint segment,
uint offset)
{
#ifdef DEBUG
if (CHECK_DATA_ACCESS())
x86emu_check_data_access(segment, offset);
#endif
return (*sys_rdl) (((u32) segment << 4) + offset);
return (*sys_rdl)(((u32)segment << 4) + offset);
}
/****************************************************************************
@ -403,13 +422,15 @@ the current 'default' segment, which may have been overridden.
NOTE: Do not inline this function as (*sys_wrX) is already inline!
****************************************************************************/
void store_data_byte(uint offset, u8 val)
void store_data_byte(
uint offset,
u8 val)
{
#ifdef DEBUG
if (CHECK_DATA_ACCESS())
x86emu_check_data_access((u16) get_data_segment(), offset);
x86emu_check_data_access((u16)get_data_segment(), offset);
#endif
(*sys_wrb) ((get_data_segment() << 4) + offset, val);
(*sys_wrb)((get_data_segment() << 4) + offset, val);
}
/****************************************************************************
@ -423,13 +444,15 @@ the current 'default' segment, which may have been overridden.
NOTE: Do not inline this function as (*sys_wrX) is already inline!
****************************************************************************/
void store_data_word(uint offset, u16 val)
void store_data_word(
uint offset,
u16 val)
{
#ifdef DEBUG
if (CHECK_DATA_ACCESS())
x86emu_check_data_access((u16) get_data_segment(), offset);
x86emu_check_data_access((u16)get_data_segment(), offset);
#endif
(*sys_wrw) ((get_data_segment() << 4) + offset, val);
(*sys_wrw)((get_data_segment() << 4) + offset, val);
}
/****************************************************************************
@ -443,13 +466,15 @@ the current 'default' segment, which may have been overridden.
NOTE: Do not inline this function as (*sys_wrX) is already inline!
****************************************************************************/
void store_data_long(uint offset, u32 val)
void store_data_long(
uint offset,
u32 val)
{
#ifdef DEBUG
if (CHECK_DATA_ACCESS())
x86emu_check_data_access((u16) get_data_segment(), offset);
x86emu_check_data_access((u16)get_data_segment(), offset);
#endif
(*sys_wrl) ((get_data_segment() << 4) + offset, val);
(*sys_wrl)((get_data_segment() << 4) + offset, val);
}
/****************************************************************************
@ -463,13 +488,16 @@ Writes a byte value to an absolute memory location.
NOTE: Do not inline this function as (*sys_wrX) is already inline!
****************************************************************************/
void store_data_byte_abs(uint segment, uint offset, u8 val)
void store_data_byte_abs(
uint segment,
uint offset,
u8 val)
{
#ifdef DEBUG
if (CHECK_DATA_ACCESS())
x86emu_check_data_access(segment, offset);
#endif
(*sys_wrb) (((u32) segment << 4) + offset, val);
(*sys_wrb)(((u32)segment << 4) + offset, val);
}
/****************************************************************************
@ -483,13 +511,16 @@ Writes a word value to an absolute memory location.
NOTE: Do not inline this function as (*sys_wrX) is already inline!
****************************************************************************/
void store_data_word_abs(uint segment, uint offset, u16 val)
void store_data_word_abs(
uint segment,
uint offset,
u16 val)
{
#ifdef DEBUG
if (CHECK_DATA_ACCESS())
x86emu_check_data_access(segment, offset);
#endif
(*sys_wrw) (((u32) segment << 4) + offset, val);
(*sys_wrw)(((u32)segment << 4) + offset, val);
}
/****************************************************************************
@ -503,13 +534,16 @@ Writes a long value to an absolute memory location.
NOTE: Do not inline this function as (*sys_wrX) is already inline!
****************************************************************************/
void store_data_long_abs(uint segment, uint offset, u32 val)
void store_data_long_abs(
uint segment,
uint offset,
u32 val)
{
#ifdef DEBUG
if (CHECK_DATA_ACCESS())
x86emu_check_data_access(segment, offset);
#endif
(*sys_wrl) (((u32) segment << 4) + offset, val);
(*sys_wrl)(((u32)segment << 4) + offset, val);
}
/****************************************************************************
@ -523,7 +557,8 @@ REMARKS:
Return a pointer to the register given by the R/RM field of the
modrm byte, for byte operands. Also enables the decoding of instructions.
****************************************************************************/
u8 *decode_rm_byte_register(int reg)
u8* decode_rm_byte_register(
int reg)
{
switch (reg) {
case 0:
@ -566,7 +601,8 @@ REMARKS:
Return a pointer to the register given by the R/RM field of the
modrm byte, for word operands. Also enables the decoding of instructions.
****************************************************************************/
u16 *decode_rm_word_register(int reg)
u16* decode_rm_word_register(
int reg)
{
switch (reg) {
case 0:
@ -609,7 +645,8 @@ REMARKS:
Return a pointer to the register given by the R/RM field of the
modrm byte, for dword operands. Also enables the decoding of instructions.
****************************************************************************/
u32 *decode_rm_long_register(int reg)
u32* decode_rm_long_register(
int reg)
{
switch (reg) {
case 0:
@ -653,7 +690,8 @@ Return a pointer to the register given by the R/RM field of the
modrm byte, for word operands, modified from above for the weirdo
special case of segreg operands. Also enables the decoding of instructions.
****************************************************************************/
u16 *decode_rm_seg_register(int reg)
u16* decode_rm_seg_register(
int reg)
{
switch (reg) {
case 0:
@ -674,7 +712,6 @@ u16 *decode_rm_seg_register(int reg)
case 5:
DECODE_PRINTF("GS");
return &M.x86.R_GS;
case 6:
case 7:
DECODE_PRINTF("ILLEGAL SEGREG");
@ -684,6 +721,138 @@ u16 *decode_rm_seg_register(int reg)
return NULL; /* NOT REACHED OR REACHED ON ERROR */
}
/****************************************************************************
PARAMETERS:
scale - scale value of SIB byte
index - index value of SIB byte
RETURNS:
Value of scale * index
REMARKS:
Decodes scale/index of SIB byte and returns relevant offset part of
effective address.
****************************************************************************/
unsigned decode_sib_si(
int scale,
int index)
{
scale = 1 << scale;
if (scale > 1) {
DECODE_PRINTF2("[%d*", scale);
} else {
DECODE_PRINTF("[");
}
switch (index) {
case 0:
DECODE_PRINTF("EAX]");
return M.x86.R_EAX * index;
case 1:
DECODE_PRINTF("ECX]");
return M.x86.R_ECX * index;
case 2:
DECODE_PRINTF("EDX]");
return M.x86.R_EDX * index;
case 3:
DECODE_PRINTF("EBX]");
return M.x86.R_EBX * index;
case 4:
DECODE_PRINTF("0]");
return 0;
case 5:
DECODE_PRINTF("EBP]");
return M.x86.R_EBP * index;
case 6:
DECODE_PRINTF("ESI]");
return M.x86.R_ESI * index;
case 7:
DECODE_PRINTF("EDI]");
return M.x86.R_EDI * index;
}
HALT_SYS();
return 0; /* NOT REACHED OR REACHED ON ERROR */
}
/****************************************************************************
PARAMETERS:
mod - MOD value of preceding ModR/M byte
RETURNS:
Offset in memory for the address decoding
REMARKS:
Decodes SIB addressing byte and returns calculated effective address.
****************************************************************************/
unsigned decode_sib_address(
int mod)
{
int sib = fetch_byte_imm();
int ss = (sib >> 6) & 0x03;
int index = (sib >> 3) & 0x07;
int base = sib & 0x07;
int offset = 0;
int displacement;
switch (base) {
case 0:
DECODE_PRINTF("[EAX]");
offset = M.x86.R_EAX;
break;
case 1:
DECODE_PRINTF("[ECX]");
offset = M.x86.R_ECX;
break;
case 2:
DECODE_PRINTF("[EDX]");
offset = M.x86.R_EDX;
break;
case 3:
DECODE_PRINTF("[EBX]");
offset = M.x86.R_EBX;
break;
case 4:
DECODE_PRINTF("[ESP]");
offset = M.x86.R_ESP;
break;
case 5:
switch (mod) {
case 0:
displacement = (s32)fetch_long_imm();
DECODE_PRINTF2("[%d]", displacement);
offset = displacement;
break;
case 1:
displacement = (s8)fetch_byte_imm();
DECODE_PRINTF2("[%d][EBP]", displacement);
offset = M.x86.R_EBP + displacement;
break;
case 2:
displacement = (s32)fetch_long_imm();
DECODE_PRINTF2("[%d][EBP]", displacement);
offset = M.x86.R_EBP + displacement;
break;
default:
HALT_SYS();
}
DECODE_PRINTF("[EAX]");
offset = M.x86.R_EAX;
break;
case 6:
DECODE_PRINTF("[ESI]");
offset = M.x86.R_ESI;
break;
case 7:
DECODE_PRINTF("[EDI]");
offset = M.x86.R_EDI;
break;
default:
HALT_SYS();
}
offset += decode_sib_si(ss, index);
return offset;
}
/****************************************************************************
PARAMETERS:
rm - RM value to decode
@ -704,25 +873,56 @@ NOTE: The code which specifies the corresponding segment (ds vs ss)
if a SS access is needed, set this bit. Otherwise, DS access
occurs (unless any of the segment override bits are set).
****************************************************************************/
unsigned decode_rm00_address(int rm)
unsigned decode_rm00_address(
int rm)
{
unsigned offset;
if (M.x86.mode & SYSMODE_PREFIX_ADDR) {
/* 32-bit addressing */
switch (rm) {
case 0:
DECODE_PRINTF("[EAX]");
return M.x86.R_EAX;
case 1:
DECODE_PRINTF("[ECX]");
return M.x86.R_ECX;
case 2:
DECODE_PRINTF("[EDX]");
return M.x86.R_EDX;
case 3:
DECODE_PRINTF("[EBX]");
return M.x86.R_EBX;
case 4:
return decode_sib_address(0);
case 5:
offset = fetch_long_imm();
DECODE_PRINTF2("[%08x]", offset);
return offset;
case 6:
DECODE_PRINTF("[ESI]");
return M.x86.R_ESI;
case 7:
DECODE_PRINTF("[EDI]");
return M.x86.R_EDI;
}
} else {
/* 16-bit addressing */
switch (rm) {
case 0:
DECODE_PRINTF("[BX+SI]");
return M.x86.R_BX + M.x86.R_SI;
return (M.x86.R_BX + M.x86.R_SI) & 0xffff;
case 1:
DECODE_PRINTF("[BX+DI]");
return M.x86.R_BX + M.x86.R_DI;
return (M.x86.R_BX + M.x86.R_DI) & 0xffff;
case 2:
DECODE_PRINTF("[BP+SI]");
M.x86.mode |= SYSMODE_SEG_DS_SS;
return M.x86.R_BP + M.x86.R_SI;
return (M.x86.R_BP + M.x86.R_SI) & 0xffff;
case 3:
DECODE_PRINTF("[BP+DI]");
M.x86.mode |= SYSMODE_SEG_DS_SS;
return M.x86.R_BP + M.x86.R_DI;
return (M.x86.R_BP + M.x86.R_DI) & 0xffff;
case 4:
DECODE_PRINTF("[SI]");
return M.x86.R_SI;
@ -737,6 +937,7 @@ unsigned decode_rm00_address(int rm)
DECODE_PRINTF("[BX]");
return M.x86.R_BX;
}
}
HALT_SYS();
return 0;
}
@ -752,37 +953,79 @@ REMARKS:
Return the offset given by mod=01 addressing. Also enables the
decoding of instructions.
****************************************************************************/
unsigned decode_rm01_address(int rm)
unsigned decode_rm01_address(
int rm)
{
int displacement = (s8) fetch_byte_imm();
int displacement;
if (M.x86.mode & SYSMODE_PREFIX_ADDR) {
/* 32-bit addressing */
if (rm != 4)
displacement = (s8)fetch_byte_imm();
else
displacement = 0;
switch (rm) {
case 0:
DECODE_PRINTF2("%d[EAX]", displacement);
return M.x86.R_EAX + displacement;
case 1:
DECODE_PRINTF2("%d[ECX]", displacement);
return M.x86.R_ECX + displacement;
case 2:
DECODE_PRINTF2("%d[EDX]", displacement);
return M.x86.R_EDX + displacement;
case 3:
DECODE_PRINTF2("%d[EBX]", displacement);
return M.x86.R_EBX + displacement;
case 4: {
int offset = decode_sib_address(1);
displacement = (s8)fetch_byte_imm();
DECODE_PRINTF2("[%d]", displacement);
return offset + displacement;
}
case 5:
DECODE_PRINTF2("%d[EBP]", displacement);
return M.x86.R_EBP + displacement;
case 6:
DECODE_PRINTF2("%d[ESI]", displacement);
return M.x86.R_ESI + displacement;
case 7:
DECODE_PRINTF2("%d[EDI]", displacement);
return M.x86.R_EDI + displacement;
}
} else {
/* 16-bit addressing */
displacement = (s8)fetch_byte_imm();
switch (rm) {
case 0:
DECODE_PRINTF2("%d[BX+SI]", displacement);
return M.x86.R_BX + M.x86.R_SI + displacement;
return (M.x86.R_BX + M.x86.R_SI + displacement) & 0xffff;
case 1:
DECODE_PRINTF2("%d[BX+DI]", displacement);
return M.x86.R_BX + M.x86.R_DI + displacement;
return (M.x86.R_BX + M.x86.R_DI + displacement) & 0xffff;
case 2:
DECODE_PRINTF2("%d[BP+SI]", displacement);
M.x86.mode |= SYSMODE_SEG_DS_SS;
return M.x86.R_BP + M.x86.R_SI + displacement;
return (M.x86.R_BP + M.x86.R_SI + displacement) & 0xffff;
case 3:
DECODE_PRINTF2("%d[BP+DI]", displacement);
M.x86.mode |= SYSMODE_SEG_DS_SS;
return M.x86.R_BP + M.x86.R_DI + displacement;
return (M.x86.R_BP + M.x86.R_DI + displacement) & 0xffff;
case 4:
DECODE_PRINTF2("%d[SI]", displacement);
return M.x86.R_SI + displacement;
return (M.x86.R_SI + displacement) & 0xffff;
case 5:
DECODE_PRINTF2("%d[DI]", displacement);
return M.x86.R_DI + displacement;
return (M.x86.R_DI + displacement) & 0xffff;
case 6:
DECODE_PRINTF2("%d[BP]", displacement);
M.x86.mode |= SYSMODE_SEG_DS_SS;
return M.x86.R_BP + displacement;
return (M.x86.R_BP + displacement) & 0xffff;
case 7:
DECODE_PRINTF2("%d[BX]", displacement);
return M.x86.R_BX + displacement;
return (M.x86.R_BX + displacement) & 0xffff;
}
}
HALT_SYS();
return 0; /* SHOULD NOT HAPPEN */
@ -799,39 +1042,107 @@ REMARKS:
Return the offset given by mod=10 addressing. Also enables the
decoding of instructions.
****************************************************************************/
unsigned decode_rm10_address(int rm)
unsigned decode_rm10_address(
int rm)
{
unsigned displacement = (u16) fetch_word_imm();
if (M.x86.mode & SYSMODE_PREFIX_ADDR) {
int displacement;
/* 32-bit addressing */
if (rm != 4)
displacement = (s32)fetch_long_imm();
else
displacement = 0;
switch (rm) {
case 0:
DECODE_PRINTF2("%04x[BX+SI]", displacement);
return M.x86.R_BX + M.x86.R_SI + displacement;
DECODE_PRINTF2("%d[EAX]", displacement);
return M.x86.R_EAX + displacement;
case 1:
DECODE_PRINTF2("%04x[BX+DI]", displacement);
return M.x86.R_BX + M.x86.R_DI + displacement;
DECODE_PRINTF2("%d[ECX]", displacement);
return M.x86.R_ECX + displacement;
case 2:
DECODE_PRINTF2("%04x[BP+SI]", displacement);
M.x86.mode |= SYSMODE_SEG_DS_SS;
return M.x86.R_BP + M.x86.R_SI + displacement;
DECODE_PRINTF2("%d[EDX]", displacement);
return M.x86.R_EDX + displacement;
case 3:
DECODE_PRINTF2("%04x[BP+DI]", displacement);
M.x86.mode |= SYSMODE_SEG_DS_SS;
return M.x86.R_BP + M.x86.R_DI + displacement;
case 4:
DECODE_PRINTF2("%04x[SI]", displacement);
return M.x86.R_SI + displacement;
DECODE_PRINTF2("%d[EBX]", displacement);
return M.x86.R_EBX + displacement;
case 4: {
int offset = decode_sib_address(2);
displacement = (s32)fetch_long_imm();
DECODE_PRINTF2("[%d]", displacement);
return offset + displacement;
}
case 5:
DECODE_PRINTF2("%04x[DI]", displacement);
return M.x86.R_DI + displacement;
DECODE_PRINTF2("%d[EBP]", displacement);
return M.x86.R_EBP + displacement;
case 6:
DECODE_PRINTF2("%04x[BP]", displacement);
M.x86.mode |= SYSMODE_SEG_DS_SS;
return M.x86.R_BP + displacement;
DECODE_PRINTF2("%d[ESI]", displacement);
return M.x86.R_ESI + displacement;
case 7:
DECODE_PRINTF2("%04x[BX]", displacement);
return M.x86.R_BX + displacement;
DECODE_PRINTF2("%d[EDI]", displacement);
return M.x86.R_EDI + displacement;
}
} else {
int displacement = (s16)fetch_word_imm();
/* 16-bit addressing */
switch (rm) {
case 0:
DECODE_PRINTF2("%d[BX+SI]", displacement);
return (M.x86.R_BX + M.x86.R_SI + displacement) & 0xffff;
case 1:
DECODE_PRINTF2("%d[BX+DI]", displacement);
return (M.x86.R_BX + M.x86.R_DI + displacement) & 0xffff;
case 2:
DECODE_PRINTF2("%d[BP+SI]", displacement);
M.x86.mode |= SYSMODE_SEG_DS_SS;
return (M.x86.R_BP + M.x86.R_SI + displacement) & 0xffff;
case 3:
DECODE_PRINTF2("%d[BP+DI]", displacement);
M.x86.mode |= SYSMODE_SEG_DS_SS;
return (M.x86.R_BP + M.x86.R_DI + displacement) & 0xffff;
case 4:
DECODE_PRINTF2("%d[SI]", displacement);
return (M.x86.R_SI + displacement) & 0xffff;
case 5:
DECODE_PRINTF2("%d[DI]", displacement);
return (M.x86.R_DI + displacement) & 0xffff;
case 6:
DECODE_PRINTF2("%d[BP]", displacement);
M.x86.mode |= SYSMODE_SEG_DS_SS;
return (M.x86.R_BP + displacement) & 0xffff;
case 7:
DECODE_PRINTF2("%d[BX]", displacement);
return (M.x86.R_BX + displacement) & 0xffff;
}
}
HALT_SYS();
return 0;
/*NOTREACHED */
return 0; /* SHOULD NOT HAPPEN */
}
/****************************************************************************
PARAMETERS:
mod - modifier
rm - RM value to decode
RETURNS:
Offset in memory for the address decoding, multiplexing calls to
the decode_rmXX_address functions
REMARKS:
Return the offset given by "mod" addressing.
****************************************************************************/
unsigned decode_rmXX_address(int mod, int rm)
{
if(mod == 0)
return decode_rm00_address(rm);
if(mod == 1)
return decode_rm01_address(rm);
return decode_rm10_address(rm);
}

View File

@ -2,7 +2,7 @@
*
* Realmode X86 Emulator Library
*
* Copyright (C) 1996-1999 SciTech Software, Inc.
* Copyright (C) 1991-2004 SciTech Software, Inc.
* Copyright (C) David Mosberger-Tang
* Copyright (C) 1999 Egbert Eich
*
@ -121,7 +121,7 @@ void x86emuOp_esc_coprocess_d9(u8 X86EMU_UNUSED(op1))
DECODE_PRINTF("\n");
break;
case 3: /* register to register */
stkelem = (u8) rl;
stkelem = (u8)rl;
if (rh < 4) {
DECODE_PRINTF2("ST(%d)\n", stkelem);
} else {
@ -342,7 +342,7 @@ void x86emuOp_esc_coprocess_da(u8 X86EMU_UNUSED(op1))
DECODE_PRINTF("\n");
break;
case 3: /* register to register */
stkelem = (u8) rl;
stkelem = (u8)rl;
DECODE_PRINTF2("\tST(%d),ST\n", stkelem);
break;
}
@ -550,7 +550,7 @@ void x86emuOp_esc_coprocess_dc(u8 X86EMU_UNUSED(op1))
DECODE_PRINTF("\n");
break;
case 3: /* register to register */
stkelem = (u8) rl;
stkelem = (u8)rl;
DECODE_PRINTF2("\tST(%d),ST\n", stkelem);
break;
}
@ -660,7 +660,7 @@ void x86emuOp_esc_coprocess_dd(u8 X86EMU_UNUSED(op1))
DECODE_PRINTF("\n");
break;
case 3: /* register to register */
stkelem = (u8) rl;
stkelem = (u8)rl;
DECODE_PRINTF2("\tST(%d),ST\n", stkelem);
break;
}
@ -720,7 +720,8 @@ void x86emuOp_esc_coprocess_dd(u8 X86EMU_UNUSED(op1))
#ifdef DEBUG
static char *x86emu_fpu_op_de_tab[] = {
static char *x86emu_fpu_op_de_tab[] =
{
"FIADD\tWORD PTR ", "FIMUL\tWORD PTR ", "FICOM\tWORD PTR ",
"FICOMP\tWORD PTR ",
"FISUB\tWORD PTR ", "FISUBR\tWORD PTR ", "FIDIV\tWORD PTR ",
@ -766,7 +767,7 @@ void x86emuOp_esc_coprocess_de(u8 X86EMU_UNUSED(op1))
DECODE_PRINTF("\n");
break;
case 3: /* register to register */
stkelem = (u8) rl;
stkelem = (u8)rl;
DECODE_PRINTF2("\tST(%d),ST\n", stkelem);
break;
}
@ -885,7 +886,7 @@ void x86emuOp_esc_coprocess_df(u8 X86EMU_UNUSED(op1))
DECODE_PRINTF("\n");
break;
case 3: /* register to register */
stkelem = (u8) rl;
stkelem = (u8)rl;
DECODE_PRINTF2("\tST(%d)\n", stkelem);
break;
}

View File

@ -2,7 +2,7 @@
#
# Realmode X86 Emulator Library
#
# Copyright (C) 1996-1999 SciTech Software, Inc.
# Copyright (C) 1991-2004 SciTech Software, Inc.
#
# ========================================================================
#

View File

@ -31,9 +31,9 @@
#############################################################################
TARGETLIB = libx86emu.a
TARGETDEBUGLIB =libx86emud.a
OBJS=\
debug.o \
decode.o \
fpu.o \
ops.o \
@ -41,20 +41,40 @@ ops2.o \
prim_ops.o \
sys.o
DEBUGOBJS=debug.d \
decode.d \
fpu.d \
ops.d \
ops2.d \
prim_ops.d \
sys.d
.SUFFIXES: .d
all: $(TARGETLIB) $(TARGETDEBUGLIB)
$(TARGETLIB): $(OBJS)
ar rv $(TARGETLIB) $(OBJS)
INCS = -I. -Ix86emu -I../../include
CFLAGS = -D__DRIVER__ -DFORCE_POST -D_CEXPORT= -DNO_LONG_LONG -DDEBUG
$(TARGETDEBUGLIB): $(DEBUGOBJS)
ar rv $(TARGETDEBUGLIB) $(DEBUGOBJS)
INCS = -I. -I../../include -I../../include/x86emu
#CFLAGS = -D__DRIVER__ -DFORCE_POST -D_CEXPORT= -DNO_LONG_LONG
CFLAGS = -D__DRIVER__ -DFORCE_POST
CDEBUGFLAGS = -DDEBUG
.c.o:
gcc -g -O -Wall -c $(CFLAGS) $(INCS) $*.c
gcc -g -Os -Wall -c $(CFLAGS) $(INCS) $*.c
.c.d:
gcc -g -O -Wall -c -o$*.d $(CFLAGS) $(CDEBUGFLAGS) $(INCS) $*.c
.cpp.o:
gcc -c $(CFLAGS) $(INCS) $*.cpp
clean:
rm -f *.a *.o
rm -f *.a *.o *.d
validate: validate.o libx86emu.a
gcc -o validate validate.o -lx86emu -L.
validate: validate.c libx86emu.a x86emu/prim_asm.h
gcc $(CFLAGS) $(INCS) -Wall -O2 -o validate validate.c -lx86emu -L.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -198,7 +198,7 @@ u8 *mem_ptr(u32 addr, int size)
retaddr = (u8 *) (M.abseg + addr);
//printk("retaddr now 0x%p\n", retaddr);
} else if (addr < 0x200) {
//printk("updating int vector 0x%x\n", addr >> 2);
printk("updating int vector 0x%x\n", addr >> 2);
retaddr = (u8 *) (M.mem_base + addr);
} else {
retaddr = (u8 *) (M.mem_base + addr);

View File

@ -2,7 +2,7 @@
*
* Realmode X86 Emulator Library
*
* Copyright (C) 1996-1999 SciTech Software, Inc.
* Copyright (C) 1991-2004 SciTech Software, Inc.
* Copyright (C) David Mosberger-Tang
* Copyright (C) 1999 Egbert Eich
*
@ -47,19 +47,27 @@
#include <stdarg.h>
#include "x86emu.h"
#include "x86emu/prim_asm.h"
#include "x86emu/prim_ops.h"
/*-------------------------- Implementation -------------------------------*/
#define true 1
#define false 0
u32 cur_flags_mask = 0;
int flags_are_different(u32 flags1, u32 flags2)
{
return (flags1&cur_flags_mask) != (flags2&cur_flags_mask);
}
#define ALL_FLAGS (F_CF | F_PF | F_AF | F_ZF | F_SF | F_OF)
#define VAL_START_BINARY(parm_type,res_type,dmax,smax,dincr,sincr) \
{ \
parm_type d,s; \
res_type r,r_asm; \
ulong flags,inflags; \
u32 flags,inflags; \
int f,failed = false; \
char buf1[80],buf2[80]; \
for (d = 0; d < dmax; d += dincr) { \
@ -70,7 +78,7 @@
#define VAL_TEST_BINARY(name) \
r_asm = name##_asm(&flags,d,s); \
r = name(d,s); \
if (r != r_asm || M.x86.R_EFLG != flags) \
if (r != r_asm || flags_are_different(M.x86.R_EFLG, flags)) \
failed = true; \
if (failed || trace) {
@ -78,7 +86,7 @@
name##_asm(&flags,d,s); \
name(d,s); \
r = r_asm = 0; \
if (M.x86.R_EFLG != flags) \
if (flags_are_different(M.x86.R_EFLG, flags)) \
failed = true; \
if (failed || trace) {
@ -202,7 +210,7 @@
#define VAL_TEST_TERNARY(name) \
r_asm = name##_asm(&flags,d,s,shift); \
r = name(d,s,shift); \
if (r != r_asm || M.x86.R_EFLG != flags) \
if (r != r_asm || flags_are_different(M.x86.R_EFLG, flags)) \
failed = true; \
if (failed || trace) {
@ -268,7 +276,7 @@
#define VAL_TEST_UNARY(name) \
r_asm = name##_asm(&flags,d); \
r = name(d); \
if (r != r_asm || M.x86.R_EFLG != flags) { \
if (r != r_asm || flags_are_different(M.x86.R_EFLG, flags)) { \
failed = true;
#define VAL_FAIL_BYTE_UNARY(name) \
@ -349,7 +357,7 @@
M.x86.R_AL = d; \
name(s); \
r = M.x86.R_AX; \
if (r != r_asm || M.x86.R_EFLG != flags) \
if (r != r_asm || flags_are_different(M.x86.R_EFLG, flags)) \
failed = true; \
if (failed || trace) { \
if (failed) \
@ -391,7 +399,7 @@
name(s); \
r_lo = M.x86.R_AX; \
r_hi = M.x86.R_DX; \
if (r_lo != r_asm_lo || r_hi != r_asm_hi || M.x86.R_EFLG != flags)\
if (r_lo != r_asm_lo || r_hi != r_asm_hi || flags_are_different(M.x86.R_EFLG, flags))\
failed = true; \
if (failed || trace) { \
if (failed) \
@ -433,7 +441,7 @@
name(s); \
r_lo = M.x86.R_EAX; \
r_hi = M.x86.R_EDX; \
if (r_lo != r_asm_lo || r_hi != r_asm_hi || M.x86.R_EFLG != flags)\
if (r_lo != r_asm_lo || r_hi != r_asm_hi || flags_are_different(M.x86.R_EFLG, flags))\
failed = true; \
if (failed || trace) { \
if (failed) \
@ -477,7 +485,7 @@
if (M.x86.intr & INTR_SYNCH) \
continue; \
name##_asm(&flags,&r_asm_quot,&r_asm_rem,d,s); \
if (r_quot != r_asm_quot || r_rem != r_asm_rem || M.x86.R_EFLG != flags) \
if (r_quot != r_asm_quot || r_rem != r_asm_rem || flags_are_different(M.x86.R_EFLG, flags)) \
failed = true; \
if (failed || trace) { \
if (failed) \
@ -522,7 +530,7 @@
if (M.x86.intr & INTR_SYNCH) \
continue; \
name##_asm(&flags,&r_asm_quot,&r_asm_rem,d & 0xFFFF,d >> 16,s);\
if (r_quot != r_asm_quot || r_rem != r_asm_rem || M.x86.R_EFLG != flags) \
if (r_quot != r_asm_quot || r_rem != r_asm_rem || flags_are_different(M.x86.R_EFLG, flags)) \
failed = true; \
if (failed || trace) { \
if (failed) \
@ -567,7 +575,7 @@
if (M.x86.intr & INTR_SYNCH) \
continue; \
name##_asm(&flags,&r_asm_quot,&r_asm_rem,d,0,s); \
if (r_quot != r_asm_quot || r_rem != r_asm_rem || M.x86.R_EFLG != flags) \
if (r_quot != r_asm_quot || r_rem != r_asm_rem || flags_are_different(M.x86.R_EFLG, flags)) \
failed = true; \
if (failed || trace) { \
if (failed) \
@ -600,49 +608,49 @@ void printk(const char *fmt, ...)
va_end(argptr);
}
char *print_flags(char *buf, ulong flags)
char * print_flags(char *buf,ulong flags)
{
char *separator = "";
buf[0] = 0;
if (flags & F_CF) {
strcat(buf, separator);
strcat(buf, "CF");
strcat(buf,separator);
strcat(buf,"CF");
separator = ",";
}
if (flags & F_PF) {
strcat(buf, separator);
strcat(buf, "PF");
strcat(buf,separator);
strcat(buf,"PF");
separator = ",";
}
if (flags & F_AF) {
strcat(buf, separator);
strcat(buf, "AF");
strcat(buf,separator);
strcat(buf,"AF");
separator = ",";
}
if (flags & F_ZF) {
strcat(buf, separator);
strcat(buf, "ZF");
strcat(buf,separator);
strcat(buf,"ZF");
separator = ",";
}
if (flags & F_SF) {
strcat(buf, separator);
strcat(buf, "SF");
strcat(buf,separator);
strcat(buf,"SF");
separator = ",";
}
if (flags & F_OF) {
strcat(buf, separator);
strcat(buf, "OF");
strcat(buf,separator);
strcat(buf,"OF");
separator = ",";
}
if (separator[0] == 0)
strcpy(buf, "None");
strcpy(buf,"None");
return buf;
}
int main(int argc)
int main(int argc, char *argv[])
{
ulong def_flags;
u32 def_flags;
int trace = false;
if (argc > 1)
@ -650,12 +658,15 @@ int main(int argc)
memset(&M, 0, sizeof(M));
def_flags = get_flags_asm() & ~ALL_FLAGS;
cur_flags_mask = F_AF | F_CF;
VAL_WORD_UNARY(aaa_word);
VAL_WORD_UNARY(aas_word);
cur_flags_mask = F_SF | F_ZF | F_PF;
VAL_WORD_UNARY(aad_word);
VAL_WORD_UNARY(aam_word);
cur_flags_mask = ALL_FLAGS;
VAL_BYTE_BYTE_BINARY(adc_byte);
VAL_WORD_WORD_BINARY(adc_word);
VAL_LONG_LONG_BINARY(adc_long);
@ -664,17 +675,21 @@ int main(int argc)
VAL_WORD_WORD_BINARY(add_word);
VAL_LONG_LONG_BINARY(add_long);
cur_flags_mask = ALL_FLAGS & (~F_AF);
VAL_BYTE_BYTE_BINARY(and_byte);
VAL_WORD_WORD_BINARY(and_word);
VAL_LONG_LONG_BINARY(and_long);
cur_flags_mask = ALL_FLAGS;
VAL_BYTE_BYTE_BINARY(cmp_byte);
VAL_WORD_WORD_BINARY(cmp_word);
VAL_LONG_LONG_BINARY(cmp_long);
cur_flags_mask = ALL_FLAGS & (~F_OF);
VAL_BYTE_UNARY(daa_byte);
VAL_BYTE_UNARY(das_byte); // Fails for 0x9A (out of range anyway)
cur_flags_mask = ALL_FLAGS;
VAL_BYTE_UNARY(dec_byte);
VAL_WORD_UNARY(dec_word);
VAL_LONG_UNARY(dec_long);
@ -683,10 +698,12 @@ int main(int argc)
VAL_WORD_UNARY(inc_word);
VAL_LONG_UNARY(inc_long);
cur_flags_mask = ALL_FLAGS & (~F_AF);
VAL_BYTE_BYTE_BINARY(or_byte);
VAL_WORD_WORD_BINARY(or_word);
VAL_LONG_LONG_BINARY(or_long);
cur_flags_mask = ALL_FLAGS;
VAL_BYTE_UNARY(neg_byte);
VAL_WORD_UNARY(neg_word);
VAL_LONG_UNARY(neg_long);
@ -695,6 +712,7 @@ int main(int argc)
VAL_WORD_UNARY(not_word);
VAL_LONG_UNARY(not_long);
cur_flags_mask = ALL_FLAGS & (~F_OF);
VAL_BYTE_ROTATE(rcl_byte);
VAL_WORD_ROTATE(rcl_word);
VAL_LONG_ROTATE(rcl_long);
@ -711,6 +729,7 @@ int main(int argc)
VAL_WORD_ROTATE(ror_word);
VAL_LONG_ROTATE(ror_long);
cur_flags_mask = ALL_FLAGS & (~(F_AF | F_OF));
VAL_BYTE_ROTATE(shl_byte);
VAL_WORD_ROTATE(shl_word);
VAL_LONG_ROTATE(shl_long);
@ -723,12 +742,14 @@ int main(int argc)
VAL_WORD_ROTATE(sar_word);
VAL_LONG_ROTATE(sar_long);
cur_flags_mask = ALL_FLAGS & (~(F_AF | F_OF));
VAL_WORD_ROTATE_DBL(shld_word);
VAL_LONG_ROTATE_DBL(shld_long);
VAL_WORD_ROTATE_DBL(shrd_word);
VAL_LONG_ROTATE_DBL(shrd_long);
cur_flags_mask = ALL_FLAGS;
VAL_BYTE_BYTE_BINARY(sbb_byte);
VAL_WORD_WORD_BINARY(sbb_word);
VAL_LONG_LONG_BINARY(sbb_long);
@ -737,6 +758,7 @@ int main(int argc)
VAL_WORD_WORD_BINARY(sub_word);
VAL_LONG_LONG_BINARY(sub_long);
cur_flags_mask = ALL_FLAGS & (~F_AF);
VAL_BYTE_BYTE_BINARY(xor_byte);
VAL_WORD_WORD_BINARY(xor_word);
VAL_LONG_LONG_BINARY(xor_long);
@ -745,6 +767,7 @@ int main(int argc)
VAL_VOID_WORD_BINARY(test_word);
VAL_VOID_LONG_BINARY(test_long);
cur_flags_mask = F_CF | F_OF;
VAL_BYTE_MUL(imul_byte);
VAL_WORD_MUL(imul_word);
VAL_LONG_MUL(imul_long);
@ -753,6 +776,7 @@ int main(int argc)
VAL_WORD_MUL(mul_word);
VAL_LONG_MUL(mul_long);
cur_flags_mask = 0;
VAL_BYTE_DIV(idiv_byte);
VAL_WORD_DIV(idiv_word);
VAL_LONG_DIV(idiv_long);

View File

@ -2,7 +2,7 @@
*
* Realmode X86 Emulator Library
*
* Copyright (C) 1996-1999 SciTech Software, Inc.
* Copyright (C) 1991-2004 SciTech Software, Inc.
* Copyright (C) David Mosberger-Tang
* Copyright (C) 1999 Egbert Eich
*
@ -35,7 +35,6 @@
* Description: Header file for debug definitions.
*
****************************************************************************/
/* $XFree86: xc/extras/x86emu/src/x86emu/x86emu/debug.h,v 1.4 2000/11/21 23:10:27 tsi Exp $ */
#ifndef __X86EMU_DEBUG_H
#define __X86EMU_DEBUG_H
@ -69,7 +68,7 @@
# define DEBUG_DISASSEMBLE() (M.x86.debug & DEBUG_DISASSEMBLE_F)
# define DEBUG_BREAK() (M.x86.debug & DEBUG_BREAK_F)
# define DEBUG_SVC() (M.x86.debug & DEBUG_SVC_F)
# define DEBUG_SAVE_IP_CS() (M.x86.debug & DEBUG_SAVE_IP_CS_F)
# define DEBUG_SAVE_IP_CS() (M.x86.debug & DEBUG_SAVE_CS_IP)
# define DEBUG_FS() (M.x86.debug & DEBUG_FS_F)
# define DEBUG_PROC() (M.x86.debug & DEBUG_PROC_F)

View File

@ -2,7 +2,7 @@
*
* Realmode X86 Emulator Library
*
* Copyright (C) 1996-1999 SciTech Software, Inc.
* Copyright (C) 1991-2004 SciTech Software, Inc.
* Copyright (C) David Mosberger-Tang
* Copyright (C) 1999 Egbert Eich
*
@ -79,6 +79,7 @@ u16* decode_rm_seg_register(int reg);
unsigned decode_rm00_address(int rm);
unsigned decode_rm01_address(int rm);
unsigned decode_rm10_address(int rm);
unsigned decode_rmXX_address(int mod, int rm);
#ifdef __cplusplus
} /* End of "C" linkage for C++ */

View File

@ -2,7 +2,7 @@
*
* Realmode X86 Emulator Library
*
* Copyright (C) 1996-1999 SciTech Software, Inc.
* Copyright (C) 1991-2004 SciTech Software, Inc.
* Copyright (C) David Mosberger-Tang
* Copyright (C) 1999 Egbert Eich
*

View File

@ -2,7 +2,7 @@
*
* Realmode X86 Emulator Library
*
* Copyright (C) 1996-1999 SciTech Software, Inc.
* Copyright (C) 1991-2004 SciTech Software, Inc.
* Copyright (C) David Mosberger-Tang
* Copyright (C) 1999 Egbert Eich
*

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
*
* Realmode X86 Emulator Library
*
* Copyright (C) 1996-1999 SciTech Software, Inc.
* Copyright (C) 1991-2004 SciTech Software, Inc.
* Copyright (C) David Mosberger-Tang
* Copyright (C) 1999 Egbert Eich
*
@ -39,8 +39,6 @@
#ifndef __X86EMU_PRIM_OPS_H
#define __X86EMU_PRIM_OPS_H
#include "x86emu/prim_asm.h"
#ifdef __cplusplus
extern "C" { /* Use "C" linkage when in C++ mode */
#endif
@ -136,96 +134,9 @@ void push_long (u32 w);
u16 pop_word (void);
u32 pop_long (void);
#if defined(__HAVE_INLINE_ASSEMBLER__) && !defined(PRIM_OPS_NO_REDEFINE_ASM)
#define aaa_word(d) aaa_word_asm(&M.x86.R_EFLG,d)
#define aas_word(d) aas_word_asm(&M.x86.R_EFLG,d)
#define aad_word(d) aad_word_asm(&M.x86.R_EFLG,d)
#define aam_word(d) aam_word_asm(&M.x86.R_EFLG,d)
#define adc_byte(d,s) adc_byte_asm(&M.x86.R_EFLG,d,s)
#define adc_word(d,s) adc_word_asm(&M.x86.R_EFLG,d,s)
#define adc_long(d,s) adc_long_asm(&M.x86.R_EFLG,d,s)
#define add_byte(d,s) add_byte_asm(&M.x86.R_EFLG,d,s)
#define add_word(d,s) add_word_asm(&M.x86.R_EFLG,d,s)
#define add_long(d,s) add_long_asm(&M.x86.R_EFLG,d,s)
#define and_byte(d,s) and_byte_asm(&M.x86.R_EFLG,d,s)
#define and_word(d,s) and_word_asm(&M.x86.R_EFLG,d,s)
#define and_long(d,s) and_long_asm(&M.x86.R_EFLG,d,s)
#define cmp_byte(d,s) cmp_byte_asm(&M.x86.R_EFLG,d,s)
#define cmp_word(d,s) cmp_word_asm(&M.x86.R_EFLG,d,s)
#define cmp_long(d,s) cmp_long_asm(&M.x86.R_EFLG,d,s)
#define daa_byte(d) daa_byte_asm(&M.x86.R_EFLG,d)
#define das_byte(d) das_byte_asm(&M.x86.R_EFLG,d)
#define dec_byte(d) dec_byte_asm(&M.x86.R_EFLG,d)
#define dec_word(d) dec_word_asm(&M.x86.R_EFLG,d)
#define dec_long(d) dec_long_asm(&M.x86.R_EFLG,d)
#define inc_byte(d) inc_byte_asm(&M.x86.R_EFLG,d)
#define inc_word(d) inc_word_asm(&M.x86.R_EFLG,d)
#define inc_long(d) inc_long_asm(&M.x86.R_EFLG,d)
#define or_byte(d,s) or_byte_asm(&M.x86.R_EFLG,d,s)
#define or_word(d,s) or_word_asm(&M.x86.R_EFLG,d,s)
#define or_long(d,s) or_long_asm(&M.x86.R_EFLG,d,s)
#define neg_byte(s) neg_byte_asm(&M.x86.R_EFLG,s)
#define neg_word(s) neg_word_asm(&M.x86.R_EFLG,s)
#define neg_long(s) neg_long_asm(&M.x86.R_EFLG,s)
#define not_byte(s) not_byte_asm(&M.x86.R_EFLG,s)
#define not_word(s) not_word_asm(&M.x86.R_EFLG,s)
#define not_long(s) not_long_asm(&M.x86.R_EFLG,s)
#define rcl_byte(d,s) rcl_byte_asm(&M.x86.R_EFLG,d,s)
#define rcl_word(d,s) rcl_word_asm(&M.x86.R_EFLG,d,s)
#define rcl_long(d,s) rcl_long_asm(&M.x86.R_EFLG,d,s)
#define rcr_byte(d,s) rcr_byte_asm(&M.x86.R_EFLG,d,s)
#define rcr_word(d,s) rcr_word_asm(&M.x86.R_EFLG,d,s)
#define rcr_long(d,s) rcr_long_asm(&M.x86.R_EFLG,d,s)
#define rol_byte(d,s) rol_byte_asm(&M.x86.R_EFLG,d,s)
#define rol_word(d,s) rol_word_asm(&M.x86.R_EFLG,d,s)
#define rol_long(d,s) rol_long_asm(&M.x86.R_EFLG,d,s)
#define ror_byte(d,s) ror_byte_asm(&M.x86.R_EFLG,d,s)
#define ror_word(d,s) ror_word_asm(&M.x86.R_EFLG,d,s)
#define ror_long(d,s) ror_long_asm(&M.x86.R_EFLG,d,s)
#define shl_byte(d,s) shl_byte_asm(&M.x86.R_EFLG,d,s)
#define shl_word(d,s) shl_word_asm(&M.x86.R_EFLG,d,s)
#define shl_long(d,s) shl_long_asm(&M.x86.R_EFLG,d,s)
#define shr_byte(d,s) shr_byte_asm(&M.x86.R_EFLG,d,s)
#define shr_word(d,s) shr_word_asm(&M.x86.R_EFLG,d,s)
#define shr_long(d,s) shr_long_asm(&M.x86.R_EFLG,d,s)
#define sar_byte(d,s) sar_byte_asm(&M.x86.R_EFLG,d,s)
#define sar_word(d,s) sar_word_asm(&M.x86.R_EFLG,d,s)
#define sar_long(d,s) sar_long_asm(&M.x86.R_EFLG,d,s)
#define shld_word(d,fill,s) shld_word_asm(&M.x86.R_EFLG,d,fill,s)
#define shld_long(d,fill,s) shld_long_asm(&M.x86.R_EFLG,d,fill,s)
#define shrd_word(d,fill,s) shrd_word_asm(&M.x86.R_EFLG,d,fill,s)
#define shrd_long(d,fill,s) shrd_long_asm(&M.x86.R_EFLG,d,fill,s)
#define sbb_byte(d,s) sbb_byte_asm(&M.x86.R_EFLG,d,s)
#define sbb_word(d,s) sbb_word_asm(&M.x86.R_EFLG,d,s)
#define sbb_long(d,s) sbb_long_asm(&M.x86.R_EFLG,d,s)
#define sub_byte(d,s) sub_byte_asm(&M.x86.R_EFLG,d,s)
#define sub_word(d,s) sub_word_asm(&M.x86.R_EFLG,d,s)
#define sub_long(d,s) sub_long_asm(&M.x86.R_EFLG,d,s)
#define test_byte(d,s) test_byte_asm(&M.x86.R_EFLG,d,s)
#define test_word(d,s) test_word_asm(&M.x86.R_EFLG,d,s)
#define test_long(d,s) test_long_asm(&M.x86.R_EFLG,d,s)
#define xor_byte(d,s) xor_byte_asm(&M.x86.R_EFLG,d,s)
#define xor_word(d,s) xor_word_asm(&M.x86.R_EFLG,d,s)
#define xor_long(d,s) xor_long_asm(&M.x86.R_EFLG,d,s)
#define imul_byte(s) imul_byte_asm(&M.x86.R_EFLG,&M.x86.R_AX,M.x86.R_AL,s)
#define imul_word(s) imul_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,s)
#define imul_long(s) imul_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,s)
#define imul_long_direct(res_lo,res_hi,d,s) imul_long_asm(&M.x86.R_EFLG,res_lo,res_hi,d,s)
#define mul_byte(s) mul_byte_asm(&M.x86.R_EFLG,&M.x86.R_AX,M.x86.R_AL,s)
#define mul_word(s) mul_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,s)
#define mul_long(s) mul_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,s)
#define idiv_byte(s) idiv_byte_asm(&M.x86.R_EFLG,&M.x86.R_AL,&M.x86.R_AH,M.x86.R_AX,s)
#define idiv_word(s) idiv_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,M.x86.R_DX,s)
#define idiv_long(s) idiv_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,M.x86.R_EDX,s)
#define div_byte(s) div_byte_asm(&M.x86.R_EFLG,&M.x86.R_AL,&M.x86.R_AH,M.x86.R_AX,s)
#define div_word(s) div_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,M.x86.R_DX,s)
#define div_long(s) div_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,M.x86.R_EDX,s)
#endif
#ifdef __cplusplus
} /* End of "C" linkage for C++ */
#endif
#endif /* __X86EMU_PRIM_OPS_H */

View File

@ -2,7 +2,7 @@
*
* Realmode X86 Emulator Library
*
* Copyright (C) 1996-1999 SciTech Software, Inc.
* Copyright (C) 1991-2004 SciTech Software, Inc.
* Copyright (C) David Mosberger-Tang
* Copyright (C) 1999 Egbert Eich
*
@ -38,8 +38,6 @@
*
****************************************************************************/
/* $XFree86: xc/extras/x86emu/src/x86emu/x86emu/x86emui.h,v 1.4 2001/04/01 13:59:58 tsi Exp $ */
#ifndef __X86EMU_X86EMUI_H
#define __X86EMU_X86EMUI_H
@ -70,14 +68,12 @@
#include "x86emu/prim_ops.h"
#include "x86emu/fpu.h"
#include "x86emu/fpu_regs.h"
#ifdef IN_MODULE
#include <xf86_ansic.h>
#else
#ifndef __KERNEL__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#endif
/*--------------------------- Inline Functions ----------------------------*/
#ifdef __cplusplus