#ifndef __x86_h
#define __x86_h

#ifdef linux
#define vm86_addr(segment, offset) (((segment) << 4) + (offset))
/*

inline void * vm86_addr (int segment, int offset) {
  return (void *)(((segment & 0xffff) << 4) + 
  (offset & 0xffff));
}
*/

#endif

/* Although the vm86_regs struct is already defined in <linux/vm86.h>,
 * a specialised version is defined here, so the dos daemon program
 * can load the values into the appropriate registers.
 * It all could probably have been done easier as just 16 bits, but
 * I already had a lot of things I would have had to change in programs
 */
#ifdef __GNUC__
#include "system.h"
#define REG86(reg) int32 reg
#else
#define uint16 unsigned int 
#define int16 int
#define REG86(reg) struct _86reg reg
#endif

struct _86reg {
  int16 lw; /* low word first (Little Endian???) */
  int16 hw; /* now the high word */
};

struct x86regs {
  REG86(eax);
  REG86(ebx);
  REG86(ecx);
  REG86(edx);
  REG86(esi);
  REG86(edi);
#ifdef linux /* only needed from withing dosemu itself, and the client */
  uint32 eflags;
  uint16 es;
  uint16 cs;
  uint16 ds;
#endif /* linux */
};

#endif
