1#include <stdio.h>
2#include <stdlib.h>
3
4char b1[23] ="0123456789abcdefghijklm";
5char b2[23] ="mlkjihgfedcba9876543210";
6char b3[23] ="mmmmmmmmmmmmmmmmmmmmmmm";
7char b4[23] ="00000000000000000000000";
8char longbuf1[256];
9char longbuf2[256];
10
11static int clc(char *a1,char *a2, int l)
12{
13	int cc;
14
15	asm volatile(	"larl 1, 1f\n"
16			"ex %3,0(1)\n"
17			"j 2f\n"
18			"1: clc 0(1,%1),0(%2)\n"
19			"2: ipm %0\n"
20			"srl %0,28\n"
21		:"=d" (cc)
22		:"a" (a1), "a" (a2), "d" (l): "1", "cc");
23	return cc;
24}
25
26
27void testrun(char *a1, char *a2, int l)
28{
29	int cc;
30
31	cc = clc(a1, a2, l);
32	printf("%d bytes:%d\n",l, cc);
33}
34
35
36void multiplex(int l, long offset1, long offset2)
37{
38	testrun(b1 + offset1, b1 + offset2, l);
39	testrun(b1 + offset1, b2 + offset2, l);
40	testrun(b1 + offset1, b3 + offset2, l);
41	testrun(b1 + offset1, b4 + offset2, l);
42	testrun(b2 + offset1, b2 + offset2, l);
43	testrun(b2 + offset1, b3 + offset2, l);
44	testrun(b2 + offset1, b4 + offset2, l);
45	testrun(b3 + offset1, b3 + offset2, l);
46	testrun(b3 + offset1, b4 + offset2, l);
47	testrun(b4 + offset1, b4 + offset2, l);
48}
49
50void sweep(int l)
51{
52	multiplex(l, 0, 0);
53	multiplex(l, 1, 0);
54	multiplex(l, 1, 1);
55	multiplex(l, 0, 1);
56}
57
58int main()
59{
60	sweep(0);
61	sweep(1);
62	sweep(2);
63	sweep(3);
64	sweep(4);
65	sweep(5);
66	sweep(22);
67	testrun(longbuf1, longbuf2, 255);
68	longbuf1[255] = 'a';
69	testrun(longbuf1, longbuf2, 255);
70	longbuf2[255] = 'b';
71	testrun(longbuf1, longbuf2, 255);
72	return 0;
73}
74
75