;       SCCSID = @(#)qsavreg.asm        6.1 90/11/18
page ,132

; ****************************************************************************
; *                                                                          *
; *                       IBM/Microsoft Confidential                         *
; *                                                                          *
; *                 Copyright (c) IBM Corporation  1987, 1990                *
; *                 Copyright (c) Microsoft Corp.  1987, 1990                *
; *                           All Rights Reserved                            *
; *                                                                          *
; ****************************************************************************
;
;/********************** START OF SPECIFICATIONS **********************/
;/*                                                                   */
;/* SOURCE FILE NAME: qsavreg.asm                                     */
;/*                                                                   */
;/* DESCRIPTIVE NAME: assembler interfaces for Queues API which       */
;/*                   save/restore registers                          */
;/*                                                                   */
;/* COPYRIGHT: (TOP MODULE ONLY)                                      */
;/*                                                                   */
;/* STATUS: RELEASE 1 LEVEL 0                                         */
;/*                                                                   */
;/* FUNCTION:                                                         */
;/*                                                                   */
;/* NOTES:                                                            */
;/*    DEPENDENCIES:                                                  */
;/*    RESTRICTIONS:                                                  */
;/*    PATCH LABEL: (TOP MODULE ONLY)                                 */
;/*                                                                   */
;/* Change History:                                                   */
;/*   MDLL  01/10/94 BJN Page Tune segments for Merged DLL.           */
;/*
;/* ENTRY POINTS:                                                     */
;/*                     PUSHALL_DS                                    */
;/*                     POPALL                                        */
;/*                                                                   */
;/* INTERNAL REFERENCES:                                              */
;/*    ROUTINES:                                                      */
;/*                                                                   */
;/* EXTERNAL REFERENCES:                                              */
;/*                                                                   */
;/*********************** END OF SPECIFICATIONS ***********************/

;MDLL .286p

;
;       Definitions for interfaces to default C Data
;
include dc1segs.inc                                                     ;MDLL

        ASSUME ds:SHRDATA                                               ;MDLL

CODE_TUNE1 SEGMENT WORD PUBLIC 'CODE' USE16                             ;MDLL
        ASSUME  CS:CODE_TUNE1                                           ;MDLL

;/********************** START OF SPECIFICATIONS *********************/
;/*                                                                  */
;/* SUBROUTINE NAME: PUSHALL_DS                                      */
;/*                                                                  */
;/* DESCRIPTIVE NAME: Push All, Set DS                               */
;/*                                                                  */
;/* FUNCTION: Pushes all registers which may be corrupted by C,sets  */
;/*           DS to the DGROUP of the DLL                            */
;/*                                                                  */
;/* NOTES:                                                           */
;/*                                                                  */
;/* ENTRY POINT: PUSHALL_DS                                          */
;/*    LINKAGE:  near, pl2                                           */
;/*                                                                  */
;/* INPUT:                                                           */
;/*                                                                  */
;/* EXIT-NORMAL:        N/A                                          */
;/*                                                                  */
;/* EXIT-ERROR:         N/A                                          */
;/*                                                                  */
;/* EFFECTS:    "pops" return address off stack, saves BX,CX,DX,     */
;/*             DS, and ES, pushes return address back onto stack,   */
;/*             set DS = to DGROUP, and returns; AX is corrupted     */
;/*                                                                  */
;/* INTERNAL REFERENCES:                                             */
;/*    ROUTINES:                                                     */
;/*                                                                  */
;/* EXTERNAL REFERENCES:                                             */
;/*    ROUTINES:                                                     */
;/*                                                                  */
;/*********************** END OF SPECIFICATIONS **********************/

        public  PUSHALL_DS                ;declaration for external reference
PUSHALL_DS PROC NEAR
        assume  cs:CODE_TUNE1                                           ;MDLL

        pop     ax                      ;ax = return offset

        push    bx                      ;place bx on stack
        push    cx                      ;save
        push    dx                      ;  the
        push    ds                      ;    register
        push    es                      ;      set

        push    ax                      ;place return offset on stack

        mov     ax,SHRDATA              ;move DGROUP                    ;MDLL
        mov     ds,ax                   ;  into DS

        ret                             ;return to calling routine

PUSHALL_DS ENDP

;/********************** START OF SPECIFICATIONS *********************/
;/*                                                                  */
;/* SUBROUTINE NAME: POPALL                                          */
;/*                                                                  */
;/* DESCRIPTIVE NAME: Pop All                                        */
;/*                                                                  */
;/* FUNCTION: Pops all registers which were saved to prevent         */
;/*           corruption by C code                                   */
;/*                                                                  */
;/* NOTES:                                                           */
;/*                                                                  */
;/* ENTRY POINT: POPALL                                              */
;/*    LINKAGE:  near, pl2                                           */
;/*                                                                  */
;/* INPUT:      DW      return code                                  */
;/*                                                                  */
;/* EXIT-NORMAL:        N/A                                          */
;/*                                                                  */
;/* EXIT-ERROR:         N/A                                          */
;/*                                                                  */
;/* EFFECTS:    reverses the effects of PUSHALL/PUSHALL_DS           */
;/*             pops the return address off the stack, exchanges     */
;/*             with the indicated old registers on stack, sets      */
;/*             AX to the return code and restores the remaining     */
;/*             registers                                            */
;/*                                                                  */
;/* INTERNAL REFERENCES:                                             */
;/*    ROUTINES:                                                     */
;/*                                                                  */
;/* EXTERNAL REFERENCES:                                             */
;/*    ROUTINES:                                                     */
;/*                                                                  */
;/*********************** END OF SPECIFICATIONS **********************/

        public  POPALL                  ;declaration for external reference
POPALL  PROC NEAR
        assume  cs:CODE_TUNE1                                           ;MDLL

        pop     bx                      ;bx = return offset

        push    bp                      ;save base pointer
        mov     bp,sp                   ;reposition base pointer
        xchg    bx,[bp+12]              ;swap return offset with old bx
        pop     bp                      ;restore base pointer

        pop     ax                      ;set return code

        pop     es                      ;restore
        pop     ds                      ;  register
        pop     dx                      ;    set
        pop     cx                      ;

        ret                             ;return

POPALL  ENDP

CODE_TUNE1 ENDS                                                         ;MDLL
        END
