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.

109 lines
3.2 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. frag16.c
  5. Abstract:
  6. Instuction fragments which operate on 16-bit WORDS
  7. Author:
  8. 12-Jun-1995 BarryBo
  9. Revision History:
  10. --*/
  11. #include <nt.h>
  12. #include <ntrtl.h>
  13. #include <nturtl.h>
  14. #include <windows.h>
  15. #include <stdio.h>
  16. #include "fragp.h"
  17. #include "frag16.h"
  18. // set up to include common functions
  19. #define MSB 0x8000
  20. #define LMB 15 // Left Most Bit
  21. #define UTYPE unsigned short
  22. #define STYPE signed short
  23. #define GET_VAL GET_SHORT
  24. #define PUT_VAL PUT_SHORT
  25. #define PUSH_VAL PUSH_SHORT
  26. #define POP_VAL POP_SHORT
  27. #define FRAGCOMMON0(fn) FRAG0(fn ## 16)
  28. #define FRAGCOMMON1(fn) FRAG1(fn ## 16,UTYPE)
  29. #define FRAGCOMMON1IMM(fn) FRAG1IMM( fn ## 16, UTYPE)
  30. #define FRAGCOMMON2(fn) FRAG2(fn ## 16, UTYPE)
  31. #define FRAGCOMMON2IMM(fn) FRAG2IMM( fn ## 16, UTYPE, UTYPE)
  32. #define FRAGCOMMON2REF(fn) FRAG2REF(fn ## 16, UTYPE)
  33. #define FRAGCOMMON3(fn) FRAG3(fn ## 16, UTYPE, UTYPE, UTYPE)
  34. #define AREG ax
  35. #define BREG bx
  36. #define CREG cx
  37. #define DREG dx
  38. #define SPREG sp
  39. #define BPREG bp
  40. #define SIREG si
  41. #define DIREG di
  42. #define SET_FLAGS_ADD SET_FLAGS_ADD16
  43. #define SET_FLAGS_SUB SET_FLAGS_SUB16
  44. #define SET_FLAGS_INC SET_FLAGS_INC16
  45. #define SET_FLAGS_DEC SET_FLAGS_DEC16
  46. #define GET_BYTE(addr) (*(UNALIGNED unsigned char *)(addr))
  47. #define GET_SHORT(addr) (*(UNALIGNED unsigned short *)(addr))
  48. #define GET_LONG(addr) (*(UNALIGNED unsigned long *)(addr))
  49. #undef PUT_BYTE
  50. #undef PUT_SHORT
  51. #undef PUT_LONG
  52. #define PUT_BYTE(addr,dw) {GET_BYTE(addr)=(unsigned char)dw;}
  53. #define PUT_SHORT(addr,dw) {GET_SHORT(addr)=(unsigned short)dw;}
  54. #define PUT_LONG(addr,dw) {GET_LONG(addr)=(unsigned long)dw;}
  55. // include the common functions with 8/16/32 flavors, with no alignment issues
  56. #include "shared.c"
  57. // include the common functions with 16/32 flavors, with no alignment issues
  58. #include "shr1632.c"
  59. // include the common unaligned functions with 8/16/32 flavors
  60. #include "shareda.c"
  61. // include the common unaligned functions with 16/32 flavors
  62. #include "shr1632a.c"
  63. #undef FRAGCOMMON0
  64. #undef FRAGCOMMON1
  65. #undef FRAGCOMMON1IMM
  66. #undef FRAGCOMMON2
  67. #undef FRAGCOMMON2IMM
  68. #undef FRAGCOMMON2REF
  69. #undef FRAGCOMMON3
  70. #undef GET_BYTE
  71. #undef GET_SHORT
  72. #undef GET_LONG
  73. #if MSCPU
  74. #define FRAGCOMMON0(fn) FRAG0(fn ## 16A)
  75. #define FRAGCOMMON1(fn) FRAG1(fn ## 16A,UTYPE)
  76. #define FRAGCOMMON1IMM(fn) FRAG1IMM( fn ## 16A, UTYPE)
  77. #define FRAGCOMMON2(fn) FRAG2(fn ## 16A, UTYPE)
  78. #define FRAGCOMMON2IMM(fn) FRAG2IMM( fn ## 16A, UTYPE, UTYPE)
  79. #define FRAGCOMMON2REF(fn) FRAG2REF(fn ## 16A, UTYPE)
  80. #define FRAGCOMMON3(fn) FRAG3(fn ## 16A, UTYPE, UTYPE, UTYPE)
  81. #define GET_BYTE(addr) (*(unsigned char *)(addr))
  82. #define GET_SHORT(addr) (*(unsigned short *)(addr))
  83. #define GET_LONG(addr) (*(unsigned long *)(addr))
  84. // include the common aligned functions with 8/16/32 flavors
  85. #include "shareda.c"
  86. // include the common aligned functions with 16/32 flavors
  87. #include "shr1632a.c"
  88. #endif