home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_02 / 2n02028a < prev    next >
Text File  |  1990-12-17  |  5KB  |  249 lines

  1. if  _32bit
  2.    .386P
  3.    Aax             equ   EAX
  4.    Abx             equ   EBX
  5.    Acx             equ   ECX
  6.    Adx             equ   EDX
  7.    Asi             equ   ESI
  8.    Adi             equ   EDI
  9.    Abp             equ   EBP
  10.    Asp             equ   ESP
  11.    BytesPerPush    equ   4
  12. else
  13.    .286P
  14.    Aax             equ   AX
  15.    Abx             equ   BX
  16.    Acx             equ   CX
  17.    Adx             equ   DX
  18.    Asi             equ   SI
  19.    Adi             equ   DI
  20.    Abp             equ   BP
  21.    Asp             equ   SP
  22.    BytesPerPush    equ   2
  23. endif
  24.  
  25. if  monocode   ;offset of first stack argument
  26.    FirstParm equ 2*BytesPerPush  
  27.    else
  28.    FirstParm equ 3*BytesPerPush
  29. endif
  30.  
  31. if  _32bit
  32. makeseg macro segname, segclass
  33. &segname segment dword public &segclass
  34.         endm
  35. else
  36. makeseg macro segname, segclass
  37. &segname segment word  public &segclass
  38.         endm
  39. endif
  40.  
  41. if  huge
  42. dseg    macro
  43. makeseg cc_data, 'DATA'
  44.         assume   ds:cc_data
  45.         endm
  46. endds   macro
  47. cc_data ends
  48.      endm
  49. else
  50. dseg        macro
  51. DGROUP  group _DATA
  52. makeseg _DATA, 'DATA'
  53.         assume  ds:DGROUP
  54. endm
  55. endds   macro
  56. _DATA   ends
  57.         endm
  58. endif
  59.  
  60. pseg    macro  name
  61. if monocode
  62. makeseg _TEXT, 'CODE'
  63.         assume cs:_TEXT
  64. else
  65. makeseg cc_text, 'CODE'
  66.         assume  cs:cc_text
  67. endif
  68. endm
  69.  
  70. endps  macro  name
  71. if monocode
  72. _TEXT   ends
  73. else
  74. cc_text ends
  75. endif
  76. endm
  77.  
  78. prolog  macro name, local
  79.         public  _&name
  80.  
  81. if multicode
  82. _&name  proc far
  83. else
  84. _&name  proc near
  85. endif
  86.  
  87.         push    Abp
  88.         mov     Abp, Asp
  89.         sub     Asp, local
  90.         push    Adi
  91.         push    Asi
  92.  
  93. if _32bit
  94.         push    Abx
  95.         push    es
  96. endif
  97.  
  98. if multidata
  99.         push    ds
  100. endif
  101. endm
  102.  
  103. endlog  macro name
  104. if multidata
  105.         pop     ds                
  106. endif
  107.    
  108. if _32bit
  109.         pop     es
  110.         pop     Abx               
  111. endif
  112.  
  113.         pop     Asi
  114.         pop     Adi
  115.         mov     Asp, Abp
  116.         pop     Abp
  117.         ret
  118. _&name  endp
  119. endm
  120.  
  121. isrprolog macro name, variable
  122.         public _&name
  123.  
  124. _&name  proc   far
  125. if _32bit
  126.         push   gs
  127.         push   fs
  128. endif
  129.         push   es
  130.         push   ds
  131.         push   ss
  132.         push   Aax
  133.         push   Abx
  134.         push   Acx
  135.         push   Adx
  136.         push   Asp
  137.         push   Abp
  138.         push   Adi
  139.         push   Asi
  140. if _32bit
  141.         mov    ax, cs
  142.         xor    ax, 18h
  143.         mov    ds, ax
  144.         mov    es, ax
  145. else
  146.         mov    ax, SEG variable
  147.         mov    ds, ax
  148.         mov    es, ax
  149. endif
  150. endm
  151.  
  152. isrendlog macro name
  153.         pop    Asi
  154.         pop    Adi
  155.         pop    Abp
  156.         pop    Asp
  157.         pop    Adx
  158.         pop    Acx
  159.         pop    Abx
  160.         pop    Aax
  161.         pop    ss
  162.         pop    ds
  163.         pop    es
  164. if _32bit
  165.         pop    fs
  166.         pop    gs
  167.         iretd
  168. else
  169.         iret
  170. endif
  171.  
  172. _&name        endp
  173. endm
  174.  
  175. extern  macro name, size
  176.    ifidn <&size>,<c_integer>   ;native C integer
  177. if _32bit               
  178.       extrn _&name:dword    ;32 bits MetaWare or Watcom 386 compilers
  179. else   
  180.       extrn _&name:word     ;16 bits for real mode DOS compilers
  181. endif
  182.    else
  183.    ifidn <&size>,<c_farptr>  ;segmented far C pointer
  184. if _32bit
  185.       extrn _&name:fword     ;48 bits for MetaWare or Watcom 386
  186. else   
  187.       extrn _&name:dword     ;32 bits for real mode DOS compilers
  188. endif
  189.    else
  190.    ifidn <&size>,<c_nearptr> ;offset for near C pointer
  191. if _32bit
  192.       extrn _&name:dword     ;32 bits for MetaWare or Watcom 386
  193. else   
  194.       extrn _&name:word      ;16 bits for real mode DOS compilers
  195. endif
  196.    else
  197.    ifidn <&size>,<c_realptr> ;segmented real mode DOS address
  198.       extrn _&name:dword     ;always 32 bits regardless of compiler
  199.    else
  200.    ifidn <&size>,<c_farproc> ;far C function
  201.       extrn _&name:FAR
  202.    else
  203.    ifidn <&size>,<c_nearproc>;near C function
  204.       extrn _&name:NEAR
  205.    else
  206.    ifidn <&size>,<c_proc>    ;far or near (model dependent) C function
  207. if multicode
  208.       extrn _&name:FAR       ;32/48 bits depending on 16/32 bit compiler
  209. else
  210.       extrn _&name:NEAR      ;always 32 bits regardless of compiler
  211. endif
  212.    else
  213.    extrn _&name:&size         ;use the size specified to macro
  214.    endif
  215.    endif
  216.    endif
  217.    endif
  218.    endif
  219.    endif
  220.    endif
  221.    name  equ _&name  ;always alias "name" with a prepended underscore
  222. endm
  223.  
  224. extern  clock_x,            c_integer
  225. extern  UpdateClock,        c_proc
  226.  
  227. ;
  228. ; Name:         NewTimerISR()
  229. ;
  230. ; Function:     Replaces default timer interrupt handler; chains to
  231. ;               default handler which has been revectored to INT 90h.
  232. ;               Upon regaining control, NewTimerISR() updates a string
  233. ;               with the current time whenever the seconds component 
  234. ;               changes and then calls a routine to update the graphics 
  235. ;               window.
  236. ;
  237.                 pseg  _TEXT
  238.                 isrprolog  NewTimerISR, clock_x
  239.  
  240.                 int   90h
  241.                 call  UpdateClock
  242.  
  243.                 isrendlog  NewTimerISR
  244.  
  245.                 endps _TEXT
  246.                 END
  247.  
  248.  
  249.