thughes | 0ee72ef | 2004-03-04 23:36:58 +0000 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | |
| 4 | int 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 | |
thughes | a02aee1 | 2004-03-15 12:58:55 +0000 | [diff] [blame] | 26 | printf("sp change after push = %ld\n", sp2 - sp1); |
| 27 | printf("sp change after pop = %ld\n", sp3 - sp2); |
thughes | 0ee72ef | 2004-03-04 23:36:58 +0000 | [diff] [blame] | 28 | 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 | |
thughes | a02aee1 | 2004-03-15 12:58:55 +0000 | [diff] [blame] | 42 | printf("sp change after push = %ld\n", sp2 - sp1); |
| 43 | printf("sp change after pop = %ld\n", sp3 - sp2); |
thughes | 0ee72ef | 2004-03-04 23:36:58 +0000 | [diff] [blame] | 44 | printf("fs after push and pop = %04x\n", fs1); |
| 45 | |
| 46 | exit(0); |
| 47 | } |