home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / misc / vfwdk / samples / bravado / vcap.inc < prev    next >
Encoding:
Text File  |  1993-01-31  |  4.0 KB  |  190 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;
  3. ; VCAP.INC - 
  4. ;
  5. ; (C) Copyright Microsoft Corp. 1992-1993.  All rights reserved.
  6. ;
  7. ; You have a royalty-free right to use, modify, reproduce and 
  8. ; distribute the Sample Files (and/or any modified version) in 
  9. ; any way you find useful, provided that you agree that 
  10. ; Microsoft has no warranty obligations or liability for any 
  11. ; Sample Application Files which are modified. 
  12. ;
  13. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  14.  
  15. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  16. ;
  17. ;   equates
  18. ;
  19. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
  20.  
  21. TRUE          equ 1
  22. FALSE         equ 0
  23.  
  24. PIC_EOI_MASTER      equ 20h             ; where to send master EOI
  25. PIC_EOI_SLAVE       equ 0A0h            ; where to send slave EOI
  26.  
  27. PIC_IMR_MASTER      equ 21h
  28. PIC_IMR_SLAVE       equ 0A1h
  29.  
  30. ; Common structures for accessing lo/hi words of DWORD
  31.  
  32. LONG    struc
  33. lo      dw      ?
  34. hi      dw      ?
  35. LONG    ends
  36.  
  37. LOHI    struc
  38. lob      db      ?
  39. hib      db      ?
  40. LOHI    ends
  41.  
  42. FARPOINTER      struc
  43. off     dw      ?
  44. sel     dw      ?
  45. FARPOINTER      ends
  46.  
  47.  
  48. ;---------------------------------Macro---------------------------------;
  49. ;
  50. ; EnterCritAndTrashBX
  51. ;
  52. ;   saves the current state of the interrupt flag on the stack then
  53. ;   disables interrupts.
  54. ;
  55. ; Registers Destroyed:
  56. ;       BX, FLAGS
  57. ;
  58. ;------------------------------------------------------------------------;
  59.  
  60. EnterCrit macro
  61.     local   no_cli
  62.     pushf
  63.     pushf
  64.     pop     bx
  65.     test    bh,2            ; if interupts are already off, dont blow
  66.     jz      no_cli          ; ... ~300 clocks doing the cli
  67.     cli
  68. no_cli:
  69. endm
  70.  
  71. ;---------------------------------Macro---------------------------------;
  72. ;
  73. ; LeaveCritAndTrashBX
  74. ;
  75. ;   restore the interrupt state saved by EnterCritAndTrashBX
  76. ;
  77. ; Registers Destroyed:
  78. ;       BX, FLAGS
  79. ;
  80. ;------------------------------------------------------------------------;
  81.  
  82. LeaveCrit macro reg
  83.     local   no_sti
  84.     pop     bx
  85.     test    bh, 2
  86.     jz      no_sti
  87.     sti
  88. no_sti:
  89. endm
  90.  
  91. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  92. ;
  93. ;   debug support
  94. ;
  95. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  96.  
  97. ifdef DEBUG
  98.     extrn OutputDebugString:far       
  99.     extrn _wDebugLevel:word           ; initc.c
  100. endif
  101.  
  102. D1 macro text
  103.     DOUT 1, < ",13,10,"Capture: &text&>
  104.     endm
  105. D2 macro text
  106.     DOUT 2, < &text&>
  107.     endm
  108. D3 macro text
  109.     DOUT 3, < &text&>
  110.     endm
  111. D4 macro text
  112.     DOUT 4, < &text&>
  113.     endm
  114.  
  115. DOUT macro level, text
  116.     local   string_buffer
  117.     local   wrong_level
  118.  
  119. ifdef DEBUG
  120.  
  121. _DATA segment
  122. string_buffer label byte
  123.     db      "&text&",0
  124. _DATA ends
  125.  
  126.     cmp     [_wDebugLevel], level
  127.     jl      wrong_level
  128.     push    DataBASE
  129.     push    DataOFFSET string_buffer
  130.     call    OutputDebugString
  131. wrong_level:
  132. endif
  133.     endm
  134.  
  135.  
  136. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  137. ;
  138. ;   assert macros
  139. ;
  140. ;   AssertF byte        -- fail iff byte==0
  141. ;   AssertT byte        -- fail iff byte!=0
  142. ;
  143. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  144.  
  145. AssertF     macro exp
  146.     local   assert_ok
  147. ifdef DEBUG
  148.     push    ax
  149.     
  150.     mov     al,exp
  151.     or      al,al
  152.     jnz     assert_ok
  153.  
  154.     D1      <AssertF fail (&exp&)>
  155.     int     3
  156.  
  157. assert_ok:
  158.     pop     ax
  159. endif
  160.     endm
  161.  
  162. AssertT     macro exp
  163.     local   assert_ok
  164. ifdef DEBUG
  165.     push    ax
  166.     
  167.     mov     al,exp
  168.     or      al,al
  169.     jz      assert_ok
  170.  
  171.     D1      <AssertT fail (&exp&)>
  172.     int     3
  173.  
  174. assert_ok:
  175.     pop     ax
  176. endif
  177.     endm
  178.  
  179. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  180. ;
  181. ; reminder macro
  182. ;
  183. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  184.  
  185. BUG macro stuff
  186. if1
  187. %out ----&stuff&
  188. endif
  189. endm
  190.