TIP: Click on subject to list as thread! ANSI
echo: 80xxx
to: BRIAN MCCLOUD
from: DAVID KIRSCHBAUM
date: 1997-05-19 11:07:00
subject: Bosskey.Asm - sysreq.

MB>>From: Mervyn Baldwin 
 > According to my reference ("PC Interrupts" by Ralf Brown & Jim
 > Kyle), all registers except for CS:IP get destroyed on return
 > from an int 2Eh... however you could do something like this:
 > ******
 > .DATA
 > SaveSS  dw      ?
 > SaveSP  dw      ?
 > SaveBP  dw      ?
 > .CODE
 > SafeInt2Eh:
 >         MOV     [SaveSS], SS
 >         MOV     [SaveSP], SP
 >         MOV     [SaveBP], BP
 >         INT     2Eh
 >         CLI     ; make sure the restoration of the registers in
 > uninterrupted
 >         MOV     AX, SEG _DATA
 >         MOV     DS, AX
 >         MOV     SP, [SaveSP]
 >         MOV     SS, [SaveSS]
 >         MOV     BP, [SaveBP]
 >         STI     ; registers restored, so interrupts OK
 >         RET
 > ******
 > Normally you might PUSH registers to preserve them before an
 > interrupt, but since SS:SP is also destroyed, you have to take
 > different precautions.
 > ((Cloud))
To simplify even further, you could have SaveSS, SaveSP, SaveBP all in the 
Code segment (rather than in the _DATA segment).  In your example above, you 
have NOT saved the caller's DS and have effectively blown it away.  Doing it 
my way, you don't need to touch any segment registers.
.CODE
SaveSS  dw  0
SaveSP  dw  0
SaveBP  dw  0
SafeInt2Eh:
        MOV     CS:[SaveSS], SS
        MOV     CS:[SaveSP], SP
        MOV     CS:[SaveBP], BP
        INT     2Eh
        CLI     ; make sure the restoration of the registers is uninterrupted
        MOV     SP, CS:[SaveSP]
        MOV     SS, CS:[SaveSS]
        MOV     BP, CS:[SaveBP]
        STI     ; registers restored, so interrupts OK
        RET
---
---------------
* Origin: Toad Hall (1:3634/2.4)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.