Home | History | Annotate | Download | only in x86
      1 
      2 #include <stdio.h>
      3 
      4 static int movzbw_1 ( void )
      5 {
      6    int res;
      7    __asm__ __volatile__(
      8       "movl $0x12345678, %%eax\n\t"
      9       "movb $0x22, %%al\n\t"
     10       "movzbw %%al,%%ax\n\t"
     11       "mov %%eax, %0"
     12       : "=r"(res) : : "eax"
     13    );
     14    return res;
     15 }
     16 
     17 static int movzbw_2 ( void )
     18 {
     19    int res;
     20    __asm__ __volatile__(
     21       "movl $0x12345678, %%eax\n\t"
     22       "movb $0x99, %%al\n\t"
     23       "movzbw %%al,%%ax\n\t"
     24       "mov %%eax, %0"
     25       : "=r"(res) : : "eax"
     26    );
     27    return res;
     28 }
     29 
     30 static int movzbl_1 ( void )
     31 {
     32    int res;
     33    __asm__ __volatile__(
     34       "movl $0x12345678, %%eax\n\t"
     35       "movb $0x22, %%al\n\t"
     36       "movzbl %%al,%%eax\n\t"
     37       "mov %%eax, %0"
     38       : "=r"(res) : : "eax"
     39    );
     40    return res;
     41 }
     42 
     43 static int movzbl_2 ( void )
     44 {
     45    int res;
     46    __asm__ __volatile__(
     47       "movl $0x12345678, %%eax\n\t"
     48       "movb $0x99, %%al\n\t"
     49       "movzbl %%al,%%eax\n\t"
     50       "mov %%eax, %0"
     51       : "=r"(res) : : "eax"
     52    );
     53    return res;
     54 }
     55 
     56 static int movzwl_1 ( void )
     57 {
     58    int res;
     59    __asm__ __volatile__(
     60       "movl $0x12345678, %%eax\n\t"
     61       "movw $0x2222, %%ax\n\t"
     62       "movzwl %%ax,%%eax\n\t"
     63       "mov %%eax, %0"
     64       : "=r"(res) : : "eax"
     65    );
     66    return res;
     67 }
     68 
     69 static int movzwl_2 ( void )
     70 {
     71    int res;
     72    __asm__ __volatile__(
     73       "movl $0x12345678, %%eax\n\t"
     74       "movw $0x9999, %%ax\n\t"
     75       "movzwl %%ax,%%eax\n\t"
     76       "mov %%eax, %0"
     77       : "=r"(res) : : "eax"
     78    );
     79    return res;
     80 }
     81 
     82 static int movsbw_1 ( void )
     83 {
     84    int res;
     85    __asm__ __volatile__(
     86       "movl $0x12345678, %%eax\n\t"
     87       "movb $0x22, %%al\n\t"
     88       "movsbw %%al,%%ax\n\t"
     89       "mov %%eax, %0"
     90       : "=r"(res) : : "eax"
     91    );
     92    return res;
     93 }
     94 
     95 static int movsbw_2 ( void )
     96 {
     97    int res;
     98    __asm__ __volatile__(
     99       "movl $0x12345678, %%eax\n\t"
    100       "movb $0x99, %%al\n\t"
    101       "movsbw %%al,%%ax\n\t"
    102       "mov %%eax, %0"
    103       : "=r"(res) : : "eax"
    104    );
    105    return res;
    106 }
    107 
    108 static int movsbl_1 ( void )
    109 {
    110    int res;
    111    __asm__ __volatile__(
    112       "movl $0x12345678, %%eax\n\t"
    113       "movb $0x22, %%al\n\t"
    114       "movsbl %%al,%%eax\n\t"
    115       "mov %%eax, %0"
    116       : "=r"(res) : : "eax"
    117    );
    118    return res;
    119 }
    120 
    121 static int movsbl_2 ( void )
    122 {
    123    int res;
    124    __asm__ __volatile__(
    125       "movl $0x12345678, %%eax\n\t"
    126       "movb $0x99, %%al\n\t"
    127       "movsbl %%al,%%eax\n\t"
    128       "mov %%eax, %0"
    129       : "=r"(res) : : "eax"
    130    );
    131    return res;
    132 }
    133 
    134 static int movswl_1 ( void )
    135 {
    136    int res;
    137    __asm__ __volatile__(
    138       "movl $0x12345678, %%eax\n\t"
    139       "movw $0x2222, %%ax\n\t"
    140       "movswl %%ax,%%eax\n\t"
    141       "mov %%eax, %0"
    142       : "=r"(res) : : "eax"
    143    );
    144    return res;
    145 }
    146 
    147 static int movswl_2 ( void )
    148 {
    149    int res;
    150    __asm__ __volatile__(
    151       "movl $0x12345678, %%eax\n\t"
    152       "movw $0x9999, %%ax\n\t"
    153       "movswl %%ax,%%eax\n\t"
    154       "mov %%eax, %0"
    155       : "=r"(res) : : "eax"
    156    );
    157    return res;
    158 }
    159 
    160 
    161 
    162 int main ( void )
    163 {
    164    printf("%8s 0x%08x\n", "movzbw_1", movzbw_1());
    165    printf("%8s 0x%08x\n", "movzbw_2", movzbw_2());
    166    printf("%8s 0x%08x\n", "movzbl_1", movzbl_1());
    167    printf("%8s 0x%08x\n", "movzbl_2", movzbl_2());
    168    printf("%8s 0x%08x\n", "movzwl_1", movzwl_1());
    169    printf("%8s 0x%08x\n", "movzwl_2", movzwl_2());
    170    printf("%8s 0x%08x\n", "movsbw_1", movsbw_1());
    171    printf("%8s 0x%08x\n", "movsbw_2", movsbw_2());
    172    printf("%8s 0x%08x\n", "movsbl_1", movsbl_1());
    173    printf("%8s 0x%08x\n", "movsbl_2", movsbl_2());
    174    printf("%8s 0x%08x\n", "movswl_1", movswl_1());
    175    printf("%8s 0x%08x\n", "movswl_2", movswl_2());
    176    return 0;
    177 }
    178