Home | History | Annotate | Download | only in amd64
      1 #include "tests/asm.h"
      2 #include <stdio.h>
      3 
      4 char in_b, out_b1, out_b2, in_b2;
      5 
      6 short in_w, out_w1, out_w2;
      7 
      8 int in_l, out_l1, out_l2;
      9 
     10 extern void sbb_ib_al ( void );
     11 asm("\n"
     12 VG_SYM(sbb_ib_al) ":\n"
     13 
     14 #ifndef VGP_amd64_darwin
     15 "\tmovb " VG_SYM(in_b) ", %al\n"
     16 #else
     17 "\tmovb " VG_SYM(in_b) "(%rip), %al\n"
     18 #endif
     19 
     20 "\tclc\n"
     21 "\tsbbb $5, %al\n"
     22 #ifndef VGP_amd64_darwin
     23 "\tmovb %al, " VG_SYM(out_b1) "\n"
     24 
     25 "\tmovb " VG_SYM(in_b) ", %al\n"
     26 #else
     27 "\tmovb %al, " VG_SYM(out_b1) "(%rip)\n"
     28 
     29 "\tmovb " VG_SYM(in_b) "(%rip), %al\n"
     30 #endif
     31 "\tstc\n"
     32 "\tsbbb $5, %al\n"
     33 #ifndef VGP_amd64_darwin
     34 "\tmovb %al, " VG_SYM(out_b2) "\n"
     35 #else
     36 "\tmovb %al," VG_SYM(out_b2) "(%rip) \n"
     37 #endif
     38 
     39 "\tretq\n"
     40 );
     41 
     42 
     43 extern void sbb_iw_ax ( void );
     44 asm("\n"
     45 VG_SYM(sbb_iw_ax) ":\n"
     46 
     47 #ifndef VGP_amd64_darwin
     48 "\tmovw " VG_SYM(in_w) ", %ax\n"
     49 #else
     50 "\tmovw " VG_SYM(in_w) "(%rip), %ax\n"
     51 #endif
     52 "\tclc\n"
     53 "\tsbbw $555, %ax\n"
     54 #ifndef VGP_amd64_darwin
     55 "\tmovw %ax, " VG_SYM(out_w1) "\n"
     56 
     57 "\tmovw " VG_SYM(in_w) ", %ax\n"
     58 #else
     59 "\tmovw %ax, " VG_SYM(out_w1) "(%rip)\n"
     60 
     61 "\tmovw " VG_SYM(in_w) "(%rip), %ax\n"
     62 #endif
     63 "\tstc\n"
     64 "\tsbbw $555, %ax\n"
     65 #ifndef VGP_amd64_darwin
     66 "\tmovw %ax, " VG_SYM(out_w2) "\n"
     67 #else
     68 "\tmovw %ax, " VG_SYM(out_w2) "(%rip)\n"
     69 #endif
     70 
     71 "\tretq\n"
     72 );
     73 
     74 
     75 extern void sbb_il_eax ( void );
     76 asm("\n"
     77 VG_SYM(sbb_il_eax) ":\n"
     78 
     79 #ifndef VGP_amd64_darwin
     80 "\tmovl " VG_SYM(in_l) ", %eax\n"
     81 #else
     82 "\tmovl " VG_SYM(in_l) "(%rip), %eax\n"
     83 #endif
     84 "\tclc\n"
     85 "\tsbbl $555666, %eax\n"
     86 #ifndef VGP_amd64_darwin
     87 "\tmovl %eax, " VG_SYM(out_l1) "\n"
     88 
     89 "\tmovl " VG_SYM(in_l) ", %eax\n"
     90 #else
     91 "\tmovl %eax, " VG_SYM(out_l1) "(%rip)\n"
     92 
     93 "\tmovl " VG_SYM(in_l) "(%rip), %eax\n"
     94 #endif
     95 "\tstc\n"
     96 "\tsbbl $555666, %eax\n"
     97 #ifndef VGP_amd64_darwin
     98 "\tmovl %eax, " VG_SYM(out_l2) "\n"
     99 #else
    100 "\tmovl %eax, " VG_SYM(out_l2) "(%rip)\n"
    101 #endif
    102 
    103 "\tretq\n"
    104 );
    105 
    106 
    107 extern void sbb_eb_gb ( void );
    108 asm("\n"
    109 VG_SYM(sbb_eb_gb) ":\n"
    110 
    111 #ifndef VGP_amd64_darwin
    112 "\tmovb " VG_SYM(in_b) ", %al\n"
    113 #else
    114 "\tmovb " VG_SYM(in_b) "(%rip), %al\n"
    115 #endif
    116 "\tclc\n"
    117 #ifndef VGP_amd64_darwin
    118 "\tsbbb " VG_SYM(in_b2) ", %al\n"
    119 "\tmovb %al, " VG_SYM(out_b1) "\n"
    120 
    121 "\tmovb " VG_SYM(in_b) ", %al\n"
    122 #else
    123 "\tsbbb " VG_SYM(in_b2) "(%rip), %al\n"
    124 "\tmovb %al, " VG_SYM(out_b1) "(%rip)\n"
    125 
    126 "\tmovb " VG_SYM(in_b) "(%rip), %al\n"
    127 #endif
    128 "\tstc\n"
    129 #ifndef VGP_amd64_darwin
    130 "\tsbbb " VG_SYM(in_b2) ", %al\n"
    131 "\tmovb %al, " VG_SYM(out_b2) "\n"
    132 #else
    133 "\tsbbb " VG_SYM(in_b2) "(%rip), %al\n"
    134 "\tmovb %al, " VG_SYM(out_b2) "(%rip)\n"
    135 #endif
    136 
    137 "\tretq\n"
    138 );
    139 
    140 
    141 extern void sbb_eb_gb_2 ( void );
    142 asm("\n"
    143 VG_SYM(sbb_eb_gb_2) ":\n"
    144 "\tpushq %rcx\n"
    145 
    146 #ifndef VGP_amd64_darwin
    147 "\tmovb " VG_SYM(in_b) ", %cl\n"
    148 "\tmovb " VG_SYM(in_b2) ", %dh\n"
    149 #else
    150 "\tmovb " VG_SYM(in_b) "(%rip), %cl\n"
    151 "\tmovb " VG_SYM(in_b2) "(%rip), %dh\n"
    152 #endif
    153 "\tclc\n"
    154 "\tsbbb %dh,%cl\n"
    155 #ifndef VGP_amd64_darwin
    156 "\tmovb %cl, " VG_SYM(out_b1) "\n"
    157 
    158 "\tmovb " VG_SYM(in_b) ", %cl\n"
    159 "\tmovb " VG_SYM(in_b2) ", %dh\n"
    160 #else
    161 "\tmovb %cl, " VG_SYM(out_b1) "(%rip)\n"
    162 
    163 "\tmovb " VG_SYM(in_b) "(%rip), %cl\n"
    164 "\tmovb " VG_SYM(in_b2) "(%rip), %dh\n"
    165 #endif
    166 "\tstc\n"
    167 "\tsbbb %dh,%cl\n"
    168 #ifndef VGP_amd64_darwin
    169 "\tmovb %cl, " VG_SYM(out_b2) "\n"
    170 #else
    171 "\tmovb %cl, " VG_SYM(out_b2) "(%rip)\n"
    172 #endif
    173 
    174 "\tpopq %rcx\n"
    175 "\tretq\n"
    176 );
    177 
    178 
    179 extern void adc_eb_gb ( void );
    180 asm("\n"
    181 VG_SYM(adc_eb_gb) ":\n"
    182 
    183 #ifndef VGP_amd64_darwin
    184 "\tmovb " VG_SYM(in_b) ", %al\n"
    185 #else
    186 "\tmovb " VG_SYM(in_b) "(%rip), %al\n"
    187 #endif
    188 "\tclc\n"
    189 #ifndef VGP_amd64_darwin
    190 "\tadcb " VG_SYM(in_b2) ", %al\n"
    191 "\tmovb %al, " VG_SYM(out_b1) "\n"
    192 
    193 "\tmovb " VG_SYM(in_b) ", %al\n"
    194 #else
    195 "\tadcb " VG_SYM(in_b2) "(%rip), %al\n"
    196 "\tmovb %al, " VG_SYM(out_b1) "(%rip)\n"
    197 
    198 "\tmovb " VG_SYM(in_b) "(%rip), %al\n"
    199 #endif
    200 "\tstc\n"
    201 #ifndef VGP_amd64_darwin
    202 "\tadcb " VG_SYM(in_b2) ", %al\n"
    203 "\tmovb %al, " VG_SYM(out_b2) "\n"
    204 #else
    205 "\tadcb " VG_SYM(in_b2) "(%rip), %al\n"
    206 "\tmovb %al, " VG_SYM(out_b2) "(%rip)\n"
    207 #endif
    208 
    209 "\tretq\n"
    210 );
    211 
    212 
    213 extern void adc_eb_gb_2 ( void );
    214 asm("\n"
    215 VG_SYM(adc_eb_gb_2) ":\n"
    216 "\tpushq %rcx\n"
    217 
    218 #ifndef VGP_amd64_darwin
    219 "\tmovb " VG_SYM(in_b) ", %cl\n"
    220 "\tmovb " VG_SYM(in_b2) ", %dh\n"
    221 #else
    222 "\tmovb " VG_SYM(in_b) "(%rip), %cl\n"
    223 "\tmovb " VG_SYM(in_b2) "(%rip), %dh\n"
    224 #endif
    225 "\tclc\n"
    226 "\tadcb %dh,%cl\n"
    227 #ifndef VGP_amd64_darwin
    228 "\tmovb %cl, " VG_SYM(out_b1) "\n"
    229 
    230 "\tmovb " VG_SYM(in_b) ", %cl\n"
    231 "\tmovb " VG_SYM(in_b2) ", %dh\n"
    232 #else
    233 "\tmovb %cl, " VG_SYM(out_b1) "(%rip)\n"
    234 
    235 "\tmovb " VG_SYM(in_b) "(%rip), %cl\n"
    236 "\tmovb " VG_SYM(in_b2) "(%rip), %dh\n"
    237 #endif
    238 "\tstc\n"
    239 "\tadcb %dh,%cl\n"
    240 #ifndef VGP_amd64_darwin
    241 "\tmovb %cl, " VG_SYM(out_b2) "\n"
    242 #else
    243 "\tmovb %cl, " VG_SYM(out_b2) "(%rip)\n"
    244 #endif
    245 
    246 "\tpopq %rcx\n"
    247 "\tretq\n"
    248 );
    249 
    250 extern void adc_ib_al ( void );
    251 asm("\n"
    252 VG_SYM(adc_ib_al) ":\n"
    253 
    254 #ifndef VGP_amd64_darwin
    255 "\tmovb " VG_SYM(in_b) ", %al\n"
    256 #else
    257 "\tmovb " VG_SYM(in_b) "(%rip), %al\n"
    258 #endif
    259 "\tclc\n"
    260 "\tadcb $5, %al\n"
    261 #ifndef VGP_amd64_darwin
    262 "\tmovb %al, " VG_SYM(out_b1) "\n"
    263 
    264 "\tmovb " VG_SYM(in_b) ", %al\n"
    265 #else
    266 "\tmovb %al, " VG_SYM(out_b1) "(%rip)\n"
    267 
    268 "\tmovb " VG_SYM(in_b) "(%rip), %al\n"
    269 #endif
    270 "\tstc\n"
    271 "\tadcb $5, %al\n"
    272 #ifndef VGP_amd64_darwin
    273 "\tmovb %al, " VG_SYM(out_b2) "\n"
    274 #else
    275 "\tmovb %al, " VG_SYM(out_b2) "(%rip)\n"
    276 #endif
    277 
    278 "\tretq\n"
    279 );
    280 
    281 
    282 extern void adc_iw_ax ( void );
    283 asm("\n"
    284 VG_SYM(adc_iw_ax) ":\n"
    285 
    286 #ifndef VGP_amd64_darwin
    287 "\tmovw " VG_SYM(in_w) ", %ax\n"
    288 #else
    289 "\tmovw " VG_SYM(in_w) "(%rip), %ax\n"
    290 #endif
    291 "\tclc\n"
    292 "\tadcw $555, %ax\n"
    293 #ifndef VGP_amd64_darwin
    294 "\tmovw %ax, " VG_SYM(out_w1) "\n"
    295 
    296 "\tmovw " VG_SYM(in_w) ", %ax\n"
    297 #else
    298 "\tmovw %ax, " VG_SYM(out_w1) "(%rip)\n"
    299 
    300 "\tmovw " VG_SYM(in_w) "(%rip), %ax\n"
    301 #endif
    302 "\tstc\n"
    303 "\tadcw $555, %ax\n"
    304 #ifndef VGP_amd64_darwin
    305 "\tmovw %ax, " VG_SYM(out_w2) "\n"
    306 #else
    307 "\tmovw %ax, " VG_SYM(out_w2) "(%rip)\n"
    308 #endif
    309 
    310 "\tretq\n"
    311 );
    312 
    313 
    314 extern void adc_il_eax ( void );
    315 asm("\n"
    316 VG_SYM(adc_il_eax) ":\n"
    317 
    318 #ifndef VGP_amd64_darwin
    319 "\tmovl " VG_SYM(in_l) ", %eax\n"
    320 #else
    321 "\tmovl " VG_SYM(in_l) "(%rip), %eax\n"
    322 #endif
    323 "\tclc\n"
    324 "\tadcl $555666, %eax\n"
    325 #ifndef VGP_amd64_darwin
    326 "\tmovl %eax, " VG_SYM(out_l1) "\n"
    327 
    328 "\tmovl " VG_SYM(in_l) ", %eax\n"
    329 #else
    330 "\tmovl %eax, " VG_SYM(out_l1) "(%rip)\n"
    331 
    332 "\tmovl " VG_SYM(in_l) "(%rip), %eax\n"
    333 #endif
    334 "\tstc\n"
    335 "\tadcl $555666, %eax\n"
    336 #ifndef VGP_amd64_darwin
    337 "\tmovl %eax, " VG_SYM(out_l2) "\n"
    338 #else
    339 "\tmovl %eax, " VG_SYM(out_l2) "(%rip)\n"
    340 #endif
    341 
    342 "\tretq\n"
    343 );
    344 
    345 
    346 int main ( void )
    347 {
    348    in_b = 99;
    349    sbb_ib_al();
    350    printf("r1 = %d %d\n", (int)out_b1, (int)out_b2);
    351 
    352    in_w = 49999;
    353    sbb_iw_ax();
    354    printf("r2 = %d %d\n", (int)out_w1, (int)out_w2);
    355 
    356    in_l = 0xF0000000;
    357    sbb_il_eax();
    358    printf("r3 = %d %d\n", (int)out_l1, (int)out_l2);
    359 
    360    in_b = 99;
    361    in_b2 = 88;
    362    sbb_eb_gb();
    363    printf("r4 = %d %d\n", (int)out_b1, (int)out_b2);
    364 
    365    in_b = 66;
    366    in_b2 = 77;
    367    sbb_eb_gb_2();
    368    printf("r5 = %d %d\n", (int)out_b1, (int)out_b2);
    369 
    370    in_b = 99;
    371    in_b2 = 88;
    372    adc_eb_gb();
    373    printf("r6 = %d %d\n", (int)out_b1, (int)out_b2);
    374 
    375    in_b = 66;
    376    in_b2 = 77;
    377    adc_eb_gb_2();
    378    printf("r7 = %d %d\n", (int)out_b1, (int)out_b2);
    379 
    380    in_b = 99;
    381    adc_ib_al();
    382    printf("r8 = %d %d\n", (int)out_b1, (int)out_b2);
    383 
    384    in_w = 49999;
    385    adc_iw_ax();
    386    printf("r9 = %d %d\n", (int)out_w1, (int)out_w2);
    387 
    388    in_l = 0xF0000000;
    389    adc_il_eax();
    390    printf("r10 = %d %d\n", (int)out_l1, (int)out_l2);
    391 
    392    return 0;
    393 }
    394