Home | History | Annotate | Download | only in x86
      1 
      2 #include <stdio.h>
      3 
      4 void do_pushb_pos ( void )
      5 {
      6    unsigned int block[3];
      7    __asm__ __volatile__ (
      8       "movl  %0, %%edx\n\t"
      9       "pushl $0x55555555\n\t"
     10       "movl  %%esp, 0(%%edx)\n\t"
     11       ".byte 0x6A,0x22\n\t"
     12       "movl  %%esp, 4(%%edx)\n\t"
     13       "popl  %%eax\n\t"
     14       "movl  %%eax,8(%%edx)\n\t"
     15       "movl  0(%%edx),%%esp\n\t"
     16       "addl  $4, %%esp"
     17       : : "r"(&block) : "eax","edx","cc","memory"
     18     );
     19     printf("  pushb_pos: delta %d, top32 0x%08x\n",
     20            block[0] - block[1], block[2]);
     21 }
     22 
     23 void do_pushb_neg ( void )
     24 {
     25    unsigned int block[3];
     26    __asm__ __volatile__ (
     27       "movl  %0, %%edx\n\t"
     28       "pushl $0x55555555\n\t"
     29       "movl  %%esp, 0(%%edx)\n\t"
     30       ".byte 0x6A,0xEE\n\t"
     31       "movl  %%esp, 4(%%edx)\n\t"
     32       "popl  %%eax\n\t"
     33       "movl  %%eax,8(%%edx)\n\t"
     34       "movl  0(%%edx),%%esp\n\t"
     35       "addl  $4, %%esp"
     36       : : "r"(&block) : "eax","edx","cc","memory"
     37     );
     38     printf("  pushb_neg: delta %d, top32 0x%08x\n",
     39            block[0] - block[1], block[2]);
     40 }
     41 
     42 void do_pushw_pos ( void )
     43 {
     44    unsigned int block[3];
     45    __asm__ __volatile__ (
     46       "movl  %0, %%edx\n\t"
     47       "pushl $0x55555555\n\t"
     48       "movl  %%esp, 0(%%edx)\n\t"
     49       "pushw $0x3344\n\t"
     50       "movl  %%esp, 4(%%edx)\n\t"
     51       "popl  %%eax\n\t"
     52       "movl  %%eax,8(%%edx)\n\t"
     53       "movl  0(%%edx),%%esp\n\t"
     54       "addl  $4, %%esp"
     55       : : "r"(&block) : "eax","edx","cc","memory"
     56     );
     57     printf("  pushw_neg: delta %d, top32 0x%08x\n",
     58            block[0] - block[1], block[2]);
     59 }
     60 
     61 void do_pushw_neg ( void )
     62 {
     63    unsigned int block[3];
     64    __asm__ __volatile__ (
     65       "movl  %0, %%edx\n\t"
     66       "pushl $0x55555555\n\t"
     67       "movl  %%esp, 0(%%edx)\n\t"
     68       "pushw $0xDDCC\n\t"
     69       "movl  %%esp, 4(%%edx)\n\t"
     70       "popl  %%eax\n\t"
     71       "movl  %%eax,8(%%edx)\n\t"
     72       "movl  0(%%edx),%%esp\n\t"
     73       "addl  $4, %%esp"
     74       : : "r"(&block) : "eax","edx","cc","memory"
     75     );
     76     printf("  pushw_pos: delta %d, top32 0x%08x\n",
     77            block[0] - block[1], block[2]);
     78 }
     79 
     80 void do_pushl_pos ( void )
     81 {
     82    unsigned int block[3];
     83    __asm__ __volatile__ (
     84       "movl  %0, %%edx\n\t"
     85       "pushl $0x55555555\n\t"
     86       "movl  %%esp, 0(%%edx)\n\t"
     87       "pushl $0x67675656\n\t"
     88       "movl  %%esp, 4(%%edx)\n\t"
     89       "popl  %%eax\n\t"
     90       "movl  %%eax,8(%%edx)\n\t"
     91       "movl  0(%%edx),%%esp\n\t"
     92       "addl  $4, %%esp"
     93       : : "r"(&block) : "eax","edx","cc","memory"
     94     );
     95     printf("  pushl_pos: delta %d, top32 0x%08x\n",
     96            block[0] - block[1], block[2]);
     97 }
     98 
     99 void do_pushl_neg ( void )
    100 {
    101    unsigned int block[3];
    102    __asm__ __volatile__ (
    103       "movl  %0, %%edx\n\t"
    104       "pushl $0x55555555\n\t"
    105       "movl  %%esp, 0(%%edx)\n\t"
    106       "pushl $0x98988787\n\t"
    107       "movl  %%esp, 4(%%edx)\n\t"
    108       "popl  %%eax\n\t"
    109       "movl  %%eax,8(%%edx)\n\t"
    110       "movl  0(%%edx),%%esp\n\t"
    111       "addl  $4, %%esp"
    112       : : "r"(&block) : "eax","edx","cc","memory"
    113     );
    114     printf("  pushl_neg: delta %d, top32 0x%08x\n",
    115            block[0] - block[1], block[2]);
    116 }
    117 
    118 
    119 void do_66pushb_pos ( void )
    120 {
    121    unsigned int block[3];
    122    __asm__ __volatile__ (
    123       "movl  %0, %%edx\n\t"
    124       "pushl $0x55555555\n\t"
    125       "movl  %%esp, 0(%%edx)\n\t"
    126       ".byte 0x66,0x6A,0x22\n\t"
    127       "movl  %%esp, 4(%%edx)\n\t"
    128       "popl  %%eax\n\t"
    129       "movl  %%eax,8(%%edx)\n\t"
    130       "movl  0(%%edx),%%esp\n\t"
    131       "addl  $4, %%esp"
    132       : : "r"(&block) : "eax","edx","cc","memory"
    133     );
    134     printf("66pushb_pos: delta %d, top32 0x%08x\n",
    135            block[0] - block[1], block[2]);
    136 }
    137 
    138 void do_66pushb_neg ( void )
    139 {
    140    unsigned int block[3];
    141    __asm__ __volatile__ (
    142       "movl  %0, %%edx\n\t"
    143       "pushl $0x55555555\n\t"
    144       "movl  %%esp, 0(%%edx)\n\t"
    145       ".byte 0x66,0x6A,0xEE\n\t"
    146       "movl  %%esp, 4(%%edx)\n\t"
    147       "popl  %%eax\n\t"
    148       "movl  %%eax,8(%%edx)\n\t"
    149       "movl  0(%%edx),%%esp\n\t"
    150       "addl  $4, %%esp"
    151       : : "r"(&block) : "eax","edx","cc","memory"
    152     );
    153     printf("66pushb_neg: delta %d, top32 0x%08x\n",
    154            block[0] - block[1], block[2]);
    155 }
    156 
    157 
    158 int main ( void )
    159 {
    160   do_pushb_pos();
    161   do_pushb_neg();
    162   do_pushw_pos();
    163   do_pushw_neg();
    164   do_pushl_pos();
    165   do_pushl_neg();
    166 
    167   do_66pushb_pos();
    168   do_66pushb_neg();
    169   return 0;
    170 }
    171