home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / network / pcb121.zip / DEBUG.INC < prev    next >
Text File  |  1992-01-23  |  4KB  |  205 lines

  1. ;;*************************************************************************
  2. ;;
  3. ;;  Copyright (C) 1989 Northwestern University, Vance Morrison
  4. ;;
  5. ;;
  6. ;; Permission to view, compile, and modify for LOCAL (intra-organization) 
  7. ;; USE ONLY is hereby granted, provided that this copyright and permission 
  8. ;; notice appear on all copies.  Any other use by permission only.
  9. ;;
  10. ;; Northwestern University makes no representations about the suitability 
  11. ;; of this software for any purpose.  It is provided "as is" without expressed 
  12. ;; or implied warranty.  See the copywrite notice file for complete details.
  13. ;;
  14.  
  15. ;;***************************************
  16. ;; debug.inc contains debug routines.
  17.  
  18. print macro string
  19.     db_print <string>
  20.     endm
  21.  
  22. db_print macro string
  23.     local return
  24.  
  25.     db_print_it <'&string&'>
  26.     db_print_it <13,10>
  27.     endm
  28.  
  29. ;;***************************************
  30. print_reg macro string, reg
  31.     db_print_reg <string>, reg
  32.     endm
  33.  
  34. db_print_reg macro string, reg
  35.     .errb <reg>
  36.  
  37.     push AX
  38.     mov AX, reg
  39.     db_print_AX <&string>
  40.     pop AX
  41.     endm
  42.  
  43. ;;***************************************
  44. dump macro segment, address, count
  45.     db_dump segment, address, count
  46.     endm
  47.  
  48. db_dump macro segment, address, count
  49.     push SI
  50.     push CX
  51.     mov CX, count
  52.     mov SI, offset address
  53.     db_dump_in_SI_CX segment
  54.     pop CX
  55.     pop SI
  56.     ENDM
  57.  
  58.  
  59. ;;***************************************
  60. dump_in_SI_CX macro segment
  61.     db_dump_in_SI_CX segment
  62.     endm
  63.  
  64. db_dump_in_SI_CX macro segment
  65.     local myloop, no_newline
  66.  
  67.     push AX
  68.     push BX
  69.     push CX
  70.     push SI
  71.  
  72.     mov BX, 8
  73.     myloop:
  74.         seg&segment
  75.     lodsb
  76.     db_print_AL <>
  77.         dec BX
  78.         jnz no_newline
  79.         mov BX, 8
  80.         db_print <>
  81.     no_newline:
  82.     dec CX
  83.     jnz myloop
  84.     db_print <>
  85.  
  86.     pop SI
  87.     pop CX
  88.     pop BX
  89.     pop AX
  90.     endm
  91.  
  92. ;; PRIVATE routeines.  Please do not use directly, they rely on DS being
  93. ;; set properly
  94. ;;***************************************
  95. db_print_no_nl macro string
  96.     local return
  97.  
  98.     db_print_it <'&string&'>
  99.     endm
  100.  
  101. ;;***************************************
  102. print_AL macro string
  103.     db_print_AL string
  104.     endm
  105.  
  106. db_print_AL macro string
  107.  
  108.     db_print_no_nl <&string>
  109.     db_print_no_nl <  >
  110.     call db_print_hex_in_AL
  111.     endm
  112.  
  113. ;;***************************************
  114. print_AX macro string
  115.    db_print_AX string
  116.    endm
  117.  
  118. db_print_AX macro string
  119.     .errb <string>
  120.  
  121.     db_print_no_nl <&string>
  122.     db_print_no_nl < >
  123.     call db_print_hex_in_AX
  124.     db_print    <>
  125.  
  126.     endm
  127.  
  128. ;;***************************************
  129. db_print_it macro string
  130.     local string_name, return
  131.     .errb <string>
  132.  
  133.     .data
  134. string_name db &string&,'$'
  135.  
  136.     .code
  137.     push AX
  138.     push DX
  139.  
  140.     mov ah, 9
  141.     mov dx, offset string_name
  142.     int 21h
  143.  
  144.     pop DX
  145.     pop AX
  146.     endm
  147.  
  148. ;;***************************************
  149. ;; db_define is called before any of the debug routines are called
  150.  
  151. DB_DECLARE macro 
  152.     global db_print_hex_digit_in_AL:proc
  153.     global db_print_hex_in_AX:proc
  154.     global db_print_hex_in_AL:proc
  155. ENDM
  156.  
  157. DB_DEFINE macro 
  158.     local around
  159.  
  160.     jmp around
  161. global db_print_hex_digit_in_AL:proc
  162. db_print_hex_digit_in_AL:
  163.     push DX
  164.     push AX
  165.     and AL, 0Fh
  166.     cmp AL, 10
  167.     jl digit
  168.     add AL, 'A'-10
  169.     jmp db_print_char
  170.     digit:
  171.     add AL, '0'
  172.     db_print_char:
  173.     mov DL, AL
  174.     mov AH, 2
  175.     int 21h
  176.     pop AX
  177.     pop DX
  178.     ret
  179.  
  180. ;;***************************************
  181. global db_print_hex_in_AL:proc
  182. db_print_hex_in_AL:
  183.     push AX         ;; Save AX
  184.     SHR AL,1
  185.     SHR AL,1
  186.     SHR AL,1
  187.     SHR AL,1
  188.     call db_print_hex_digit_in_AL
  189.     pop AX
  190.     call db_print_hex_digit_in_AL
  191.     ret
  192.  
  193. ;;***************************************
  194. global db_print_hex_in_AX:proc
  195. db_print_hex_in_AX:
  196.     push AX         ;; Save AX
  197.     mov AL, AH
  198.     call db_print_hex_in_AL ;; db_print MSB
  199.     pop AX
  200.     call db_print_hex_in_AL
  201.     ret 
  202.  
  203.     around:
  204.     ENDM
  205.