🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #331

Re: Binary translation

#331
From: Waldek Hebisch
Date: Sun, 25 Oct 2026 00:10
45 lines
3208 bytes
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
> BGB <cr88192@gmail.com> writes:
>>On 10/22/2026 11:47 AM, Anton Ertl wrote:
>>> OTOH, it seems to work ok for Apple with Rosetta.
>>> 
>>
>>Yes.
>>
>>ARM64 works well here.
> 
> I think that Apple's *implementations* of ARM A64 (all OoO on the
> Macs) work well.
> 
>>There also seems to be some interest in the RISC-V space for dynamic 
>>translation of x86 to RISC-V; though emulating x86 on RISC-V is likely 
>>to lead to a not exactly small number of things that are difficult to 
>>emulate efficiently (EFLAGS being almost kinda evil in some ways; and 
>>then on an ISA that is in some ways rather poorly equipped to try to 
>>fake it).
> 
> The flags are always a problem, and I don't think that ARM A64 has
> significant advantages over RISC-V here.  Yes it has flags of its own,
> but the instructions do not set them the same way as AMD64.  AMD64 has
> instructions that sometimes set the flags and sometimes don't, it has
> instructions that set C and/or V separately from NZP.  And AFAIK ARM
> A64 has subtract with carry (and corresponding carry handling on
> compares), while AMD64 has subtract with borrow; so the meaning of the
> carry is inverted between the two after a subtract or compare
> instruction, while it agrees after an add instruction.
> 
> So the binary translator essentially has to prepare for the worst case
> and generate all the AMD64 flags in case they are then used in a way
> that the binary translator does not see (e.g., after an indirect
> branch), and if the usage is known, can eliminate most or all of this
> flag-generation code.  Pretty much the same for RISC-V.

IIUC Apple uses extra instructions for emulation purpose.  If
extra instructions are allowed then flags are modest annoyance:
one just needs to add a bunch of instructions which instead of
producing normal result produce flags (in x86 way) in result
register.  Risc-V has tiny advantage here as various extentions
are encouraged.

-- 
                              Waldek Hebisch
Technical Details
Message-ID: <11bjhd7$21qtd$1@paganini.bofh.team>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!newsfeed.bofh.team!paganini.bofh.team!not-for-mail
References: <6ad51222.27689359@news.eternal-september.org> <memo.20261020202111.15264J@jgd.cix.co.uk> <11bb7b6$93g4$1@dont-email.me> <1792685413-5857@newsgrouper.org> <2026Oct22.184735@mips.complang.tuwien.ac.at> <11bed14$1c7dh$1@dont-email.me> <2026Oct23.095556@mips.complang.tuwien.ac.at>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!newsfeed.bofh.team!paganini.bofh.team!not-for-mail
From: antispam@fricas.org (Waldek Hebisch)
Newsgroups: comp.arch
Subject: Re: Binary translation
Date: Sun, 25 Oct 2026 00:10:17 -0000 (UTC)
Organization: bofh.team Usenet service
Message-ID: <11bjhd7$21qtd$1@paganini.bofh.team>
References: <6ad51222.27689359@news.eternal-september.org> <memo.20261020202111.15264J@jgd.cix.co.uk> <11bb7b6$93g4$1@dont-email.me> <1792685413-5857@newsgrouper.org> <2026Oct22.184735@mips.complang.tuwien.ac.at> <11bed14$1c7dh$1@dont-email.me> <2026Oct23.095556@mips.complang.tuwien.ac.at>
Injection-Date: Sun, 25 Oct 2026 00:10:17 -0000 (UTC)
Injection-Info: paganini.bofh.team; logging-data="2157485"; mail-complaints-to="usenet@bofh.team"; posting-host="d028f9ad2fa2c51f22dbfed0d81d7daf"; posting-account="69e66f1681224ab92235b464ce7a90b6"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-9-amd64 (x86_64))
X-Postfilter: Postfilter-NG 2026.10.2