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=1708772739; x=1709377539; darn=delorie.com; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=s2Yj1yidU8+Ken2lFEA4eciMqqfHDnDcjnWHK59eB0Y=; b=VUeXiVEptNGniAXiex83+HVkA7lqqBivfhF/3dcnwH5ZU2gelie17S+V6UkXDAvLdU ASU3m7boBM1zg9pxvBJM2l33+6SxsHIP78T9kxCyMrsHMI8/mkFNLIK22T7xsPzi2esD LQ4+jae80oXDMlkrFUQ5UtdwgjwSaIisUkb857drqp843r7W83dbowJCAdxfzHhdjQcq S8Ya7u8dyU07Mum0gB36u/JBTp8ne805WXU2W6OACiB/o6oXxugidJ8rie5cyG0TPIha RlBoi3lh1nMNa9xveJ/yGp11ET9SH/uT6J0r3kvtsKa889GCw5RrUl4X5ndFtfbAlBYX 2P4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708772739; x=1709377539; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=s2Yj1yidU8+Ken2lFEA4eciMqqfHDnDcjnWHK59eB0Y=; b=ZwSP+vpm9pS+WDjF5V6KSNOkUjEWCd16hqeoHG6KJnrq06wVUWNK5Fc7trnnLmNmAV aTuXGb5B3climZIHLczKBhLsRY8Rn3KqsbJpij4J19ClFng/QX6/5TI4rrA+DgrnD3Za cJD2GOeZGD6PKXqF1iUlRLS1xELumvQRh5WsVRJtK5KkijpmvIBMN3i6WhehJIL82c44 MNRHAlo4ykuQgkaduLvoYSEMfX8UQ9uZgUmnUQOjATDNl6+tJNVFaGwyZzbrMc6H84Gx lz3pm0ENwHTQTmgGn5deuMLR+eiI/5IJjWHVaeWzL9Yo5iT+cUoEBK62F1V6EDfS5983 lCsg== X-Gm-Message-State: AOJu0YxGOoWUJdfDh7pKtN7FsVsq/paNUIKzEJmRP0V3BCf4n7Jj2nrU wa/zacxGahCOyz2h9RzaZUOXVLkaFPcLsCAljIcHPNUXm5rSY1Y8wObGbiK1 X-Google-Smtp-Source: AGHT+IHdDVmg/tu9iy5x8ZiKuoBZVdTRh6Mjdy5jLdF8AelGMYHzFK37izjqczejmiAITXUdFqGWBw== X-Received: by 2002:a17:906:798:b0:a42:ed2d:3d8f with SMTP id l24-20020a170906079800b00a42ed2d3d8fmr631663ejc.73.1708772738684; Sat, 24 Feb 2024 03:05:38 -0800 (PST) Message-ID: Date: Sat, 24 Feb 2024 12:05:38 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: checking int2d amis appstring with djgpp Content-Language: en-US To: djgpp AT delorie DOT com References: From: "J.W. Jagersma (jwjagersma AT gmail DOT com) [via djgpp AT delorie DOT com]" In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On 2024-02-24 01:08, Ozkan Sezer (sezeroz AT gmail DOT com) [via djgpp AT delorie DOT com] wrote: > On Sat, Feb 24, 2024 at 12:49 AM J.W. Jagersma (jwjagersma AT gmail DOT com) > [via 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.