source: Deliverables/D4.1/GCC/ParityCheck.c @ 171

Last change on this file since 171 was 171, checked in by mulligan, 9 years ago

Parity check program. Bug found with jump zero instruction. A few more
opcodes covered.

File size: 271 bytes
Line 
1int parity_test(unsigned int v)
2{
3  int parity;
4  parity = 0;
5  while (v)
6  {
7    parity = (1 - parity);
8    v = v & (v - 1);
9  }
10  return parity;
11}
12
13int main()
14{
15  unsigned int v;
16  int p;
17  v = 5;
18  p = parity_test(v);
19  if(p == 1)
20    return 5;
21  else
22    return 7;
23}
Note: See TracBrowser for help on using the repository browser.