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.

364 lines
6.9 KiB

  1. ;++
  2. ;
  3. ;Copyright (c) 1991 Microsoft Corporation
  4. ;
  5. ;Module Name:
  6. ;
  7. ; debugmac.inc
  8. ;
  9. ;Abstract:
  10. ;
  11. ; Contains debugging macros:
  12. ;
  13. ; DbgBreakPoint
  14. ; DbgUnsupported
  15. ; DbgDEBUG
  16. ; DbgPrint
  17. ; DbgPrintTty
  18. ; DbgPrintString
  19. ; DbgPrintHexDword
  20. ; DbgPrintHexWord
  21. ; DbgPrintHexByte
  22. ; DbgPrintNearPointer
  23. ; DbgPrintFarPointer
  24. ;
  25. ;Author:
  26. ;
  27. ; Richard L Firth (rfirth) 13-Sep-1991
  28. ;
  29. ;Environment:
  30. ;
  31. ; DOS application mode only
  32. ;
  33. ;[Notes:]
  34. ;
  35. ; optional-notes
  36. ;
  37. ;Revision History:
  38. ;
  39. ; 13-Sep-1991 rfirth
  40. ; Created
  41. ;
  42. ;--
  43. ;*** DbgBreakPoint
  44. ;*
  45. ;* Same as NT routine of same name. No-op in non-DEBUG version
  46. ;*
  47. ;* ENTRY
  48. ;*
  49. ;* EXIT
  50. ;*
  51. ;* RETURNS
  52. ;*
  53. ;* ASSUMES
  54. ;*
  55. ;***
  56. DbgBreakPoint macro
  57. if DEBUG
  58. int 3
  59. endif
  60. endm
  61. ;*** DbgUnsupported
  62. ;*
  63. ;* Causes the 32-bit support code to display a message about an unsupported
  64. ;* service code, and dumps the 16-bit registers. Used to discover when an
  65. ;* unsupported int 2f/11 call or int 21/5f call is being made
  66. ;*
  67. ;* ENTRY
  68. ;*
  69. ;* EXIT
  70. ;*
  71. ;* RETURNS
  72. ;*
  73. ;* ASSUMES
  74. ;*
  75. ;***
  76. DbgUnsupported macro
  77. if DEBUG
  78. SVC -1
  79. endif
  80. endm
  81. ;*** DbgDEBUG
  82. ;*
  83. ;* Prints the string "DEBUG: " to console using Bios Int 10h/ah=0eh
  84. ;*
  85. ;* ENTRY nothing
  86. ;*
  87. ;* EXIT nothing
  88. ;*
  89. ;* USES ax
  90. ;*
  91. ;* ASSUMES 286+
  92. ;*
  93. ;***
  94. DbgDEBUG macro
  95. mov ax,(14 shl 8) + 'D'
  96. ifndef NEC_98 ;Delete int 10h
  97. int 10h
  98. mov al,'E'
  99. int 10h
  100. mov al,'B'
  101. int 10h
  102. mov al,'U'
  103. int 10h
  104. mov al,'G'
  105. int 10h
  106. mov al,':'
  107. int 10h
  108. mov al,' '
  109. int 10h
  110. endif ;NEC_98
  111. endm
  112. ;*** DbgCrLf
  113. ;*
  114. ;* Prints CR,LF to console using Bios Int 10h/ah=0eh
  115. ;*
  116. ;* ENTRY nothing
  117. ;*
  118. ;* EXIT nothing
  119. ;*
  120. ;* USES nothing
  121. ;*
  122. ;* ASSUMES 286+
  123. ;*
  124. ;***
  125. DbgCrLf macro
  126. push ax
  127. mov ax,(14 shl 8) + 13
  128. ifndef NEC_98
  129. int 10h
  130. mov al,10
  131. int 10h
  132. endif ;NEC_98
  133. pop ax
  134. endm
  135. ;*** DbgPrint
  136. ;*
  137. ;* Prints an ASCIZ string to console using Bios Int 10h
  138. ;*
  139. ;* ENTRY string - address of ASCIZ string to print
  140. ;*
  141. ;* EXIT nothing
  142. ;*
  143. ;* USES nothing
  144. ;*
  145. ;* ASSUMES 286+
  146. ;*
  147. ;***
  148. DbgPrint macro string
  149. if DEBUG ;; no macro if not debug version
  150. pushf ;; save regs used by DbgPrintTty
  151. push ax
  152. push bx
  153. push si
  154. push ds
  155. mov ax,seg string
  156. mov ds,ax
  157. mov si,offset string;; ds:si = address of string
  158. DbgPrintTty ;; display it on console
  159. pop ds
  160. pop si
  161. pop bx
  162. pop ax
  163. popf
  164. endif
  165. endm
  166. ;*** DbgPrintTty
  167. ;*
  168. ;* Prints an ASCIZ string in ds:si to console using Bios Int 10h
  169. ;*
  170. ;* ENTRY page - if present defines which Bios video page to use
  171. ;* Defaults to 0
  172. ;* ds:si - address of ASCIZ string to print
  173. ;*
  174. ;* EXIT nothing
  175. ;*
  176. ;* USES al, bh, si, flags
  177. ;*
  178. ;* ASSUMES 286+
  179. ;*
  180. ;***
  181. DbgPrintTty macro page
  182. local l1,l2
  183. if DEBUG ;; no macro if not debug version
  184. mov ah,14 ;; Bios Int write character as TTY function
  185. ifb <page>
  186. sub bh,bh
  187. else
  188. mov bh,page
  189. endif
  190. cld ;; autoincrement lodsb
  191. l1: lodsb ;; al := next character; si := next character addr
  192. or al,al ;; eof string?
  193. jz l2 ;; yes
  194. ifndef NEC_98
  195. int 10h ;; display it to console
  196. endif ;NEC_98
  197. jmp short l1 ;; go round again
  198. l2:
  199. endif
  200. endm
  201. ;*** DbgPrintString
  202. ;*
  203. ;* Prints a string to console using Bios Int 10h. Note that this macro
  204. ;* does not do printf style substitutions. The string "DEBUG: " will be
  205. ;* displayed if the banner parm is not blank
  206. ;*
  207. ;* ENTRY string - character string. Needn't be zero-terminated
  208. ;* banner - the "DEBUG: " banner will be printed if not blank
  209. ;*
  210. ;* EXIT nothing
  211. ;*
  212. ;* USES nothing
  213. ;*
  214. ;* ASSUMES 286+
  215. ;*
  216. ;***
  217. DbgPrintString macro string, banner
  218. local s1
  219. local l1
  220. if DEBUG ;; no macro if not debug version
  221. jmp short l1
  222. s1 db &string,0
  223. l1: pushf ;; don't destroy direction flag
  224. pusha ;; save gp regs
  225. ifb <banner>
  226. DbgDEBUG ;; Display "DEBUG: "
  227. endif
  228. push ds ;; save user's data seg
  229. push cs
  230. pop ds ;; ds == cs
  231. mov si,offset cs:s1 ;; si := string offset
  232. DbgPrintTty ;; display ds:si to console
  233. pop ds ;; restore user's data seg
  234. popa ;; restore gp regs
  235. popf ;; restore direction flag+
  236. endif
  237. endm
  238. ;*** DbgPrintHexDword
  239. ;*
  240. ;* Prints a dword to console in hex notation using Bios Int 10h
  241. ;*
  242. ;* ENTRY dword - dword to print
  243. ;*
  244. ;* EXIT nothing
  245. ;*
  246. ;* USES nothing
  247. ;*
  248. ;* ASSUMES 286+
  249. ;*
  250. ;***
  251. DbgPrintHexDword macro dword
  252. if DEBUG ;; no macro if not debug version
  253. DbgPrint <"DbgPrintHexDword not implemented yet",13,10>
  254. endif
  255. endm
  256. ;*** DbgPrintHexWord
  257. ;*
  258. ;* Prints a word to console in hex notation using Bios Int 10h
  259. ;*
  260. ;* ENTRY word - to print. Can be memory or register
  261. ;*
  262. ;* EXIT nothing
  263. ;*
  264. ;* USES nothing
  265. ;*
  266. ;* ASSUMES 286+
  267. ;*
  268. ;***
  269. DbgPrintHexWord macro word
  270. local l1, l2
  271. if DEBUG ;; no macro if not debug version
  272. pushf ;; don't use any registers
  273. push ax
  274. push cx
  275. push dx
  276. ifdifi <word>,<ax>
  277. mov ax,word
  278. endif
  279. mov cx,4
  280. l1: rol ax,4
  281. mov dx,ax
  282. and al,0fh
  283. cmp al,9
  284. jle l2
  285. add al,'a'-('9'+1)
  286. l2: add al,'0'
  287. mov ah,14
  288. ifndef NEC_98
  289. int 10h
  290. endif ;NEC_98
  291. mov ax,dx
  292. loop l1
  293. pop dx
  294. pop cx
  295. pop ax
  296. popf
  297. endif
  298. endm
  299. ;*** DbgPrintHexByte
  300. ;*
  301. ;* Prints a string to console using Bios Int 10h. Note that this macro
  302. ;* does not do printf style substitutions
  303. ;*
  304. ;* ENTRY string - character string. Needn't be zero-terminated
  305. ;*
  306. ;* EXIT
  307. ;*
  308. ;* USES nothing
  309. ;*
  310. ;* ASSUMES 286+
  311. ;*
  312. ;***
  313. DbgPrintHexByte macro byte
  314. if DEBUG ;; no macro if not debug version
  315. DbgPrint <"DbgPrintHexByte not implemented yet",13,10>
  316. endif
  317. endm
  318. DbgPrintNearPointer macro nearptr
  319. endm
  320. DbgPrintFarPointer macro farptr
  321. endm