blob: 5f84b7331d4d48b5f8fc5eb89a14a2f6379a54e8 [file] [log] [blame]
thughes0ee72ef2004-03-04 23:36:58 +00001#include <stdio.h>
2#include <stdlib.h>
3
4int main(int argc, char **argv)
5{
6 unsigned long sp1;
7 unsigned long sp2;
8 unsigned long sp3;
9 unsigned short fs1;
10 unsigned short fs2;
11
12 fs1 = 0x0003;
13
14 asm("movw %4, %%fs\n"
15 "movl %%esp, %0\n"
16 "pushw %%fs\n"
17 "movl %%esp, %1\n"
18 "popw %%fs\n"
19 "movl %%esp, %2\n"
20 "movw %%fs, %3\n"
21 : "=m" (sp1), "=m" (sp2), "=m" (sp3), "=m" (fs2)
22 : "m" (fs1)
23 : "ax"
24 );
25
thughesa02aee12004-03-15 12:58:55 +000026 printf("sp change after push = %ld\n", sp2 - sp1);
27 printf("sp change after pop = %ld\n", sp3 - sp2);
thughes0ee72ef2004-03-04 23:36:58 +000028 printf("fs after push and pop = %04x\n", fs1);
29
30 asm("movw %4, %%fs\n"
31 "movl %%esp, %0\n"
32 "pushl %%fs\n"
33 "movl %%esp, %1\n"
34 "popl %%fs\n"
35 "movl %%esp, %2\n"
36 "movw %%fs, %3\n"
37 : "=m" (sp1), "=m" (sp2), "=m" (sp3), "=m" (fs2)
38 : "m" (fs1)
39 : "ax"
40 );
41
thughesa02aee12004-03-15 12:58:55 +000042 printf("sp change after push = %ld\n", sp2 - sp1);
43 printf("sp change after pop = %ld\n", sp3 - sp2);
thughes0ee72ef2004-03-04 23:36:58 +000044 printf("fs after push and pop = %04x\n", fs1);
45
46 exit(0);
47}