1#include "tests/asm.h"
2#include <stdio.h>
3
4char in_b, out_b1, out_b2, in_b2;
5
6short in_w, out_w1, out_w2;
7
8int in_l, out_l1, out_l2;
9
10extern void sbb_ib_al ( void );
11asm("\n"
12VG_SYM(sbb_ib_al) ":\n"
13
14"\tmovb " VG_SYM(in_b) ", %al\n"
15"\tclc\n"
16"\tsbbb $5, %al\n"
17"\tmovb %al, " VG_SYM(out_b1) "\n"
18
19"\tmovb " VG_SYM(in_b) ", %al\n"
20"\tstc\n"
21"\tsbbb $5, %al\n"
22"\tmovb %al, " VG_SYM(out_b2) "\n"
23
24"\tret\n"
25);
26
27
28extern void sbb_iw_ax ( void );
29asm("\n"
30VG_SYM(sbb_iw_ax) ":\n"
31
32"\tmovw " VG_SYM(in_w) ", %ax\n"
33"\tclc\n"
34"\tsbbw $555, %ax\n"
35"\tmovw %ax, " VG_SYM(out_w1) "\n"
36
37"\tmovw " VG_SYM(in_w) ", %ax\n"
38"\tstc\n"
39"\tsbbw $555, %ax\n"
40"\tmovw %ax, " VG_SYM(out_w2) "\n"
41
42"\tret\n"
43);
44
45
46extern void sbb_il_eax ( void );
47asm("\n"
48VG_SYM(sbb_il_eax) ":\n"
49
50"\tmovl " VG_SYM(in_l) ", %eax\n"
51"\tclc\n"
52"\tsbbl $555666, %eax\n"
53"\tmovl %eax, " VG_SYM(out_l1) "\n"
54
55"\tmovl " VG_SYM(in_l) ", %eax\n"
56"\tstc\n"
57"\tsbbl $555666, %eax\n"
58"\tmovl %eax, " VG_SYM(out_l2) "\n"
59
60"\tret\n"
61);
62
63
64extern void sbb_eb_gb ( void );
65asm("\n"
66VG_SYM(sbb_eb_gb) ":\n"
67
68"\tmovb " VG_SYM(in_b) ", %al\n"
69"\tclc\n"
70"\tsbbb " VG_SYM(in_b2) ", %al\n"
71"\tmovb %al, " VG_SYM(out_b1) "\n"
72
73"\tmovb " VG_SYM(in_b) ", %al\n"
74"\tstc\n"
75"\tsbbb " VG_SYM(in_b2) ", %al\n"
76"\tmovb %al, " VG_SYM(out_b2) "\n"
77
78"\tret\n"
79);
80
81
82extern void sbb_eb_gb_2 ( void );
83asm("\n"
84VG_SYM(sbb_eb_gb_2) ":\n"
85"\tpushl %ecx\n"
86
87"\tmovb " VG_SYM(in_b) ", %cl\n"
88"\tmovb " VG_SYM(in_b2) ", %dh\n"
89"\tclc\n"
90"\tsbbb %dh,%cl\n"
91"\tmovb %cl, " VG_SYM(out_b1) "\n"
92
93"\tmovb " VG_SYM(in_b) ", %cl\n"
94"\tmovb " VG_SYM(in_b2) ", %dh\n"
95"\tstc\n"
96"\tsbbb %dh,%cl\n"
97"\tmovb %cl, " VG_SYM(out_b2) "\n"
98
99"\tpopl %ecx\n"
100"\tret\n"
101);
102
103
104extern void adc_eb_gb ( void );
105asm("\n"
106VG_SYM(adc_eb_gb) ":\n"
107
108"\tmovb " VG_SYM(in_b) ", %al\n"
109"\tclc\n"
110"\tadcb " VG_SYM(in_b2) ", %al\n"
111"\tmovb %al, " VG_SYM(out_b1) "\n"
112
113"\tmovb " VG_SYM(in_b) ", %al\n"
114"\tstc\n"
115"\tadcb " VG_SYM(in_b2) ", %al\n"
116"\tmovb %al, " VG_SYM(out_b2) "\n"
117
118"\tret\n"
119);
120
121
122extern void adc_eb_gb_2 ( void );
123asm("\n"
124VG_SYM(adc_eb_gb_2) ":\n"
125"\tpushl %ecx\n"
126
127"\tmovb " VG_SYM(in_b) ", %cl\n"
128"\tmovb " VG_SYM(in_b2) ", %dh\n"
129"\tclc\n"
130"\tadcb %dh,%cl\n"
131"\tmovb %cl, " VG_SYM(out_b1) "\n"
132
133"\tmovb " VG_SYM(in_b) ", %cl\n"
134"\tmovb " VG_SYM(in_b2) ", %dh\n"
135"\tstc\n"
136"\tadcb %dh,%cl\n"
137"\tmovb %cl, " VG_SYM(out_b2) "\n"
138
139"\tpopl %ecx\n"
140"\tret\n"
141);
142
143extern void adc_ib_al ( void );
144asm("\n"
145VG_SYM(adc_ib_al) ":\n"
146
147"\tmovb " VG_SYM(in_b) ", %al\n"
148"\tclc\n"
149"\tadcb $5, %al\n"
150"\tmovb %al, " VG_SYM(out_b1) "\n"
151
152"\tmovb " VG_SYM(in_b) ", %al\n"
153"\tstc\n"
154"\tadcb $5, %al\n"
155"\tmovb %al, " VG_SYM(out_b2) "\n"
156
157"\tret\n"
158);
159
160
161extern void adc_iw_ax ( void );
162asm("\n"
163VG_SYM(adc_iw_ax) ":\n"
164
165"\tmovw " VG_SYM(in_w) ", %ax\n"
166"\tclc\n"
167"\tadcw $555, %ax\n"
168"\tmovw %ax, " VG_SYM(out_w1) "\n"
169
170"\tmovw " VG_SYM(in_w) ", %ax\n"
171"\tstc\n"
172"\tadcw $555, %ax\n"
173"\tmovw %ax, " VG_SYM(out_w2) "\n"
174
175"\tret\n"
176);
177
178
179extern void adc_il_eax ( void );
180asm("\n"
181VG_SYM(adc_il_eax) ":\n"
182
183"\tmovl " VG_SYM(in_l) ", %eax\n"
184"\tclc\n"
185"\tadcl $555666, %eax\n"
186"\tmovl %eax, " VG_SYM(out_l1) "\n"
187
188"\tmovl " VG_SYM(in_l) ", %eax\n"
189"\tstc\n"
190"\tadcl $555666, %eax\n"
191"\tmovl %eax, " VG_SYM(out_l2) "\n"
192
193"\tret\n"
194);
195
196
197int main ( void )
198{
199   in_b = 99;
200   sbb_ib_al();
201   printf("r1 = %d %d\n", (int)out_b1, (int)out_b2);
202
203   in_w = 49999;
204   sbb_iw_ax();
205   printf("r2 = %d %d\n", (int)out_w1, (int)out_w2);
206
207   in_l = 0xF0000000;
208   sbb_il_eax();
209   printf("r3 = %d %d\n", (int)out_l1, (int)out_l2);
210
211   in_b = 99;
212   in_b2 = 88;
213   sbb_eb_gb();
214   printf("r4 = %d %d\n", (int)out_b1, (int)out_b2);
215
216   in_b = 66;
217   in_b2 = 77;
218   sbb_eb_gb_2();
219   printf("r5 = %d %d\n", (int)out_b1, (int)out_b2);
220
221   in_b = 99;
222   in_b2 = 88;
223   adc_eb_gb();
224   printf("r6 = %d %d\n", (int)out_b1, (int)out_b2);
225
226   in_b = 66;
227   in_b2 = 77;
228   adc_eb_gb_2();
229   printf("r7 = %d %d\n", (int)out_b1, (int)out_b2);
230
231   in_b = 99;
232   adc_ib_al();
233   printf("r8 = %d %d\n", (int)out_b1, (int)out_b2);
234
235   in_w = 49999;
236   adc_iw_ax();
237   printf("r9 = %d %d\n", (int)out_w1, (int)out_w2);
238
239   in_l = 0xF0000000;
240   adc_il_eax();
241   printf("r10 = %d %d\n", (int)out_l1, (int)out_l2);
242
243   return 0;
244}
245