8000 gcc build: XMScopy varargs call doesn't work as expected · Issue #171 · FDOS/freecom · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

gcc build: XMScopy varargs call doesn't work as expected #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ecm-pushbx opened this issue Feb 23, 2025 · 0 comments
Open

gcc build: XMScopy varargs call doesn't work as expected #171

ecm-pushbx opened this issue Feb 23, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@ecm-pushbx
Copy link
Contributor

This is XMScopy, a varargs function that's called with the contents for an XMS move structure:

freecom/shell/cswapc.c

Lines 97 to 125 in e24bd7e

#ifdef __GNUC__
__attribute__((noinline))
#endif
static int XMScopy(
long length, ...
/* short shandle,
long soffset,
short dhandle,
long doffset */
)
{
assert(XMSdriverAdress);
/* asm push si;
asm lea si,length
asm mov ah,0bh; */
#if defined(__TURBOC__)
_SI = (unsigned)&length;
_AH = 0xb;
XMSrequest();
/* asm pop si; */
return _AX; /* shut up warning */
#elif defined(__GNUC__)
return XMSrequest(0xb00, 0, &length);
#else
return XMSdriverAdress(0xb00, 0, &length);
#endif
}

However, in my gcc build this doesn't work. Here's an excerpt from debugging:

-
AX=0001 BX=C001 CX=6220 DX=0000 SP=3A72 BP=3A90 SI=C00F DI=1D60
DS=C00F ES=0000 SS=CE18 CS=C00F IP=0B67 NV UP EI PL NZ AC PO NC
C00F:0B67 36C706D00F0100    mov     word [ss:0FD0], 0001           SS:0FD0=0000
-
AX=0001 BX=C001 CX=6220 DX=0000 SP=3A72 BP=3A90 SI=C00F DI=1D60
DS=C00F ES=0000 SS=CE18 CS=C00F IP=0B6E NV UP EI PL NZ AC PO NC
C00F:0B6E 36C606C60F02      mov     byte [ss:0FC6], 02               SS:0FC6=01
-
AX=0001 BX=C001 CX=6220 DX=0000 SP=3A72 BP=3A90 SI=C00F DI=1D60
DS=C00F ES=0000 SS=CE18 CS=C00F IP=0B74 NV UP EI PL NZ AC PO NC
C00F:0B74 837EE600          cmp     word [bp-1A], +00              SS:3A76=0622
-
AX=0001 BX=C001 CX=6220 DX=0000 SP=3A72 BP=3A90 SI=C00F DI=1D60
DS=C00F ES=0000 SS=CE18 CS=C00F IP=0B78 NV UP EI PL NZ NA PE NC
C00F:0B78 7421              jz      0B9B                            not jumping
-
AX=0001 BX=C001 CX=6220 DX=0000 SP=3A72 BP=3A90 SI=C00F DI=1D60
DS=C00F ES=0000 SS=CE18 CS=C00F IP=0B7A NV UP EI PL NZ NA PE NC
C00F:0B7A 06                push    es
-
AX=0001 BX=C001 CX=6220 DX=0000 SP=3A70 BP=3A90 SI=C00F DI=1D60
DS=C00F ES=0000 SS=CE18 CS=C00F IP=0B7B NV UP EI PL NZ NA PE NC
C00F:0B7B 06                push    es
-
AX=0001 BX=C001 CX=6220 DX=0000 SP=3A6E BP=3A90 SI=C00F DI=1D60
DS=C00F ES=0000 SS=CE18 CS=C00F IP=0B7C NV UP EI PL NZ NA PE NC
C00F:0B7C FF76EA            push    word [bp-16]                   SS:3A7A=0001
-
AX=0001 BX=C001 CX=6220 DX=0000 SP=3A6C BP=3A90 SI=C00F DI=1D60
DS=C00F ES=0000 SS=CE18 CS=C00F IP=0B7F NV UP EI PL NZ NA PE NC
C00F:0B7F FF76E4            push    word [bp-1C]                   SS:3A74=F34C
-
AX=0001 BX=C001 CX=6220 DX=0000 SP=3A6A BP=3A90 SI=C00F DI=1D60
DS=C00F ES=0000 SS=CE18 CS=C00F IP=0B82 NV UP EI PL NZ NA PE NC
C00F:0B82 06                push    es
-
AX=0001 BX=C001 CX=6220 DX=0000 SP=3A68 BP=3A90 SI=C00F DI=1D60
DS=C00F ES=0000 SS=CE18 CS=C00F IP=0B83 NV UP EI PL NZ NA PE NC
C00F:0B83 06                push    es
-
AX=0001 BX=C001 CX=6220 DX=0000 SP=3A66 BP=3A90 SI=C00F DI=1D60
DS=C00F ES=0000 SS=CE18 CS=C00F IP=0B84 NV UP EI PL NZ NA PE NC
C00F:0B84 91                xchg    ax, cx
-
AX=6220 BX=C001 CX=0001 DX=0000 SP=3A66 BP=3A90 SI=C00F DI=1D60
DS=C00F ES=0000 SS=CE18 CS=C00F IP=0B85 NV UP EI PL NZ NA PE NC
C00F:0B85 16                push    ss
-
AX=6220 BX=C001 CX=0001 DX=0000 SP=3A64 BP=3A90 SI=C00F DI=1D60
DS=C00F ES=0000 SS=CE18 CS=C00F IP=0B86 NV UP EI PL NZ NA PE NC
C00F:0B86 1F                pop     ds
-
AX=6220 BX=C001 CX=0001 DX=0000 SP=3A66 BP=3A90 SI=C00F DI=1D60
DS=CE18 ES=0000 SS=CE18 CS=C00F IP=0B87 NV UP EI PL NZ NA PE NC
C00F:0B87 E86BFE            call    09F5
-
AX=6220 BX=C001 CX=0001 DX=0000 SP=3A64 BP=3A90 SI=C00F DI=1D60
DS=CE18 ES=0000 SS=CE18 CS=C00F IP=09F5 NV UP EI PL NZ NA PE NC
C00F:09F5 56                push    si
-
AX=6220 BX=C001 CX=0001 DX=0000 SP=3A62 BP=3A90 SI=C00F DI=1D60
DS=CE18 ES=0000 SS=CE18 CS=C00F IP=09F6 NV UP EI PL NZ NA PE NC
C00F:09F6 55                push    bp
-
AX=6220 BX=C001 CX=0001 DX=0000 SP=3A60 BP=3A90 SI=C00F DI=1D60
DS=CE18 ES=0000 SS=CE18 CS=C00F IP=09F7 NV UP EI PL NZ NA PE NC
C00F:09F7 89E5              mov     bp, sp
-
AX=6220 BX=C001 CX=0001 DX=0000 SP=3A60 BP=3A60 SI=C00F DI=1D60
DS=CE18 ES=0000 SS=CE18 CS=C00F IP=09F9 NV UP EI PL NZ NA PE NC
C00F:09F9 52                push    dx
-
AX=6220 BX=C001 CX=0001 DX=0000 SP=3A5E BP=3A60 SI=C00F DI=1D60
DS=CE18 ES=0000 SS=CE18 CS=C00F IP=09FA NV UP EI PL NZ NA PE NC
C00F:09FA 50                push    ax
-
AX=6220 BX=C001 CX=0001 DX=0000 SP=3A5C BP=3A60 SI=C00F DI=1D60
DS=CE18 ES=0000 SS=CE18 CS=C00F IP=09FB NV UP EI PL NZ NA PE NC
C00F:09FB 8D76FC            lea     si, [bp-04]
-
AX=6220 BX=C001 CX=0001 DX=0000 SP=3A5C BP=3A60 SI=3A5C DI=1D60
DS=CE18 ES=0000 SS=CE18 CS=C00F IP=09FE NV UP EI PL NZ NA PE NC
C00F:09FE 31D2              xor     dx, dx
-
AX=6220 BX=C001 CX=0001 DX=0000 SP=3A5C BP=3A60 SI=3A5C DI=1D60
DS=CE18 ES=0000 SS=CE18 CS=C00F IP=0A00 NV UP EI PL ZR NA PE NC
C00F:0A00 B8000B            mov     ax, 0B00
-
AX=0B00 BX=C001 CX=0001 DX=0000 SP=3A5C BP=3A60 SI=3A5C DI=1D60
DS=CE18 ES=0000 SS=CE18 CS=C00F IP=0A03 NV UP EI PL ZR NA PE NC
C00F:0A03 2EFF1EC008        call    far [cs:08C0]             CS:08C0=F000:F685
-dw ds:si l 10
header     0    2    4    6    8    A    C    E    0123456789ABCDEF
CE18:3A50                     -          6220 0000              b..
CE18:3A60  3A90 C00F 0B8A 0000-0000 F34C           .:........L.
-

Note the lea si, [bp-04] which points not at the function parameters on the stack but rather at a local variable initialised from the length parameter.

@ecm-pushbx ecm-pushbx added the bug Something isn't working label Feb 23, 2025
ecm-pushbx added a commit to ecm-pushbx/freecom that referenced this issue Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant
0