> Hello David, and/or Mervyn,
DK>> .CODE
DK>> SaveSS dw 0
DK>> SaveSP dw 0
DK>> SaveBP dw 0
DK>> SafeInt2Eh:
DK>> MOV CS:[SaveSS], SS
DK>> MOV CS:[SaveSP], SP
DK>> MOV CS:[SaveBP], BP
DK>> INT 2Eh
DK>> CLI ; make sure the restoration of the registers is uninterrupted
DK>> MOV SP, CS:[SaveSP]
DK>> MOV SS, CS:[SaveSS]
DK>> MOV BP, CS:[SaveBP]
DK>> STI ; registers restored, so interrupts OK
DK>> RET
> Why is it not just as important to CLI and STI when saving the registers?
> Kind regards, Barry
Because _saving_ them does not _change_ them.
But when it comes time to actually _change_ where your stack pointer is
aiming at .. well, you have to be a little more careful. You wouldn't want
some other process to come in and try to use the stack just at the instant
when you'd changed the SP but not the SS, would you? Murphy depends on
assumptions like that :-)
---
---------------
* Origin: Toad Hall (1:3634/2.4)
|