This is the mail archive of the
cgen@sources.redhat.com
mailing list for the CGEN project.
[patch] xstormy16::parity()
- From: DJ Delorie <dj at redhat dot com>
- To: cgen at sources dot redhat dot com, sid at sources dot redhat dot com
- Date: Mon, 20 Jan 2003 18:20:04 -0500
- Subject: [patch] xstormy16::parity()
The fix seemed obvious to me, but being paranoid, I even wrote a test
program to test all 65536 values against a brute-force method. Ok?
* xstormy16.cxx (parity): Fix logic.
Index: xstormy16.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/xstormy16/xstormy16.cxx,v
retrieving revision 1.2
diff -p -3 -r1.2 xstormy16.cxx
*** xstormy16.cxx 11 Jan 2002 07:25:02 -0000 1.2
--- xstormy16.cxx 20 Jan 2003 23:16:53 -0000
*************** xstormy16_cpu::parity (int reg)
*** 358,365 ****
{
int tmp;
tmp = reg ^ (reg >> 8);
! tmp ^= reg >> 4;
! tmp ^= reg >> 2;
! tmp ^= reg >> 1;
return tmp & 1;
}
--- 358,365 ----
{
int tmp;
tmp = reg ^ (reg >> 8);
! tmp ^= tmp >> 4;
! tmp ^= tmp >> 2;
! tmp ^= tmp >> 1;
return tmp & 1;
}