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