From ceaaaea8388a4fab985e39880c488087bfc23fc7 Mon Sep 17 00:00:00 2001 From: "E. C. Masloch" Date: Sun, 19 May 2024 23:12:39 +0200 Subject: [PATCH] sys: fix, work on DOS versions that clobber di in int 25h/26h Running on DR-DOS v7.03, the int 25h call zeroes di leading to a crash here when di is expected to preserve the stack pointer. So push di twice and pop it twice. The second pop always gets the saved sp, regardless of whether int 21h or int 25h/26h are used. Refer to https://github.com/SvarDOS/edrdos/issues/57#issuecomment-2119360035 --- country | 2 +- share | 2 +- sys/sys.c | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/country b/country index 13587a32..a170a550 160000 --- a/country +++ b/country @@ -1 +1 @@ -Subproject commit 13587a32d6fda6cf1a1ce9bd9c3da7d3ae5a8dd5 +Subproject commit a170a5508430cd861754b9064d7e1a081d8b3101 diff --git a/share b/share index 47f3d425..f2efe19f 160000 --- a/share +++ b/share @@ -1 +1 @@ -Subproject commit 47f3d42527256fa46a00fe84cdb46d90f2e66f50 +Subproject commit f2efe19f234eb752de57c633c5147d7e060d9cfa diff --git a/sys/sys.c b/sys/sys.c index 5ad0b48e..ca2a0d2a 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -122,7 +122,12 @@ int int86(int ivec, union REGS *in, union REGS *out) { /* must save sp for int25/26 */ asm("mov %5, (1f+1); jmp 0f; 0:push %%ds; mov %%di, %%dx; mov %%sp, %%di;" - "1:int $0x00; mov %%di, %%sp; pop %%ds; sbb %0, %0" : + "push %%di; push %%di;" + /* push twice to work both for int 25h/26h and int 21h */ + "1:int $0x00; pop %%di; pop %%di;" + /* second pop always reads the correct SP value. + the first pop may read the FL left on stack. */ + "mov %%di, %%sp; pop %%ds; sbb %0, %0" : "=r"(out->x.cflag), "=a"(out->x.ax), "=b"(out->x.bx), "=c"(out->x.cx), "=d"(out->x.dx) : "q"((unsigned char)ivec), "a"(in->x.ax), "b"(in->x.bx),