home *** CD-ROM | disk | FTP | other *** search
- Inline(
- {;****************************************************************************;}
- {; S T A Y S A V E . I N C ;}
- {;****************************************************************************;}
- {;Version 4.15}
- {;}
- {; This Inline routine will save the regs and Stack for Stay resident programs.}
- {; It restores DS and SS from the previously saved integer constants "OurDseg"}
- {; and "OurSSeg". DS is restored from the Turbo Initialization Savearea.}
- {; Author: Copyr. 1985, 1986}
- {; Lane Ferris}
- {; - The Hunter's Helper -}
- {; Distributed to the Public Domain for use without profit.}
- {; Original Version 5.15.85}
- $FA { CLI ; Stop all interrupts}
- /$2E { CS:}
- /$80/$0E/>STATUS/<INUSE { Or by [<Status],<InUse ; Set Active bit}
- {; Switch the SS:Sp reg pair over to ES:Si}
- {; Put Turbo's Stack pointers into SS:Sp}
- /$2E { CS:}
- /$8C/$1E/>USRDSEG { Mov [>UsrDSeg],DS ; Save Usr DataSegment}
- /$2E { CS:}
- /$8C/$16/>USRSSEG { Mov [>UsrSSeg],SS ; Save Usr Stack Segment}
- /$2E { CS:}
- /$89/$26/>USRSPTR { Mov [>UsrSPtr],Sp ; Save Usr Stack Ptr}
- {; Stack User interrupted pgm regs for Exit.}
- {; These are the original interrupt process regs}
- {; that must be returned on interrupt return}
- /$2E { CS:}
- /$8E/$1E/>OURDSEG { Mov DS,[>OurDseg] ; Get Turbo Stack pointer from DataSegment}
- /$2E { CS:}
- /$8E/$16/>OURSSEG { Mov SS,[>OurSSeg]}
- /$8B/$26/$74/$01 { Mov Sp,[$174] ; Sp set by code at $B2B in Turbo initialization}
- /$55 { Push Bp}
- /$50 { Push Ax}
- /$53 { Push Bx}
- /$51 { Push Cx}
- /$52 { Push Dx}
- /$56 { Push Si}
- /$57 { Push Di}
- /$06 { Push Es}
- {; Save the InDOS stack to avoid recursion crashes (Writeln).}
- {; Setup destination to Turbo Stack}
- /$89/$E7 { Mov Di,Sp ;Dest is our stack}
- /$4F { Dec Di ;Back off current used word}
- /$4F { Dec Di}
- /$2E { CS:}
- /$8C/$D0 { Mov Ax,SS ;Turbo stack is destination}
- /$8E/$C0 { Mov ES,Ax}
- {; Setup source from DOS Indos primary stack}
- /$2E { CS:}
- /$8E/$1E/>DOSSSEG { Mov DS,[>DosSSeg] ; Source is DOS Indos primary stack}
- /$2E { CS:}
- /$8B/$36/>DOSSPTR { Mov Si,[>DosSptr] ; DOS primary stack offset}
- /$B9/$40/$00 { Mov Cx,$40}
- /$2E { CS:}
- /$89/$0E/>DOSSSIZ { Mov [>DosSsiz],Cx ;remember the stack word size}
- /$4E { Dec Si ;point last word on stack}
- /$4E { Dec Si}
- /$89/$E0 { Mov Ax,Sp ;Get stack pointer higher to avoid}
- /$29/$C8 { Sub Ax,Cx ;overwriting during enabled REP functions}
- /$29/$C8 { Sub Ax,Cx}
- /$89/$C4 { Mov Sp,Ax}
- /$FD { STD ;Move like Pushes on stack}
- /$F2/$A5 { Rep Movsw ;Move users stack to our own}
- /$89/$FC { Mov Sp,Di ;Update our stack pointer to available word.}
- /$FC { Cld}
- /$2E { CS:}
- /$8E/$1E/>OURDSEG { Mov DS,[>OurDSeg] ; Setup Turbo Data Segment Pointer}
- /$FB { STI ; Enable Interrupts}
- {;...........................................................................}
- );
-