delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2024/02/24/06:20:22

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1708773614; x=1709378414; darn=delorie.com;
h=content-transfer-encoding:to:subject:message-id:date:from
:in-reply-to:references:mime-version:from:to:cc:subject:date
:message-id:reply-to;
bh=REt3KYWWUVupFLnyCsh1FI8RWnm563H5IYml0aP8sew=;
b=ZqiXKrT1SlDGij8SSVpycwjquTpKYr5XuSmr7HKR5L/IloCPvPvPk4v5DdDNwB+6vI
PjahGaW++/ENLAWoVRDUDJJitAJlfYYSUMLtp6egYcvnXUqsbhBfaIQLIA5CxExhoGrv
zcqVeOWJR1PCltlBCXA/IRUtoI2DgP5qBH7Bi2Xg5uX+5FGb8Q/wPfQCn/galcdfLPUU
7nv8780ExVbB7NBQtFG6i4u/R0yWd9LShk9ZvcA+1gGIcH/4m19zR8GUbJ6Z8qThWbpn
TmYVg0WvTF6R51xUF1tcQiyF4K2+xNZJfHkBnJAd57TjF6Ds8biSlDKdKhvijwgZf5kP
Cs8w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1708773614; x=1709378414;
h=content-transfer-encoding:to:subject:message-id:date:from
:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
:subject:date:message-id:reply-to;
bh=REt3KYWWUVupFLnyCsh1FI8RWnm563H5IYml0aP8sew=;
b=FKjADg3DgDwyZm3OkEDm0poufNfdryhmJ1zpnUfgpQZVl2b4pacPt24ChHF1A2evDm
BwUZwgvbgE/CCHYTzbTej/yT9W4auzqJC4iL3SqAulntVtn9vHFIBAt0QXbRLbyMzEw6
5/a4LFlpFXTxybOcwhWhdjcFkQxs7Z4P/viPe2CExHpsuFoC2PkxHF7gxh0zXlICCEq1
Ax4pVqO6u6jK239rT920mqXasLBXTPYRq6yXpc+iLgvR9DvAMGQzPInV/Y1f/Es1tmV2
2OXaXkhJ3uEOSrf4KEntrKT70ANF4LxFsypsX+OVNPeTHdreFpDvFFaqF4mhHLTm949P
dBtg==
X-Gm-Message-State: AOJu0YwTUste5zm59fS6W6Wo1GSpO6dzWZOMgPnF7gPoC4cVfMqz+Efn
OhYtOPDMPob23aGvDv5W9i0akLLRhcO/cKf4aJDrEXTJrl3YHxGFYxX1JH12Cz3TRtW6bQ14Tiz
Bw13n8tmyHXSbGjOmaq9v7L55YrYw/IXT
X-Google-Smtp-Source: AGHT+IG2EjZOPMV1XTHEEVVftrZHrysppwHjnYsGHqmWl9ZvcqNyJ3Qp57E2JNx26GqoKNY88X+ZnHIsRDzR6g2zaKw=
X-Received: by 2002:a2e:86cd:0:b0:2d2:43fd:391b with SMTP id
n13-20020a2e86cd000000b002d243fd391bmr892819ljj.26.1708773614325; Sat, 24 Feb
2024 03:20:14 -0800 (PST)
MIME-Version: 1.0
References: <CAA2C=vB8ZicddhV9vbcu9RELueGs8o5_=OQdy0gejtPzFaYeJw AT mail DOT gmail DOT com>
<fb540633-1a6d-4a7b-8dd0-74b774ad8733 AT gmail DOT com> <CAA2C=vAMR_eEmGd01jZDe3013inxvtEM-0qB-yoCzsTF0Cx2zw AT mail DOT gmail DOT com>
<a38d27c4-5ff1-410d-9045-fec911c09faa AT gmail DOT com>
In-Reply-To: <a38d27c4-5ff1-410d-9045-fec911c09faa@gmail.com>
From: "Ozkan Sezer (sezeroz AT gmail DOT com) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
Date: Sat, 24 Feb 2024 14:20:02 +0300
Message-ID: <CAA2C=vCJ+vZcgVRq3DBJUyKQzsJhZajhTp4KapMGCqaRHHVDFg@mail.gmail.com>
Subject: Re: checking int2d amis appstring with djgpp
To: djgpp AT delorie DOT com
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id 41OBKGZl015266
Reply-To: djgpp AT delorie DOT com

On Sat, Feb 24, 2024 at 2:06 PM J.W. Jagersma (jwjagersma AT gmail DOT com)
[via djgpp AT delorie DOT com] <djgpp AT delorie DOT com> wrote:
>
> >>>     __asm__ __volatile__ ("movw %%dx,%0":"=m"(addr.segment));
> >>>     __asm__ __volatile__ ("movw %%di,%0":"=m"(addr.offset16));
> >>
> >> This doesn't look right - you can't assume gcc preserves registers
> >> between asm blocks.
> >
> > OK, should have been like this then, yes?
> >
> > __asm__ __volatile__ (
> >   "movb %2,   %%ah\n"
> >   "xorb %%al, %%al\n"
> >   "int  $0x2D\n"
> >   "cmpb $0xFF,%%al\n"     /* is this a free multiplex? */
> >   "jz  1f\n"
> >   "xorw %%dx, %%dx\n"     /* it is, return NULL pointer */
> >   "xorw %%di, %%di\n"
> >   "1:\n"
> >   "movw %%dx, %0\n"
> >   "movw %%di, %1\n"
> >   : "=m"(addr.segment),
> >     "=m"(addr.offset16)
> >   :  "m"(mx) );
>
> Almost.  You would also need to list the registers you modified,
> otherwise gcc will make the wrong assumptions about their contents.  So:
>
>   /* ... */
>   : "=m"(addr.segment),
>     "=m"(addr.offset16)
>   :  "m"(mx)
>   : "ax", "dx", "di");
>
> Although if I were to call a protected-mode interrupt, I would do the
> control flow in C, so the asm can be simplified to:
>
>   unsigned ax = mx << 8;
>   __dpmi_raddr addr;
>
>   asm
>   (
>     "int $0x2D"
>     : "+a" (ax),            /* ax */
>       "=d" (addr.segment),  /* dx */
>       "=D" (addr.offset16)  /* di */
>   );
>
>   if ((ax & 0xff) != 0xff)
>     continue;
>
>   /* ... */
>
> But this is not very relevant to your question anymore, of course :)
>
> Last version of the code you posted looks good to me, I would expect
> that to work.

Thanks!

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019