From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: From: =?UTF-8?B?QXJhbSBIxIN2xINybmVhbnU=?= Date: Thu, 4 Feb 2016 15:05:16 +0100 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>, Brantley Coile Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [9fans] FP register usage in Plan9 assembler Topicbox-Message-UUID: 8280567e-ead9-11e9-9d60-3106f5b1d025 Brantley Coile wrote: > Which plan 9 assembler uses right to left argument assignments, > or compare argument order? The CMP order is different (at least) between power and arm64. This inconsistency is impossible to fix; I know because I tried to fix it in the SPARC64 Go port. The problem is that different architectures treat immediate constants either as the first, or the second argument. For non-commutative operations like subtractions, this matters. However, in Plan 9, for three-argument instructions, we want to have a two argument variant that works like this: OP one, two -> OP one, two, two That is, the last argument is doubled, and serves as the (Plan 9) second operand. However, this means immediates must come first, because OP $imm, R -> OP $imm, R, R makes sense, but OP R, $imm, $imm doesn't; $imm can't serve as destination. So this forces immediates in Plan 9 assembly to be the first operands, even though the machine might treat them as the first, or second operands. One might be tempted to allow immediates as second operands, and simply forbit an instruction of the form "OP R, $imm", mandating one should always use the three-operand form "OP Rs, $imm, Rd". Indeed this was what I did with the SPARC64 Go port. However, this makes the compiler significantly more complex, and different, so it's not a good idea. As for instructions with different data flow order, atomic instructions on ARM64 come to mind. Note that printing is still in "from, reg, from3, to" order, so printing these instructions (7a -S) will print something different than the input. This has been fixed in Go. --=20 Aram H=C4=83v=C4=83rneanu