On 06/27/2016 02:48 PM, Peter Maydell wrote:
On 27 June 2016 at 22:43, Richard Henderson <r...@twiddle.net> wrote:
All you need to do is byte-reverse the data.
bswap(a + b) == bswap(a) + bswap(b).
?
0xFF + 0xFF == 0x1FE, bswap(0x1FE) == 0xFE010000
bswap(0xFF) + bswap(0xFF) == 0xFF000000 + 0xFF000000 == 0x1FE000000
(or 0xFE000000 with truncate to 32-bit).
Or am I missing something?
No, you're quite right. I think I didn't have enough coffee this morning.
So we'd need a cmpxchg loop for reverse-endian add.
r~