Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FUIJ7-0005mE-GI for qemu-devel@nongnu.org; Fri, 14 Apr 2006 03:01:29 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FUIJ6-0005lE-R4 for qemu-devel@nongnu.org; Fri, 14 Apr 2006 03:01:29 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FUIJ6-0005l5-JD for qemu-devel@nongnu.org; Fri, 14 Apr 2006 03:01:28 -0400 Received: from [65.54.175.24] (helo=hotmail.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FUIOa-000125-Kh for qemu-devel@nongnu.org; Fri, 14 Apr 2006 03:07:08 -0400 Message-ID: From: "Blue Swirl" Subject: Re: [Qemu-devel] [PATCH] SPARC target : Fix carry flagupdate inaddxcc and subxc Date: Fri, 14 Apr 2006 09:01:25 +0200 Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_68dd_5d0c_3cad" Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: even.rouault@mines-paris.org, qemu-devel@nongnu.org This is a multi-part message in MIME format. ------=_NextPart_000_68dd_5d0c_3cad Content-Type: text/plain; format=flowed >Conclusion : the computation of the V flag in qemu is correct, and their is >no special case to consider if the C flag is set or not :-) >For tomorrow, the formal proof of the correctness of the whole qemu code >;-) Thanks for the superb analysis! Now it's time to check if real hardware works according to theory. In this addition, there is a carry from lower 32 bits as well as sign change: ./addx -1 0x7fffffff 1 0 7fffffffffffffff + 1 = 8000000000000000, NZVC: 10 qemu-sparc ./addx -1 0x7fffffff 1 0 7fffffffffffffff + 1 = 8000000000000000, NZVC: 10 Here, no carry: ./addx -1 0x7fffffff 0 1 7fffffffffffffff + 100000000 = 80000000ffffffff, NZVC: 10 qemu-sparc ./addx -1 0x7fffffff 0 1 7fffffffffffffff + 100000000 = 80000000ffffffff, NZVC: 10 Another case: ./addx 0 0x80000000 0 0x80000000 8000000000000000 + 8000000000000000 = 0, NZVC: 7 qemu-sparc ./addx 0 0x80000000 0 0x80000000 8000000000000000 + 8000000000000000 = 0, NZVC: 7 Looks fine to me. There was a sign extension problem in the test program, fixed version attached. _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ ------=_NextPart_000_68dd_5d0c_3cad Content-Type: text/x-csrc; name="addx.c" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="addx.c" #include #include void addx_test(unsigned int a, unsigned int b, unsigned int c, unsigned int d) { unsigned int flags, result1, result2; asm ("addcc %3,%5,%1\n\t" "addxcc %4,%6,%2\n\t" "mov 0, %0\n\t" "bcc 1f\n\t" " nop\n\t" "mov 1, %0\n\t" "1: \n\t" "bvc 1f\n\t" " nop\n\t" "or %0, 2, %0\n\t" "1: \n\t" "bnz 1f\n\t" " nop\n\t" "or %0, 4, %0\n\t" "1: \n\t" "bpos 1f\n\t" " nop\n\t" "or %0, 8, %0\n\t" "1: \n\t" : "=r" (flags), "=r" (result1), "=r" (result2) : "r" (a), "r" (b), "r" (c), "r" (d)); printf("%llx + %llx = %llx, NZVC: %d\n", ((unsigned long long)b << 32) | (unsigned long long)a, ((unsigned long long)d << 32) | (unsigned long long)c, ((unsigned long long)result2 << 32) | (unsigned long long)result1, flags); } int main(int argc, const char **argv) { unsigned int a, b, c, d; if (argc != 5) return 1; a = strtoul(argv[1], NULL, 0); b = strtoul(argv[2], NULL, 0); c = strtoul(argv[3], NULL, 0); d = strtoul(argv[4], NULL, 0); addx_test(a, b, c, d); return 0; } ------=_NextPart_000_68dd_5d0c_3cad--