Home | History | Annotate | Download | only in ppc32
      1 /*  Copyright (C) 2007 IBM
      2 
      3     Author: Pete Eberlein  eberlein (at) us.ibm.com
      4 
      5     This program is free software; you can redistribute it and/or
      6     modify it under the terms of the GNU General Public License as
      7     published by the Free Software Foundation; either version 2 of the
      8     License, or (at your option) any later version.
      9 
     10     This program is distributed in the hope that it will be useful, but
     11     WITHOUT ANY WARRANTY; without even the implied warranty of
     12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13     General Public License for more details.
     14 
     15     You should have received a copy of the GNU General Public License
     16     along with this program; if not, write to the Free Software
     17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
     18     02111-1307, USA.
     19 
     20     The GNU General Public License is contained in the file COPYING.
     21 */
     22 
     23 
     24 
     25 #include <stdio.h>
     26 #include <stdlib.h>
     27 #include <strings.h>
     28 
     29 #define CMPB(result,a,b) \
     30     asm __volatile ("cmpb %0, %1, %2\n" : "=r"(result) : "r"(a), "r"(b))
     31 
     32 
     33 int main(int argc, char *argv[])
     34 {
     35    int i, j, k;
     36    long mask;
     37    for (i = 1; i < 16; i++) {
     38       mask = 0;
     39       if (i & 1)
     40          mask += 0xff;
     41       if (i & 2)
     42          mask += 0xff00;
     43       if (i & 4)
     44          mask += 0xff0000;
     45       if (i & 8)
     46          mask += 0xff000000;
     47 
     48       for (j = 0; j < 256; j++)
     49          for (k = 0; k < 256; k++)
     50             if (j != k) {
     51 
     52                long a, b, result;
     53                a = (mask & (j * 0x1010101)) + ((~mask) & (k * 0x1010101));
     54                b = j * 0x1010101;
     55                CMPB(result, a, b);
     56                if (result != mask) {
     57                   printf("%llx %llx %llx %llx\n",
     58                          (unsigned long long) mask, (unsigned long long) a,
     59                          (unsigned long long) b,
     60                          (unsigned long long) result);
     61                   exit(1);
     62 		}
     63             }
     64 
     65    }
     66 
     67    return 0;
     68 }
     69