home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / VDH / VDHCDLL.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  7KB  |  190 lines

  1. ;*DDK*************************************************************************/
  2. ;
  3. ; COPYRIGHT (C) Microsoft Corporation, 1989
  4. ; COPYRIGHT    Copyright (C) 1995 IBM Corporation
  5. ;
  6. ;    The following IBM OS/2 WARP source code is provided to you solely for
  7. ;    the purpose of assisting you in your development of OS/2 WARP device
  8. ;    drivers. You may use this code in accordance with the IBM License
  9. ;    Agreement provided in the IBM Device Driver Source Kit for OS/2. This
  10. ;    Copyright statement may not be removed.;
  11. ;*****************************************************************************/
  12.         PAGE    60,132
  13.         TITLE   VDHCDLL.ASM -- Dynlink Register Preservation Routines
  14.  
  15. ;/*****************************************************************************
  16. ;*
  17. ;* SOURCE FILE NAME = VDHCDLL.ASM
  18. ;*
  19. ;* DESCRIPTIVE NAME = Dynlink Register Preservation Routines 
  20. ;*
  21. ;*
  22. ;* VERSION      V2.0
  23. ;*
  24. ;* DATE         
  25. ;*
  26. ;* DESCRIPTION  Dynlink Register Preservation Routines 
  27. ;*              This module contains register save and restore routines
  28. ;*              that are called by each top-level VDH routine
  29. ;*              immediately following entry and imediately prior to
  30. ;*              exit, respectively.
  31. ;*
  32. ;* FUNCTIONS    _SaveRegs, _RestoreRegs
  33. ;*
  34. ;* NOTES        NONE
  35. ;*             
  36. ;* STRUCTURES   NONE
  37. ;*
  38. ;* EXTERNAL REFERENCES  NONE
  39. ;*
  40. ;* EXTERNAL FUNCTIONS
  41. ;*
  42. ;*              NONE
  43. ;*
  44. ;* CHANGE ACTIVIY =
  45. ;*   DATE      FLAG       APAR    CHANGE DESCRIPTION
  46. ;*   --------  ---------- -----   --------------------------------------
  47. ;*   mm/dd/yy  @Vr.mpppxx xxxxx   xxxxxxx
  48. ;****************************************************************************/
  49.  
  50. .286p
  51.  
  52.  
  53. ;/*
  54. ;** Include files                                                             
  55. ;*/
  56.  
  57. include struc.inc                          ; Structured assembly macros
  58.  
  59.  
  60. ;/*
  61. ;** Local variables                                       
  62. ;*/
  63.  
  64. SavedBX    equ WORD PTR [bp+6]             ; Storage for original BX register
  65. SavedCX    equ WORD PTR [bp+8]             ; Storage for original CX register
  66. SavedDX    equ WORD PTR [bp+10]            ; Storage for original DX register
  67. SavedES    equ WORD PTR [bp+12]            ; Storage for original ES register
  68. SavedFLAGS equ WORD PTR [bp+14]            ; Storage for original flag register
  69.  
  70.  
  71. R2CSEG  SEGMENT  WORD  PUBLIC  'CODE'
  72. ASSUME  CS:R2CSEG
  73.  
  74.  
  75. ;/****************************************************************************
  76. ;*
  77. ;*  SUBROUTINE NAME: SaveRegs                                         
  78. ;*                                                                    
  79. ;*  DESCRIPTIVE NAME: Save registers and flags                        
  80. ;*                                                                    
  81. ;*  FUNCTION: SaveRegs is the first call made by each of the toplevel 
  82. ;*            VDH entry points.                                       
  83. ;*                                                                    
  84. ;*  ENTRY POINT: SaveRegs                                             
  85. ;*    LINKAGE:   CALL FAR                                             
  86. ;*                                                                    
  87. ;*  INPUT: NONE                                                       
  88. ;*                                                                    
  89. ;*  EXIT-NORMAL: Registers and flags are saved on the stack           
  90. ;*                                                                    
  91. ;*  INTERNAL REFERENCES:                                              
  92. ;*    ROUTINES: NONE                                                  
  93. ;*                                                                    
  94. ;*  EXTERNAL REFERENCES:                                              
  95. ;*    ROUTINES: NONE                                                  
  96. ;*                                                                    
  97. ;****************************************************************************/
  98.  
  99. PUBLIC    _SaveRegs
  100. _SaveRegs  PROC  FAR
  101.  
  102.  
  103. ;/*
  104. ;** ENTRY: SS:SP = NextIP  NextCS     
  105. ;** EXIT:  SS:SP = NextIP NextCS SavedBX SavedCX SavedDX SavedES SavedFLAGS 
  106. ;*/
  107.  
  108.      sub  sp, 10                   ; Allocate temporary storage on stack
  109.      push bp
  110.      mov  bp, sp
  111.  
  112.      mov ax, [bp+12]               ; Move far return address to top of the stack
  113.      mov [bp+2], ax
  114.      mov ax, [bp+14]
  115.      mov [bp+4], ax
  116.  
  117.      mov SavedBX, bx               ; Now save the registers
  118.      mov SavedCX, cx
  119.      mov SavedDX, dx
  120.      mov SavedES, es
  121.      pushf
  122.      pop SavedFLAGS
  123.  
  124.      pop bp
  125.  
  126.      ret
  127.  
  128. _SaveRegs  ENDP
  129.  
  130. ;/****************************************************************************
  131. ;*                                                                     
  132. ;*  SUBROUTINE NAME: RestoreRegs                                       
  133. ;*                                                                     
  134. ;*  DESCRIPTIVE NAME: Restore registers and flags                      
  135. ;*                                                                     
  136. ;*  FUNCTION: RestoreRegs is the last call made by each of the toplevel
  137. ;*            VDH entry points, prior to returning.                    
  138. ;*                                                                     
  139. ;*  ENTRY POINT: RestoreRegs                                           
  140. ;*    LINKAGE:   CALL FAR                                              
  141. ;*                                                                     
  142. ;*  INPUT: NONE                                                        
  143. ;*                                                                     
  144. ;*  EXIT-NORMAL: Registers and flags are restored.                     
  145. ;*                                                                     
  146. ;*  INTERNAL REFERENCES:                                               
  147. ;*    ROUTINES: NONE                                                   
  148. ;*                                                                     
  149. ;*  EXTERNAL REFERENCES:                                               
  150. ;*    ROUTINES: NONE                                                   
  151. ;*                                                                     
  152. ;****************************************************************************/
  153.  
  154. PUBLIC       _RestoreRegs
  155. _RestoreRegs  PROC  FAR
  156.  
  157.  
  158. ;/*
  159. ;**   ENTRY: SS:SP = NextIP NextCS SavedBX SavedCX SavedDX SavedES SavedFLAGS  
  160. ;**   EXIT:  SS:SP = NextIP NextCS                                             
  161. ;*/
  162.  
  163.      push bp
  164.      mov  bp, sp
  165.  
  166.      push SavedFLAGS
  167.      popf
  168.  
  169.      mov bx, SavedBX               ; Restore registers
  170.      mov cx, SavedCX
  171.      mov dx, SavedDX
  172.      verr SavedES
  173.      .if < nz >
  174.         push 0
  175.         pop  es                    ; If     selector, replace with zero
  176.      .else
  177.         mov es, SavedES
  178.      .endif
  179.  
  180.      pop  bp
  181.  
  182.      ret 10
  183.  
  184. _RestoreRegs  ENDP
  185.  
  186.  
  187. R2CSEG  ENDS
  188.  
  189. END
  190.