entry.asm: fix Critical Error caller 386 registers

Fixes #210, fixes #212
This commit is contained in:
E. C. Masloch 2025-08-22 16:13:33 +02:00 committed by Kenneth J Davis
parent 032523a2bb
commit 6094067574
2 changed files with 26 additions and 3 deletions

View File

@ -136,6 +136,8 @@ irp_hi equ 26
%macro Protect386Registers 0
%endmacro
%assign Size386Registers 0
%macro RestoreSP 0
mov sp, bp
%endmacro
@ -151,8 +153,10 @@ irp_hi equ 26
push gs
%endmacro
%assign Size386Registers 4
%macro RestoreSP 0
lea sp, [bp-4]
lea sp, [bp - Size386Registers]
%endmacro
%macro Restore386Registers 0
@ -176,8 +180,10 @@ irp_hi equ 26
pop dx
%endmacro
%assign Size386Registers 6
%macro RestoreSP 0
lea sp, [bp-6]
lea sp, [bp - Size386Registers]
%endmacro
%macro Restore386Registers 0

View File

@ -611,6 +611,8 @@ CritErr05:
mov bp,sp
push si
push di
Protect386Registers
;
; Get parameters
;
@ -659,6 +661,13 @@ CritErr05:
;
cld
cli
Protect386Registers
; ecm: The extended stack frame must be restored here
; in case the response isn't Abort. The int 21h handler
; will expect the extended stack frame to be still
; intact, but the stack written by the int 24h (even
; only the int instruction) will have overwritten it.
mov bp, [cs:_DGROUP_]
mov ds,bp
mov ss,bp
@ -672,7 +681,13 @@ CritErr05:
pop word [es:PSP_USERSP]
pop word [es:PSP_USERSS]
mov bp, sp
mov ah, byte [bp+4+4] ; restore old AH from nFlags
mov ah, byte [bp + 4 + 4 + Size386Registers]
; restore old AH from nFlags
; ecm: One 4 is the displacement of nFlags from the
; usual bp, the other 4 accounts for the si and di
; on the stack, the Size386Registers is added to
; skip the fs and gs (OpenWatcom 386 build) or high
; words that are a part of the stack frame, if any.
sti ; Enable interrupts
;
; clear flags
@ -715,6 +730,8 @@ CritErr30:
CritErrExit:
xor ah,ah ; clear out top for return
Restore386Registers
pop di
pop si
pop bp