🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #307

Re: Binary translation

#307
From: Anton Ertl
Date: Fri, 23 Oct 2026 16:21
56 lines
3812 bytes
BGB <cr88192@gmail.com> writes:
>On 10/23/2026 2:55 AM, Anton Ertl wrote:
>> 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.
>> 
>
>The main thing I think would be to have some way to cheaply compute them 
>and store them away until needed (or restore them from a snapshot state, 
>do the op, and then snapshot them again).
>
>Potentially, with the snapshots of the non-x86 flags, one could use 
>these to synthesize the x86 view of the flags if/when they became 
>architecturally visible in the x86 space (with things like moving bits 
>around or inverting some bits, etc, being potentially cheaper than fully 
>faking the flags).

Yes, you will not store the flags in eflags format, but in some
representation that's easy on the target, except when you need to
produce them in eflags format.

For NZP, the destination register of the instruction that writes the
flag contains all the information, so one can store that (and just as
cheaply on RISC-V as on ARM A64); one does need to sign-extend the
target size to the full 64 bits.

C can be computed relatively cheaply even on RISC-V, taking one
instruction.

V takes several on RISC-V and may be cheaper to do on ARM A64 (where
it probably falls out of the computation in the same way as am AMD64
in many cases).

>And, then there were instructions that update parts of a register:
>   ADD AX, CX
>   XCHG AL, DH
>   ...
>
>That can also be a hassle sometimes.

They cost what they cost, when they occur (which is rarely).  And they
even cost quite a bit on hardware implementations of AMD64.

By contrast, flags are produced by many instructions, and in most
cases are overwritten without being read.

- anton
-- 
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
  Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Technical Details
Message-ID: <2026Oct23.182100@mips.complang.tuwien.ac.at>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!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> <11bf785$1jldo$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: Binary translation
Date: Fri, 23 Oct 2026 16:21:00 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 56
Message-ID: <2026Oct23.182100@mips.complang.tuwien.ac.at>
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> <11bf785$1jldo$1@dont-email.me>
Injection-Date: Fri, 23 Oct 2026 16:41:40 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2064522"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19rg7BfDk8spXpp814ZPdR5"; posting-host="2fa3e9841a62cba7e672273caf15be57"
Cancel-Lock: sha1:iFHK/aOxdx9LHuUfR4qeVpfPNNw= sha256:qw2bgvH6yFY5ld7jIHybL3nvH7AxOTgupeTtoNPiEB0=
	sha1:aFr/CbKzKc6V4x2eU3IrJOc732E= sha256:FIoQj4TGFvJWijJE/QZtc31Wv7Uh5x+XDvHYHledIBs=
X-newsreader: xrn 10.11