diff --git a/include/cswap.h b/include/cswap.h index dc0c0221..4636f389 100644 --- a/include/cswap.h +++ b/include/cswap.h @@ -29,8 +29,6 @@ extern unsigned char far dosCMDNAME[128]; /*extern unsigned char far dosCMDTAIL[128];*/ #define dosCMDTAIL ((char far*)MK_FP(_psp, 0x80)) -extern word residentCS; - extern int cdecl XMSexec(void); #ifdef __WATCOMC__ @@ -38,6 +36,7 @@ typedef unsigned long xmsfunc(unsigned request, unsigned dx, void *si); #pragma aux xmsfunc = parm [ax] [dx] [si] modify [bx cx] extern xmsfunc far *far XMSdriverAdress; #elif defined(__GNUC__) +extern far void real_XMSexec(void); extern unsigned far *far XMSdriverAdress; static inline unsigned long XMSrequest(unsigned request, unsigned dx, void *si) { diff --git a/include/stuff.inc b/include/stuff.inc index bc9bb43b..c428ed7e 100644 --- a/include/stuff.inc +++ b/include/stuff.inc @@ -1,3 +1,5 @@ +cpu 8086 + ;; Multi-Push/Pop ;; Both take the registers in the same order, "F"==Flags ;; Push pushes left to right; pop right to left diff --git a/shell/cswap.asm b/shell/cswap.asm index 3483a60b..9f34e558 100644 --- a/shell/cswap.asm +++ b/shell/cswap.asm @@ -84,7 +84,9 @@ mySP DW 0 execRetval dw 0 -; global real_XMSexec +%ifidn __OUTPUT_FORMAT__,elf + cglobal real_XMSexec +%endif real_XMSexec: int 21h ; shrink/free: first thing done from resident code @@ -320,7 +322,6 @@ XMSrequest: ;; SS at the end of the XMSexec function cglobal XMSexec XMSexec: - cextern residentCS ; save ALL registers needed later %ifidn __OUTPUT_FORMAT__,elf ; GCC: need to preserve es push es @@ -345,7 +346,12 @@ XMSexec: mov bx,[SwapResidentSize] mov dx, ds - mov cx, [residentCS] +%ifidn __OUTPUT_FORMAT__,elf ; GCC/ELF: can't use seg so use pointer from C + cextern preal_XMSexec + mov cx, [cs:preal_XMSexec+2] +%else + mov cx, seg mySS +%endif mov ds, cx mov [mySS],ss ; 2E @@ -355,11 +361,11 @@ XMSexec: mov sp,localStack push dx ; save DS of transient portion - push cs ; save segment of transient portion - push WORD ret_from_resident - push cx - push WORD real_XMSexec - retf +%ifidn __OUTPUT_FORMAT__,elf ; GCC/ELF: can't use direct call far + call far [cs:preal_XMSexec] +%else + call far real_XMSexec +%endif ret_from_resident: mov ax,[execRetval] diff --git a/shell/cswapc.c b/shell/cswapc.c index a1f22a9a..c131b413 100644 --- a/shell/cswapc.c +++ b/shell/cswapc.c @@ -78,7 +78,11 @@ static enum { ,INIT_FAILED ,INIT_SUCCEEDED } initialized = INIT_NO; -word residentCS; +#ifdef __GNUC__ +/* For other compilers this is defined in cswap.asm but NASM can't deal + with relocations in ELF */ +void far * far preal_XMSexec __attribute__((section(".text"))) = real_XMSexec; +#endif int XMSisactive(void) { return initialized == INIT_SUCCEEDED; diff --git a/shell/init.c b/shell/init.c index f5d1ec54..c4adb340 100644 --- a/shell/init.c +++ b/shell/init.c @@ -180,9 +180,6 @@ int initialize(void) /* Set up the host environment of COMMAND.COM */ /* Give us shell privileges */ -#ifdef FEATURE_XMS_SWAP - residentCS = _CS; -#endif myPID = _psp; termAddr = pspTermAddr; pspTermAddr = terminateFreeCOMHook;