home *** CD-ROM | disk | FTP | other *** search
- {****************************************************************************}
- { S T A Y R S T R . I N C }
- { }
- { This is the StayRstr.Inc file included above }
- { Separate the code out into a file or replace the $I StayRstr.310 }
- { statement above with this code. }
- {****************************************************************************}
-
- { Inline Code to restore the stack and regs moved to the Turbo Resident
- Program Stack to allow re-entrancy into the Dos Code for I/O and
- recursion from built-in Turbo functions.
-
- ; Arthor: L.H. Ferris
-
- ; Distributed to the Public Domain for use without profit.
- ; Original Version 5.15.85
-
- ;----------------------------------------------------------------------;
- ; Restore the Dos Regs and Stack
- ;----------------------------------------------------------------------;
-
- ; On entry the Stack will already contain:
- ;
- ; 1) Bottom of Dos Stack Ptr
- ; 2) Dos Flags
- ; 3) Dos Code Segment
- ; 4) Dos Instruction Ptr
- ; 5) Dos Base Pointer
- ; 6) Dos Original Stack Ptr
- }
- inline(
-
- $BD/Regs/ {Mov Bp,offset REGS}
- $2E/$8B/$46/$00/ {CS:Mov Ax,[Bp+0]}
- $2E/$8B/$5E/$02/ {Cs:Mov Bx,[Bp+2]}
- $2E/$8B/$4E/$04/ {CS:Mov Cx,[Bp+4]}
- $2E/$8B/$56/$06/ {CS:Mov Dx,[Bp+6]}
-
- $2E/$8B/$76/$0A/ {CS:Mov Si,[Bp+A]}
- $2E/$8B/$7E/$0C/ {CS:Mov Di,[Bp+C]}
- $2E/$8E/$5E/$0E/ {CS:Mov DS,[Bp+E]}
- $2E/$8E/$46/$10/ {CS:Mov ES,[Bp+10]}
- $2E/$FF/$76/$12/ {Push Cs:[Bp+12]}
- $9D/ {Popf}
-
- { If [Cs:InUse]:= True, then dont restore the stack. This program is }
- { being recursive. Else restore Dos Stack and Program Entry registers }
-
- $2E/$80/$3E/Inuse/$01/ {Cmp byte ptr Cs:[Inuse],1 }
- $74/$23/ {Je ReCurOut }
-
- $FA / { Cli ; Stop all interrupts }
-
- { Move 40 words of our stack back to Dos Stack }
-
- $5E/ {Pop Si Bottom of Dos Stack }
- $B9/>$0028/ {Mov Cx,40 Return 40 Dos Stack Words }
- $2E/$8E/$06/DosSSeg/ {Mov ES,Cs:DosSSeg Get Dos StackSegment }
- {Restack:}
- $4E/$4E/ {Dec Si/Dec Si Backup Dos Stack }
- $26/$8F/$04/ {Pop Es:[Si] Dos Stack := Our Stack }
- $E2/$F9/ {Loop to Restack }
- $89/$F5/ {Mov Bp,Si Save Dos Sp across Pops }
-
-
- $07/ {Pop Es }
- $1F/ {Pop Ds }
- $5F/ {Pop Di }
- $5E/ {Pop Si }
- $5A/ {Pop Dx }
- $59/ {Pop Cx }
- $5B/ {Pop Bx }
- $44/$44/ {Inc sp/Inc sp Thow old Ax value away }
-
- $89/$EC/ {Mov Sp,Bp Setup Dos Stack Ptr }
- $2E/$8E/$16/DosSSeg/ {Mov SS,Cs:DosSSeg Give back Dos Stack }
-
- {RecurOut Clean up the Stack }
-
- $5D/ {Pop Bp Throw away old dos Sp }
-
- $BD/Regs/ {Mov Bp,offset REGS }
- $2E/$FF/$76/$12/ {Push Cs:[Bp+12] }
- $9D/ {Popf }
- $5D/ {Pop Bp Retrieve old BP }
-
- $FB/ {Sti Enable interrupts }
- $CA/$02/$00 {Ret Far 002 }
- );
- {.......................................................................}