Source code of Windows XP (NT5)
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.

242 lines
3.9 KiB

  1. ;++
  2. ;
  3. ;Copyright (c) 1991 Microsoft Corporation
  4. ;
  5. ;Module Name:
  6. ;
  7. ; asmmacro.inc
  8. ;
  9. ;Abstract:
  10. ;
  11. ; Contains macros to extend masm functionality:
  12. ;
  13. ; jmpc
  14. ; jmpnc
  15. ; jmpne
  16. ; jmps
  17. ; _mkjmp
  18. ;
  19. ;
  20. ;Author:
  21. ;
  22. ; Richard L Firth (rfirth) 24-Sep-1991
  23. ;
  24. ;Environment:
  25. ;
  26. ; DOS application mode only
  27. ;
  28. ;Revision History:
  29. ;
  30. ; 24-Sep-1991 rfirth
  31. ; Created
  32. ;
  33. ;--
  34. DEFINED_BIT=020h
  35. ;ISDEFINED equ %(.type <thing> and DEFINED_BIT)
  36. LABEL_DEFINED equ <(.type &label and DEFINED_BIT)>
  37. DEBUG_MACROS = 0
  38. ;DEBUG_MACROS = 1
  39. ;*** jmpa
  40. ;*
  41. ;* jump to label if above. Label can be short (+129, -126 from
  42. ;* the first byte of the current jump instruction, if it is a short - ie
  43. ;* byte - jump) or near
  44. ;*
  45. ;* ENTRY label - to jump to
  46. ;*
  47. ;* EXIT nothing
  48. ;*
  49. ;* USES nothing
  50. ;*
  51. ;* ASSUMES 286+
  52. ;*
  53. ;***
  54. jmpa macro label
  55. _mkjmp ja,jna,&label
  56. endm
  57. ;*** jmpc
  58. ;*
  59. ;* jump to label if below. Label can be short (+129, -126 from
  60. ;* the first byte of the current jump instruction, if it is a short - ie
  61. ;* byte - jump) or near
  62. ;*
  63. ;* ENTRY label - to jump to
  64. ;*
  65. ;* EXIT nothing
  66. ;*
  67. ;* USES nothing
  68. ;*
  69. ;* ASSUMES 286+
  70. ;*
  71. ;***
  72. jmpb macro label
  73. _mkjmp jb,jnb,&label
  74. endm
  75. ;*** jmpc
  76. ;*
  77. ;* jump to label if carry flag set. Label can be short (+129, -126 from
  78. ;* the first byte of the current jump instruction, if it is a short - ie
  79. ;* byte - jump) or near
  80. ;*
  81. ;* ENTRY label - to jump to
  82. ;*
  83. ;* EXIT nothing
  84. ;*
  85. ;* USES nothing
  86. ;*
  87. ;* ASSUMES 286+
  88. ;*
  89. ;***
  90. jmpc macro label
  91. _mkjmp jc,jnc,&label
  92. endm
  93. ;*** jmpnc
  94. ;*
  95. ;* jump to label if carry flag NOT set. Label can be short (+129, -126 from
  96. ;* the first byte of the current jump instruction, if it is a short - ie
  97. ;* byte - jump) or near
  98. ;*
  99. ;* ENTRY label - to jump to
  100. ;*
  101. ;* EXIT nothing
  102. ;*
  103. ;* USES nothing
  104. ;*
  105. ;* ASSUMES 286+
  106. ;*
  107. ;***
  108. jmpnc macro label
  109. _mkjmp jnc,jc,&label
  110. endm
  111. ;*** jmpne
  112. ;*
  113. ;* jump to label if zero flag NOT set. Label can be short (+129, -126 from
  114. ;* the first byte of the current jump instruction, if it is a short - ie
  115. ;* byte - jump) or near
  116. ;*
  117. ;* ENTRY label - to jump to
  118. ;*
  119. ;* EXIT nothing
  120. ;*
  121. ;* USES nothing
  122. ;*
  123. ;* ASSUMES 286+
  124. ;*
  125. ;***
  126. jmpne macro label
  127. _mkjmp jne,je,&label
  128. endm
  129. ;*** jmpe
  130. ;*
  131. ;* jump to label if zero flag set. Label can be short (+129, -126 from
  132. ;* the first byte of the current jump instruction, if it is a short - ie
  133. ;* byte - jump) or near
  134. ;*
  135. ;* ENTRY label - to jump to
  136. ;*
  137. ;* EXIT nothing
  138. ;*
  139. ;* USES nothing
  140. ;*
  141. ;* ASSUMES 286+
  142. ;*
  143. ;***
  144. jmpe macro label
  145. _mkjmp je,jne,&label
  146. endm
  147. ;*** jmps
  148. ;*
  149. ;* jump to label. Label can be short (+129, -126 from
  150. ;* the first byte of the current jump instruction, if it is a short - ie
  151. ;* byte - jump) or near
  152. ;*
  153. ;* ENTRY label - to jump to
  154. ;*
  155. ;* EXIT nothing
  156. ;*
  157. ;* USES nothing
  158. ;*
  159. ;* ASSUMES 286+
  160. ;*
  161. ;***
  162. jmps macro label
  163. local dist
  164. dist=&label-$
  165. if DEBUG
  166. jmp &label
  167. else
  168. if (.type label and DEFINED_BIT)
  169. if ((dist gt 129) or (dist lt -126))
  170. jmp &label
  171. else
  172. jmp short &label
  173. endif
  174. else
  175. jmp &label
  176. endif
  177. endif
  178. endm
  179. ;*** _mkjmp
  180. ;*
  181. ;* Make a jmp<?> macro. Generate instruction sequence for jump with or
  182. ;* without conditional test. Jump may be short (+127/-128 bytes) or near
  183. ;* (+32767/-32768 bytes)
  184. ;*
  185. ;* ENTRY is - short jump instruction
  186. ;* in - near jump instruction
  187. ;* label - to jump to
  188. ;*
  189. ;* EXIT nothing
  190. ;*
  191. ;* USES nothing
  192. ;*
  193. ;* ASSUMES 286+
  194. ;*
  195. ;***
  196. _mkjmp macro is, in, label
  197. local l
  198. if DEBUG
  199. &in l
  200. jmp &label
  201. else
  202. &is &label
  203. endif
  204. l:
  205. endm