00001         subttl  emstack.asm - Emulator Stack Management Macros
00002         page
00003 ;***
00004 ;emstack.asm - Emulator Stack Management Area
00005 ;
00006 ;        Microsoft 
Confidential
00007 ;        
Copyright (c) Microsoft Corporation 1991
00008 ;        All Rights Reserved
00009 ;
00010 ;Purpose:
00011 ;       Handles emulator stack.
00012 ;
00013 ;Revision History:
00014 ;
00015 ; []    09/05/91  TP    Initial 32-bit version.
00016 ;
00017 ;*******************************************************************************
00018 
00019 
00020 ;POPSTret:  pops the stack and returns.  Uses esi.
00021 
00022 POPSTret        macro   reg
00023         local   stackwrap
00024 IFB     <reg>
00025         mov     esi,EMSEG:[CURstk]
00026 _popreg equ     esi
00027 ELSE
00028 _popreg equ     reg
00029 ENDIF
00030         mov     EMSEG:[_popreg].bTag,bTAG_EMPTY
00031         NextStackElem   _popreg,stackwrap
00032         mov     EMSEG:[CURstk],_popreg
00033         ret
00034 
00035 Wrap&stackwrap:
00036         mov     EMSEG:[CURstk],BEGstk
00037         ret
00038         endm
00039 
00040 ;NextStackElem:  Given pST(0) = [CURstk] in reg, returns pST(1)
00041 ;Requires NextStackWrap macro with same arguments
00042 
00043 NextStackElem   macro   reg,stackwrap
00044         cmp     reg,INITstk                     ;JWM
00045         jae     Wrap&stackwrap
00046         add     reg,Reg87Len
00047 Cont&stackwrap:
00048         endm
00049 
00050 NextStackWrap   macro   reg,stackwrap
00051 Wrap&stackwrap:
00052         mov     reg,BEGstk                      ;JWM
00053         jmp     Cont&stackwrap
00054         endm
00055 
00056 
00057 ;PrevStackElem:  Given pST(0) = [CURstk] in reg, returns new pST(0) 
00058 ;after a push onto on the stack.
00059 ;Requires PrevStackWrap macro with same arguments
00060 
00061 PrevStackElem   macro   reg,stackwrap
00062         cmp     reg,BEGstk                      ;JWM
00063         jbe     Wrap&stackwrap
00064         sub     reg,Reg87Len
00065 Cont&stackwrap:
00066         endm
00067 
00068 PrevStackWrap   macro   reg,stackwrap
00069 Wrap&stackwrap:
00070         mov     reg,INITstk                     ;JWM
00071         jmp     Cont&stackwrap
00072         endm