Commit | Line | Data |
---|---|---|
e49d4fa6 SS |
1 | /* Target-dependent definitions for Intel x86 running DJGPP. |
2 | Copyright 1995, 1996, 1997 Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of GDB. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program; if not, write to the Free Software | |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
19 | ||
20 | #include "i386/tm-i386v.h" | |
21 | ||
22 | /* Number of machine registers. */ | |
23 | ||
24 | #undef NUM_FREGS | |
25 | #define NUM_FREGS 15 | |
26 | #undef NUM_REGS | |
27 | #define NUM_REGS (16+NUM_FREGS) | |
28 | ||
29 | /* Initializer for an array of names of registers. There should be | |
30 | NUM_REGS strings in this initializer. */ | |
31 | ||
32 | /* The order of the first 8 registers must match the compiler's | |
33 | numbering scheme (which is the same as the 386 scheme). */ | |
34 | ||
35 | #undef REGISTER_NAMES | |
36 | #define REGISTER_NAMES { "eax", "ecx", "edx", "ebx", \ | |
37 | "esp", "ebp", "esi", "edi", \ | |
38 | "eip", "eflags","cs", "ss", \ | |
39 | "ds", "es", "fs", "gs", \ | |
40 | "st0", "st1", "st2", "st3", \ | |
41 | "st4", "st5", "st6", "st7", \ | |
42 | "fctrl","fstat", "ftag", "fcs", \ | |
43 | "fopsel","fip", "fopoff" } | |
44 | ||
45 | #undef FP_REGNUM | |
46 | #define FP_REGNUM 5 /* (ebp) Contains addr of stack frame */ | |
47 | #undef SP_REGNUM | |
48 | #define SP_REGNUM 4 /* (usp) Contains address of top of stack */ | |
49 | #undef PS_REGNUM | |
50 | #define PS_REGNUM 9 /* (ps) Contains processor status */ | |
51 | #undef PC_REGNUM | |
52 | #define PC_REGNUM 8 /* (eip) Contains program counter */ | |
53 | #undef FP0_REGNUM | |
54 | #define FP0_REGNUM 16 /* Floating point register 0 */ | |
55 | #undef FPC_REGNUM | |
56 | #define FPC_REGNUM 24 /* 80387 control register */ | |
57 | #undef FPCWD_REGNUM | |
58 | #define FPCWD_REGNUM FPC_REGNUM | |
59 | #undef FPSWD_REGNUM | |
60 | #define FPSWD_REGNUM 25 /* 80387 status register */ | |
61 | #undef FPTWD_REGNUM | |
62 | #define FPTWD_REGNUM 26 /* 80387 tag register */ | |
63 | #undef FPIPO_REGNUM | |
64 | #define FPIPO_REGNUM 29 /* 80387 instruction pointer offset reg */ | |
65 | #undef FPIPS_REGNUM | |
66 | #define FPIPS_REGNUM 27 /* 80387 instruction pointer selector reg */ | |
67 | #undef FPOOS_REGNUM | |
68 | #define FPOOS_REGNUM 30 /* 80387 operand pointer offset reg */ | |
69 | #undef FPOPS_REGNUM | |
70 | #define FPOPS_REGNUM 28 /* 80387 operand pointer selector reg */ | |
71 | ||
72 | /* Total amount of space needed to store our copies of the machine's | |
73 | register state, the array `registers'. */ | |
74 | ||
75 | #undef REGISTER_BYTES | |
76 | #define REGISTER_BYTES (10*4 + 6*2 + 8*10 + 5*2 + 2*4) | |
77 | ||
78 | /* Index within `registers' of the first byte of the space for | |
79 | register N. */ | |
80 | ||
81 | #undef REGISTER_BYTE | |
82 | #define REGBYTE_0 0 | |
83 | #define REGBYTE_10 (REGBYTE_0+10*4) | |
84 | #define REGBYTE_16 (REGBYTE_10+6*2) | |
85 | #define REGBYTE_24 (REGBYTE_16+8*10) | |
86 | #define REGBYTE_29 (REGBYTE_24+5*2) | |
87 | #define REGISTER_BYTE(N) (((N) < 10) ? (N) * 4 : \ | |
88 | (N) < 16 ? REGBYTE_10 +((N) - 10) * 2 : \ | |
89 | (N) < 24 ? REGBYTE_16 +((N) - 16) * 10 : \ | |
90 | (N) < 29 ? REGBYTE_24 +((N) - 24) * 2 : \ | |
91 | REGBYTE_29 + ((N) - 29) * 4) | |
92 | ||
93 | /* Number of bytes of storage in the actual machine representation | |
94 | for register N. */ | |
95 | ||
96 | #undef REGISTER_RAW_SIZE | |
97 | #define REGISTER_RAW_SIZE(N) ((N) < 10 ? 4 : (N) < 16 ? 2 : (N) < 24 ? 10 : \ | |
98 | (N) < 29 ? 2 : 4) | |
99 | ||
100 | /* Number of bytes of storage in the program's representation | |
101 | for register N. */ | |
102 | ||
103 | #undef REGISTER_VIRTUAL_SIZE | |
104 | #define REGISTER_VIRTUAL_SIZE(N) REGISTER_RAW_SIZE(N) | |
105 | ||
106 | /* Largest value REGISTER_RAW_SIZE can have. */ | |
107 | ||
108 | #undef MAX_REGISTER_RAW_SIZE | |
109 | #define MAX_REGISTER_RAW_SIZE 10 | |
110 | ||
111 | /* Largest value REGISTER_VIRTUAL_SIZE can have. */ | |
112 | ||
113 | #undef MAX_REGISTER_VIRTUAL_SIZE | |
114 | #define MAX_REGISTER_VIRTUAL_SIZE 10 | |
115 | ||
116 | /* Nonzero if register N requires conversion | |
117 | from raw format to virtual format. */ | |
118 | ||
119 | #undef REGISTER_CONVERTIBLE | |
120 | #define REGISTER_CONVERTIBLE(N) ((N) < FP0_REGNUM ? 0 :\ | |
121 | (N) < FPC_REGNUM ? 1 : 0) | |
122 | ||
123 | /* The host and target are i386 machines and the compiler supports | |
124 | long doubles. Long doubles on the host therefore have the same | |
125 | layout as a 387 FPU stack register. */ | |
126 | ||
127 | #if defined(HAVE_LONG_DOUBLE) && defined(HOST_I386) | |
128 | #undef LD_I387 | |
129 | #define LD_I387 | |
130 | #endif | |
131 | ||
132 | /* Allow floating point numbers to be specified by a raw long double | |
133 | 10 hex bytes number, e.g. 1.0 can be input as | |
134 | 0x3fff8000000000000000 */ | |
135 | ||
136 | #ifdef LD_I387 | |
137 | #define HEX_LONG_DOUBLE_INPUT(base,p,len,target) \ | |
138 | ((base) == 16 && (len) == 20 \ | |
139 | && i387_hex_long_double_input ((p), (target))) | |
140 | #endif | |
141 | ||
142 | extern int i387_hex_long_double_input (char *p, long double *putithere); | |
143 | ||
144 | #undef REGISTER_CONVERT_TO_VIRTUAL | |
145 | #ifdef LD_I387 | |
146 | #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \ | |
147 | { \ | |
148 | if (TYPE == REGISTER_VIRTUAL_TYPE (REGNUM)) \ | |
149 | { \ | |
150 | memcpy (TO, FROM, TYPE_LENGTH (TYPE)); \ | |
151 | } \ | |
152 | else \ | |
153 | { \ | |
154 | long double val = *((long double *)FROM); \ | |
155 | store_floating ((TO), TYPE_LENGTH (TYPE), val); \ | |
156 | } \ | |
157 | } | |
158 | #else | |
159 | /* Convert data from raw format for register REGNUM in buffer FROM to | |
160 | virtual format with type TYPE in buffer TO. */ | |
161 | #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \ | |
162 | { \ | |
163 | double val; \ | |
164 | i387_to_double ((FROM), (char *)&val); \ | |
165 | store_floating ((TO), TYPE_LENGTH (TYPE), val); \ | |
166 | } | |
167 | #endif | |
168 | ||
169 | extern void i387_to_double PARAMS ((char *, char *)); | |
170 | ||
171 | #undef REGISTER_CONVERT_TO_RAW | |
172 | #ifdef LD_I387 | |
173 | #define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \ | |
174 | { \ | |
175 | if (TYPE == REGISTER_VIRTUAL_TYPE (REGNUM)) \ | |
176 | { \ | |
177 | memcpy (TO, FROM, TYPE_LENGTH (TYPE)); \ | |
178 | } \ | |
179 | else \ | |
180 | { \ | |
181 | long double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \ | |
182 | *((long double *)TO) = val; \ | |
183 | } \ | |
184 | } | |
185 | #else | |
186 | #define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \ | |
187 | { \ | |
188 | double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \ | |
189 | double_to_i387((char *)&val, (TO)); \ | |
190 | } | |
191 | #endif | |
192 | ||
193 | extern void double_to_i387 PARAMS ((char *, char *)); | |
194 | ||
195 | /* Return the GDB type object for the "standard" data type of data in | |
196 | register N. */ | |
197 | ||
198 | #undef REGISTER_VIRTUAL_TYPE | |
199 | #ifdef LD_I387 | |
200 | #define REGISTER_VIRTUAL_TYPE(N) \ | |
201 | ((N < FP0_REGNUM) ? builtin_type_int : \ | |
202 | (N < FPC_REGNUM) ? builtin_type_long_double : builtin_type_int) | |
203 | #else | |
204 | #define REGISTER_VIRTUAL_TYPE(N) \ | |
205 | ((N < FP0_REGNUM) ? builtin_type_int : \ | |
206 | (N < FPC_REGNUM) ? builtin_type_double : builtin_type_int) | |
207 | #endif | |
208 | ||
209 | #undef TARGET_LONG_DOUBLE_BIT | |
210 | #define TARGET_LONG_DOUBLE_BIT 96 | |
211 | ||
212 | #define NAMES_HAVE_UNDERSCORE |