home *** CD-ROM | disk | FTP | other *** search
- {****************************************************************************}
- { S T A Y S A V E . I N C }
- { }
- { This is the Staysave.Inc file included above }
- { }
- { Separate the code out into a file or replace the $I Staysave.320 }
- { statement above with this code. }
- {****************************************************************************}
-
- {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". This is important since Dos is not re-entrant and any attempt
- to use Interrupt I/O services will clobber the very stack on which the
- Resident Turbo program just saved its regs. Thus, on the final return, you
- and Toto will end up somewhere other than Kansas and without your Ruby Reds.
- }
-
- { Arthor: Lane Ferris
- - The Hunter's Helper -
-
- Distributed to the Public Domain for use without profit.
- Original Version 5.15.85
- }
- { On entry the Stack will already contain: }
- { 1) Sp for Dos }
- { 2) Bp for Dos }
- { 3) Ip for Dos }
- { 4) Cs for Dos }
- { 5) Flags for Dos }
- Inline (
-
- { The following routine avoids the overhead of saving the DOS stack }
- { when the INT 16 function was not for a character request. This happens }
- { often (every four chars) as DOS checks on ^S/^Q/^C/Keypressed ad.nausea }
-
- $80/$FC/$00/ {Cmp Ah,00 If Char request, }
- $74/$07/ {Je ChrRqst enter Staysave code }
- $5D/$5D/ {Pop Bp/Pop Bp Restore Bp }
- $2E/
- $FF/$2E/User_IntIP/ {Jmp Far Cs:[User_IntIp] }
-
- {ChrRqst: }
- $FA / { Cli Stop all interrupts }
- { Bp and Sp aready saved at Begin Stmt }
- $55/ {Push Bp Save again for Regpak }
- $BD/Regs/ {Mov Bp,offset REGS}
- $2E/$89/$46/$00/ {CS:Mov [Bp+0],AX}
- $2E/$89/$5E/$02/ {Cs:Mov [Bp+2],Bx}
- $2E/$89/$4E/$04/ {CS:Mov [Bp+4],CX}
- $2E/$89/$56/$06/ {CS:Mov [Bp+6],DX}
- $2E/$8F/$46/$08/ {Pop Cs:[Bp+8] Fetch Bp from stack }
- $2E/$89/$76/$0A/ {CS:Mov [Bp+A],SI}
- $2E/$89/$7E/$0C/ {CS:Mov [Bp+C],DI}
- $2E/$8C/$5E/$0E/ {CS:Mov [Bp+E],DS}
- $2E/$8C/$46/$10/ {CS:Mov [Bp+10],ES}
- $9C/ {PUSHF put Flags on stack to retrieve }
- $2E/$8F/$46/$12/ {POP Cs:[Bp+12]}
-
- { If Current SS := [OurSseg] or Inuse = True, then dont save the stack. }
- { This program is being recursive. }
-
- $2E/$80/$3E/Inuse/$01/ {Cmp Cs:[Inuse],1 }
- $74/$57/ {Je ReCurin -J-U-M-P- }
-
-
- $2E/$8C/$16/DosSSeg/ {Mov Cs:DosSSeg,SS Save Dos Stack Segment }
- $8C/$D6/ {Mov Si,SS If this is our Stack Seg }
- $8E/$C6/ {Mov Es,Si Get Dos StackSeg }
- $2E/$8E/$16/OurSSeg/ {Mov SS,Cs:OurSSeg Get our Stack segment }
- $2E/$8E/$1E/OurDseg/ {Mov Ds,Cs:Our_Ds Setup our Data Segment }
-
-
- $2E/$3B/$36/OurSSeg/ {Cmp Si,Cs:OurSSeg ..use current Stack ptr }
- $89/$E6/ {Mov Si,Sp ..value..else reset stack }
- $74/$05/ {Je $+5 ..to original Turbo stack }
- $3E/$8B/$36/$74/$01/ {Mov Si,Ds:[174] ..(cf. code at B2B 3.0x) }
-
- $87/$F4/ {Xchg Sp,Si Set new Stack Pointer }
- { Save Dos/User regs for Exit }
- $2E/$FF/$76/$00/ {Push [Bp+0] Save Ax }
- $2E/$FF/$76/$02/ {Push [Bp+2] Save Bx }
- $2E/$FF/$76/$04/ {Push [Bp+4] Save Cx }
- $2E/$FF/$76/$06/ {Push [Bp+6] Save Dx }
- {Push [Bp+8] Save Bp }
- $2E/$FF/$76/$0A/ {Push [Bp+A] Save Si }
- $2E/$FF/$76/$0C/ {Push [Bp+C] Save Di }
- $2E/$FF/$76/$0E/ {Push [Bp+E] Save Ds }
- $2E/$FF/$76/$10/ {Push [Bp+10] Save Es }
-
- { Now save 40 Words from the Dos Stack before performing any }
- { I/O or re-using the Dos stack }
-
- $B9/>$0028/ {Mov Cx,40 Save 40 Dos Stack words for Retn }
- {Restack:}
- $26/$FF/$34/ {Push Es:[Si] Our Stack := Dos Es:Si }
- $46/$46/ {Inc Si/Inc Si Get Next Dos Stack Word }
- $E2/$F9/ {Loop to Restack }
-
- $2E/$8E/$16/OurSSeg/ {Mov SS,Cs:OurSSeg Set up our Stack }
- $56/ {Push Si Save bottom of Dos Stack }
- $2E/$8C/$5E/$0E/ {Mov Cs:[Bp+E],Ds Set New Data Segmt in regs}
- {Recurin Jump here if Recursion }
- $FB {Sti Enable Interrupts }
-
- ) ;
- {...........................................................................}