1 #include <stdio.h> 2 #include "test.h" 3 #define icm(r1, mask, b) do {\ 4 asm volatile( "lg 1, 0(%0)\n" \ 5 "icm 1," #mask ",0(%1)\n" \ 6 "stg 1, 0(%0)\n" \ 7 :: "a" (r1), "a" (b) \ 8 : "1", "memory", "cc"); \ 9 } while(0) 10 11 #define icmh(r1, mask, b) do {\ 12 asm volatile( "lg 1, 0(%0)\n" \ 13 "icmh 1," #mask ",0(%1)\n" \ 14 "stg 1, 0(%0)\n" \ 15 :: "a" (r1), "a" (b) \ 16 : "1", "memory", "cc"); \ 17 } while(0) 18 19 int main() 20 { 21 long a[320]; 22 char buffer[256]; 23 char *b1="\x80\x00\x00\x00"; 24 char *b2="\x00\x00\x00\x01"; 25 char *b3="\xff\x00\x00\x00"; 26 char *b4="\x00\xff\x00\x00"; 27 char *b5="\x00\x00\xff\x00"; 28 char *b6="\x00\x00\x00\xff"; 29 int n; 30 int cc; 31 32 for (n=0; n<320; n++) 33 a[n] = n; 34 35 #define test(what, offset) do { \ 36 icm(&a[0+offset], 0, what); cc = get_cc(); \ 37 icm(&a[1+offset+cc], 1, what); cc = get_cc(); \ 38 icm(&a[2+offset+cc], 2, what); cc = get_cc(); \ 39 icm(&a[3+offset+cc], 3, what); cc = get_cc(); \ 40 icm(&a[4+offset+cc], 4, what); cc = get_cc(); \ 41 icm(&a[5+offset+cc], 5, what); cc = get_cc(); \ 42 icm(&a[6+offset+cc], 6, what); cc = get_cc(); \ 43 icm(&a[7+offset+cc], 7, what); cc = get_cc(); \ 44 icm(&a[8+offset+cc], 8, what); cc = get_cc(); \ 45 icm(&a[9+offset+cc], 9, what); cc = get_cc(); \ 46 icm(&a[10+offset+cc], 10, what); cc = get_cc(); \ 47 icm(&a[11+offset+cc], 11, what); cc = get_cc(); \ 48 icm(&a[12+offset+cc], 12, what); cc = get_cc(); \ 49 icm(&a[13+offset+cc], 13, what); cc = get_cc(); \ 50 icm(&a[14+offset+cc], 14, what); cc = get_cc(); \ 51 icm(&a[15+offset+cc], 15, what); cc = get_cc(); \ 52 icmh(&a[0+offset+cc], 0, what); cc = get_cc(); \ 53 icmh(&a[1+offset+cc], 1, what); cc = get_cc(); \ 54 icmh(&a[2+offset+cc], 2, what); cc = get_cc(); \ 55 icmh(&a[3+offset+cc], 3, what); cc = get_cc(); \ 56 icmh(&a[4+offset+cc], 4, what); cc = get_cc(); \ 57 icmh(&a[5+offset+cc], 5, what); cc = get_cc(); \ 58 icmh(&a[6+offset+cc], 6, what); cc = get_cc(); \ 59 icmh(&a[7+offset+cc], 7, what); cc = get_cc(); \ 60 icmh(&a[8+offset+cc], 8, what); cc = get_cc(); \ 61 icmh(&a[9+offset+cc], 9, what); cc = get_cc(); \ 62 icmh(&a[10+offset+cc], 10, what); cc = get_cc(); \ 63 icmh(&a[11+offset+cc], 11, what); cc = get_cc(); \ 64 icmh(&a[12+offset+cc], 12, what); cc = get_cc(); \ 65 icmh(&a[13+offset+cc], 13, what); cc = get_cc(); \ 66 icmh(&a[14+offset+cc], 14, what); cc = get_cc(); \ 67 icmh(&a[15+offset+cc], 15, what); \ 68 } while (0) 69 70 for (n=0; n<256; n++) 71 buffer[n] = n; 72 73 test(&buffer[0],0); 74 test(&buffer[60],16); 75 test(&buffer[120],32); 76 test(&buffer[180],48); 77 test(&buffer[240],64); 78 test(&buffer[252],80); 79 test(b1,96); 80 test(b2,112); 81 for (n=0; n<256; n++) 82 buffer[n] = 255-n; 83 test(&buffer[0],128); 84 test(&buffer[60],144); 85 test(&buffer[160],160); 86 test(b3,176); 87 test(b4,192); 88 test(b5,208); 89 test(b6,224); 90 91 dump_field((char *) a, sizeof(a)); 92 93 return 0; 94 } 95