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