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.

356 lines
7.1 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. int 10h
  97. mov al,'E'
  98. int 10h
  99. mov al,'B'
  100. int 10h
  101. mov al,'U'
  102. int 10h
  103. mov al,'G'
  104. int 10h
  105. mov al,':'
  106. int 10h
  107. mov al,' '
  108. int 10h
  109. endm
  110. ;*** DbgCrLf
  111. ;*
  112. ;* Prints CR,LF to console using Bios Int 10h/ah=0eh
  113. ;*
  114. ;* ENTRY nothing
  115. ;*
  116. ;* EXIT nothing
  117. ;*
  118. ;* USES nothing
  119. ;*
  120. ;* ASSUMES 286+
  121. ;*
  122. ;***
  123. DbgCrLf macro
  124. push ax
  125. mov ax,(14 shl 8) + 13
  126. int 10h
  127. mov al,10
  128. int 10h
  129. pop ax
  130. endm
  131. ;*** DbgPrint
  132. ;*
  133. ;* Prints an ASCIZ string to console using Bios Int 10h
  134. ;*
  135. ;* ENTRY string - address of ASCIZ string to print
  136. ;*
  137. ;* EXIT nothing
  138. ;*
  139. ;* USES nothing
  140. ;*
  141. ;* ASSUMES 286+
  142. ;*
  143. ;***
  144. DbgPrint macro string
  145. if DEBUG ;; no macro if not debug version
  146. pushf ;; save regs used by DbgPrintTty
  147. push ax
  148. push bx
  149. push si
  150. push ds
  151. mov ax,seg string
  152. mov ds,ax
  153. mov si,offset string;; ds:si = address of string
  154. DbgPrintTty ;; display it on console
  155. pop ds
  156. pop si
  157. pop bx
  158. pop ax
  159. popf
  160. endif
  161. endm
  162. ;*** DbgPrintTty
  163. ;*
  164. ;* Prints an ASCIZ string in ds:si to console using Bios Int 10h
  165. ;*
  166. ;* ENTRY page - if present defines which Bios video page to use
  167. ;* Defaults to 0
  168. ;* ds:si - address of ASCIZ string to print
  169. ;*
  170. ;* EXIT nothing
  171. ;*
  172. ;* USES al, bh, si, flags
  173. ;*
  174. ;* ASSUMES 286+
  175. ;*
  176. ;***
  177. DbgPrintTty macro page
  178. local l1,l2
  179. if DEBUG ;; no macro if not debug version
  180. mov ah,14 ;; Bios Int write character as TTY function
  181. ifb <page>
  182. sub bh,bh
  183. else
  184. mov bh,page
  185. endif
  186. cld ;; autoincrement lodsb
  187. l1: lodsb ;; al := next character; si := next character addr
  188. or al,al ;; eof string?
  189. jz l2 ;; yes
  190. int 10h ;; display it to console
  191. jmp short l1 ;; go round again
  192. l2:
  193. endif
  194. endm
  195. ;*** DbgPrintString
  196. ;*
  197. ;* Prints a string to console using Bios Int 10h. Note that this macro
  198. ;* does not do printf style substitutions. The string "DEBUG: " will be
  199. ;* displayed if the banner parm is not blank
  200. ;*
  201. ;* ENTRY string - character string. Needn't be zero-terminated
  202. ;* banner - the "DEBUG: " banner will be printed if not blank
  203. ;*
  204. ;* EXIT nothing
  205. ;*
  206. ;* USES nothing
  207. ;*
  208. ;* ASSUMES 286+
  209. ;*
  210. ;***
  211. DbgPrintString macro string, banner
  212. local s1
  213. local l1
  214. if DEBUG ;; no macro if not debug version
  215. jmp short l1
  216. s1 db &string,0
  217. l1: pushf ;; don't destroy direction flag
  218. pusha ;; save gp regs
  219. ifb <banner>
  220. DbgDEBUG ;; Display "DEBUG: "
  221. endif
  222. push ds ;; save user's data seg
  223. push cs
  224. pop ds ;; ds == cs
  225. mov si,offset cs:s1 ;; si := string offset
  226. DbgPrintTty ;; display ds:si to console
  227. pop ds ;; restore user's data seg
  228. popa ;; restore gp regs
  229. popf ;; restore direction flag+
  230. endif
  231. endm
  232. ;*** DbgPrintHexDword
  233. ;*
  234. ;* Prints a dword to console in hex notation using Bios Int 10h
  235. ;*
  236. ;* ENTRY dword - dword to print
  237. ;*
  238. ;* EXIT nothing
  239. ;*
  240. ;* USES nothing
  241. ;*
  242. ;* ASSUMES 286+
  243. ;*
  244. ;***
  245. DbgPrintHexDword macro dword
  246. if DEBUG ;; no macro if not debug version
  247. DbgPrint <"DbgPrintHexDword not implemented yet",13,10>
  248. endif
  249. endm
  250. ;*** DbgPrintHexWord
  251. ;*
  252. ;* Prints a word to console in hex notation using Bios Int 10h
  253. ;*
  254. ;* ENTRY word - to print. Can be memory or register
  255. ;*
  256. ;* EXIT nothing
  257. ;*
  258. ;* USES nothing
  259. ;*
  260. ;* ASSUMES 286+
  261. ;*
  262. ;***
  263. DbgPrintHexWord macro word
  264. local l1, l2
  265. if DEBUG ;; no macro if not debug version
  266. pushf ;; don't use any registers
  267. push ax
  268. push cx
  269. push dx
  270. ifdifi <word>,<ax>
  271. mov ax,word
  272. endif
  273. mov cx,4
  274. l1: rol ax,4
  275. mov dx,ax
  276. and al,0fh
  277. cmp al,9
  278. jle l2
  279. add al,'a'-('9'+1)
  280. l2: add al,'0'
  281. mov ah,14
  282. int 10h
  283. mov ax,dx
  284. loop l1
  285. pop dx
  286. pop cx
  287. pop ax
  288. popf
  289. endif
  290. endm
  291. ;*** DbgPrintHexByte
  292. ;*
  293. ;* Prints a string to console using Bios Int 10h. Note that this macro
  294. ;* does not do printf style substitutions
  295. ;*
  296. ;* ENTRY string - character string. Needn't be zero-terminated
  297. ;*
  298. ;* EXIT
  299. ;*
  300. ;* USES nothing
  301. ;*
  302. ;* ASSUMES 286+
  303. ;*
  304. ;***
  305. DbgPrintHexByte macro byte
  306. if DEBUG ;; no macro if not debug version
  307. DbgPrint <"DbgPrintHexByte not implemented yet",13,10>
  308. endif
  309. endm
  310. DbgPrintNearPointer macro nearptr
  311. endm
  312. DbgPrintFarPointer macro farptr
  313. endm