Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. decoderp.h
  5. Abstract:
  6. Private exports, defines for CPU Instruction decoder
  7. Author:
  8. 27-Jun-1995 BarryBo, Created
  9. Revision History:
  10. --*/
  11. #ifndef DECODERP_H
  12. #define DECODERP_H
  13. #define GET_BYTE(addr) (*(UNALIGNED unsigned char *)(addr))
  14. #define GET_SHORT(addr) (*(UNALIGNED unsigned short *)(addr))
  15. #define GET_LONG(addr) (*(UNALIGNED unsigned long *)(addr))
  16. /*---------------------------------------------------------------------*/
  17. typedef struct _DecoderState {
  18. DWORD InstructionAddress;
  19. INT RepPrefix;
  20. BOOL AdrPrefix;
  21. OPERATION OperationOverride;
  22. } DECODERSTATE, *PDECODERSTATE;
  23. #define eipTemp State->InstructionAddress
  24. #define DISPATCH(x) void x(PDECODERSTATE State, PINSTRUCTION Instr)
  25. #if DBG
  26. #define UNIMPL_INSTR(name) { \
  27. OutputDebugString("CPU: Warning: unimplemented instruction " ## name ## " encountered\r\n"); \
  28. BAD_INSTR; \
  29. }
  30. #else
  31. #define UNIMPL_INSTR BAD_INSTR
  32. #endif
  33. #define BAD_INSTR \
  34. State->OperationOverride = OP_BadInstruction;
  35. #define PRIVILEGED_INSTR \
  36. State->OperationOverride = OP_PrivilegedInstruction;
  37. #define get_reg32(cpu) \
  38. (GP_EAX + (((*(PBYTE)(eipTemp+1)) >> 3) & 0x07))
  39. #define get_reg16(cpu) \
  40. (GP_AX + (((*(PBYTE)(eipTemp+1)) >> 3) & 0x07))
  41. #define DEREF8(Op) \
  42. CPUASSERT(Op.Type == OPND_REGREF || Op.Type == OPND_ADDRREF); \
  43. Op.Type = (Op.Type == OPND_REGREF) ? OPND_REGVALUE : OPND_ADDRVALUE8;
  44. #define DEREF16(Op) \
  45. CPUASSERT(Op.Type == OPND_REGREF || Op.Type == OPND_ADDRREF); \
  46. Op.Type = (Op.Type == OPND_REGREF) ? OPND_REGVALUE : OPND_ADDRVALUE16;
  47. #define DEREF32(Op) \
  48. CPUASSERT(Op.Type == OPND_REGREF || Op.Type == OPND_ADDRREF); \
  49. Op.Type++;
  50. int scaled_index(PBYTE pmodrm, POPERAND op);
  51. void get_segreg(PDECODERSTATE State, POPERAND op);
  52. int mod_rm_reg32(PDECODERSTATE State, POPERAND op1, POPERAND op2);
  53. int mod_rm_reg16(PDECODERSTATE State, POPERAND op1, POPERAND op2);
  54. int mod_rm_reg8 (PDECODERSTATE State, POPERAND op1, POPERAND op2);
  55. #define PREFIX_NONE 0
  56. #define PREFIX_REPZ 1
  57. #define PREFIX_REPNZ 2
  58. typedef void (*pfnDispatchInstruction)(PDECODERSTATE, PINSTRUCTION);
  59. extern pfnDispatchInstruction Dispatch32[256];
  60. extern pfnDispatchInstruction Dispatch232[256];
  61. extern pfnDispatchInstruction Dispatch16[256];
  62. extern pfnDispatchInstruction Dispatch216[256];
  63. extern pfnDispatchInstruction LockDispatch32[256];
  64. extern pfnDispatchInstruction LockDispatch232[256];
  65. extern pfnDispatchInstruction LockDispatch16[256];
  66. extern pfnDispatchInstruction LockDispatch216[256];
  67. #endif //DECODERP_H