Commit | Line | Data |
---|---|---|
1ba53b71 L |
1 | /* Test program for byte registers. |
2 | ||
b811d2c2 | 3 | Copyright 2010-2020 Free Software Foundation, Inc. |
1ba53b71 L |
4 | |
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 3 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
19 | ||
20 | #include <stdio.h> | |
21 | ||
22 | int data[] = { | |
23 | 0x14131211, | |
24 | 0x24232221, | |
25 | 0x34333231, | |
26 | 0x44434241, | |
27 | 0x54535251, | |
28 | 0x64636261, | |
29 | 0x74737271, | |
30 | 0x84838281, | |
31 | 0x94939291, | |
32 | 0xa4a3a2a1, | |
33 | 0xb4b3b2b1, | |
34 | 0xc4c3c2c1, | |
35 | 0xd4d3d2d1, | |
36 | 0xe4e3e2e1, | |
37 | }; | |
38 | ||
39 | int | |
40 | main (int argc, char **argv) | |
41 | { | |
fb0576e9 DE |
42 | register int eax asm ("eax"); |
43 | register int ebx asm ("ebx"); | |
44 | register int ecx asm ("ecx"); | |
45 | register int edx asm ("edx"); | |
46 | register int esi asm ("esi"); | |
47 | register int edi asm ("edi"); | |
48 | register long r8 asm ("r8"); | |
49 | register long r9 asm ("r9"); | |
50 | register long r10 asm ("r10"); | |
51 | register long r11 asm ("r11"); | |
52 | register long r12 asm ("r12"); | |
53 | register long r13 asm ("r13"); | |
54 | register long r14 asm ("r14"); | |
55 | register long r15 asm ("r15"); | |
56 | ||
1ba53b71 L |
57 | asm ("mov 0(%0), %%eax\n\t" |
58 | "mov 4(%0), %%ebx\n\t" | |
59 | "mov 8(%0), %%ecx\n\t" | |
60 | "mov 12(%0), %%edx\n\t" | |
61 | "mov 16(%0), %%esi\n\t" | |
62 | "mov 20(%0), %%edi\n\t" | |
63 | : /* no output operands */ | |
64 | : "r" (data) | |
65 | : "eax", "ebx", "ecx", "edx", "esi", "edi"); | |
66 | asm ("nop"); /* first breakpoint here */ | |
67 | ||
68 | asm ("mov 24(%0), %%r8d\n\t" | |
69 | "mov 28(%0), %%r9d\n\t" | |
70 | "mov 32(%0), %%r10d\n\t" | |
71 | "mov 36(%0), %%r11\n\t" | |
72 | "mov 40(%0), %%r12d\n\t" | |
73 | "mov 44(%0), %%r13d\n\t" | |
74 | "mov 48(%0), %%r14d\n\t" | |
75 | "mov 52(%0), %%r15d\n\t" | |
76 | : /* no output operands */ | |
77 | : "r" (data) | |
78 | : "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"); | |
1ba53b71 | 79 | |
fb0576e9 DE |
80 | asm ("nop" /* second breakpoint here */ |
81 | /* amd64-{byte,word,dword}.exp write eax-edi here. | |
82 | Tell gcc/clang they're live. */ | |
83 | : "=r" (eax), "=r" (ebx), "=r" (ecx), | |
84 | "=r" (edx), "=r" (esi), "=r" (edi) | |
85 | : /* no inputs */); | |
c207c6da | 86 | |
1ba53b71 L |
87 | asm ("mov %%eax, 0(%0)\n\t" |
88 | "mov %%ebx, 4(%0)\n\t" | |
89 | "mov %%ecx, 8(%0)\n\t" | |
90 | "mov %%edx, 12(%0)\n\t" | |
91 | "mov %%esi, 16(%0)\n\t" | |
92 | "mov %%edi, 20(%0)\n\t" | |
93 | : /* no output operands */ | |
fb0576e9 DE |
94 | : "r" (data), |
95 | /* Mark these as inputs so that gcc/clang won't try to use them as | |
96 | a temp to build %0. */ | |
97 | "r" (eax), "r" (ebx), "r" (ecx), | |
98 | "r" (edx), "r" (esi), "r" (edi)); | |
1ba53b71 | 99 | |
fb0576e9 DE |
100 | asm ("nop" /* third breakpoint here */ |
101 | /* amd64-{byte,word,dword}.exp write r8-r15 here. | |
102 | Tell gcc/clang they're live. */ | |
103 | : "=r" (r8), "=r" (r9), "=r" (r10), "=r" (r11), | |
104 | "=r" (r12), "=r" (r13), "=r" (r14), "=r" (r15) | |
105 | : /* no inputs */); | |
c207c6da | 106 | |
1ba53b71 L |
107 | asm ("mov %%r8d, 24(%0)\n\t" |
108 | "mov %%r9d, 28(%0)\n\t" | |
109 | "mov %%r10d, 32(%0)\n\t" | |
110 | "mov %%r11d, 36(%0)\n\t" | |
111 | "mov %%r12d, 40(%0)\n\t" | |
112 | "mov %%r13d, 44(%0)\n\t" | |
113 | "mov %%r14d, 48(%0)\n\t" | |
114 | "mov %%r15d, 52(%0)\n\t" | |
115 | : /* no output operands */ | |
fb0576e9 DE |
116 | : "r" (data), |
117 | /* Mark these as inputs so that gcc/clang won't try to use them as | |
118 | a temp to build %0. */ | |
119 | "r" (r8), "r" (r9), "r" (r10), "r" (r11), | |
120 | "r" (r12), "r" (r13), "r" (r14), "r" (r15)); | |
1ba53b71 L |
121 | puts ("Bye!"); /* forth breakpoint here */ |
122 | ||
123 | return 0; | |
124 | } |