]>
Commit | Line | Data |
---|---|---|
dd3b648e | 1 | /* Parameters for execution on a 68000 series machine. |
75af490b | 2 | Copyright 1986, 1987, 1989, 1990, 1992 Free Software Foundation, Inc. |
dd3b648e RP |
3 | |
4 | This file is part of GDB. | |
5 | ||
99a7de40 | 6 | This program is free software; you can redistribute it and/or modify |
dd3b648e | 7 | it under the terms of the GNU General Public License as published by |
99a7de40 JG |
8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | |
dd3b648e | 10 | |
99a7de40 | 11 | This program is distributed in the hope that it will be useful, |
dd3b648e RP |
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 | |
99a7de40 JG |
17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
dd3b648e | 19 | |
84d82b1c | 20 | /* Generic 68000 stuff, to be included by other tm-*.h files. |
dd3b648e RP |
21 | Define HAVE_68881 if that is the case. */ |
22 | ||
23 | #if defined (HAVE_68881) | |
24 | #define IEEE_FLOAT 1 | |
25 | #endif | |
26 | ||
27 | /* Define the bit, byte, and word ordering of the machine. */ | |
28 | #define TARGET_BYTE_ORDER BIG_ENDIAN | |
29 | ||
30 | /* Offset from address of function to start of its code. | |
31 | Zero on most machines. */ | |
32 | ||
33 | #define FUNCTION_START_OFFSET 0 | |
34 | ||
35 | /* Advance PC across any function entry prologue instructions | |
36 | to reach some "real" code. */ | |
37 | ||
b6666a5d FF |
38 | #if !defined(SKIP_PROLOGUE) |
39 | #define SKIP_PROLOGUE(ip) {(ip) = m68k_skip_prologue(ip);} | |
75af490b | 40 | extern CORE_ADDR m68k_skip_prologue PARAMS ((CORE_ADDR ip)); |
b6666a5d | 41 | #endif |
dd3b648e RP |
42 | |
43 | /* Immediately after a function call, return the saved pc. | |
44 | Can't always go through the frames for this because on some machines | |
45 | the new frame is not set up until the new function executes | |
46 | some instructions. */ | |
47 | ||
48 | #define SAVED_PC_AFTER_CALL(frame) \ | |
49 | read_memory_integer (read_register (SP_REGNUM), 4) | |
50 | ||
51 | /* Stack grows downward. */ | |
52 | ||
53 | #define INNER_THAN < | |
54 | ||
55 | /* Sequence of bytes for breakpoint instruction. | |
56 | This is a TRAP instruction. The last 4 bits (0xf below) is the | |
84d82b1c | 57 | vector. Systems which don't use 0xf should define BPT_VECTOR |
dd3b648e RP |
58 | themselves before including this file. */ |
59 | ||
b6666a5d | 60 | #if !defined (BPT_VECTOR) |
84d82b1c FF |
61 | #define BPT_VECTOR 0xf |
62 | #endif | |
63 | ||
dd3b648e | 64 | #if !defined (BREAKPOINT) |
84d82b1c | 65 | #define BREAKPOINT {0x4e, (0x40 | BPT_VECTOR)} |
dd3b648e RP |
66 | #endif |
67 | ||
68 | /* If your kernel resets the pc after the trap happens you may need to | |
dcd15e5e | 69 | define this before including this file. */ |
dd3b648e RP |
70 | |
71 | #if !defined (DECR_PC_AFTER_BREAK) | |
72 | #define DECR_PC_AFTER_BREAK 2 | |
73 | #endif | |
74 | ||
75 | /* Nonzero if instruction at PC is a return instruction. */ | |
76 | /* Allow any of the return instructions, including a trapv and a return | |
77 | from interupt. */ | |
78 | ||
79 | #define ABOUT_TO_RETURN(pc) ((read_memory_integer (pc, 2) & ~0x3) == 0x4e74) | |
80 | ||
81 | /* Return 1 if P points to an invalid floating point value. */ | |
82 | ||
83 | #define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */ | |
84 | ||
85 | /* Say how long registers are. */ | |
86 | ||
87 | #define REGISTER_TYPE long | |
88 | ||
89 | #if defined (HAVE_68881) | |
39d2bcca | 90 | # if defined (GDB_TARGET_IS_SUN3) |
dd3b648e RP |
91 | /* Sun3 status includes fpflags, which shows whether the FPU has been used |
92 | by the process, and whether the FPU was done with an instruction or | |
93 | was interrupted in the middle of a long instruction. See | |
94 | <machine/reg.h>. */ | |
95 | /* a&d, pc,sr, fp, fpstat, fpflags */ | |
96 | # define NUM_REGS 31 | |
97 | # define REGISTER_BYTES (16*4 + 8 + 8*12 + 3*4 + 4) | |
98 | # else /* Not sun3. */ | |
99 | # define NUM_REGS 29 | |
100 | # define REGISTER_BYTES (16*4 + 8 + 8*12 + 3*4) | |
101 | # endif /* Not sun3. */ | |
102 | #else /* No 68881. */ | |
103 | # define NUM_REGS 18 | |
104 | # define REGISTER_BYTES (16*4 + 8) | |
105 | #endif /* No 68881. */ | |
106 | ||
107 | /* Index within `registers' of the first byte of the space for | |
108 | register N. */ | |
109 | ||
110 | #if defined (HAVE_68881) | |
111 | #define REGISTER_BYTE(N) \ | |
112 | ((N) >= FPC_REGNUM ? (((N) - FPC_REGNUM) * 4) + 168 \ | |
113 | : (N) >= FP0_REGNUM ? (((N) - FP0_REGNUM) * 12) + 72 \ | |
114 | : (N) * 4) | |
115 | ||
116 | /* Number of bytes of storage in the actual machine representation | |
117 | for register N. On the 68000, all regs are 4 bytes | |
118 | except the floating point regs which are 12 bytes. */ | |
119 | /* Note that the unsigned cast here forces the result of the | |
120 | subtraction to very high positive values if N < FP0_REGNUM */ | |
121 | ||
122 | #define REGISTER_RAW_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 12 : 4) | |
123 | ||
124 | /* Number of bytes of storage in the program's representation | |
125 | for register N. On the 68000, all regs are 4 bytes | |
126 | except the floating point regs which are 8-byte doubles. */ | |
127 | ||
128 | #define REGISTER_VIRTUAL_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 8 : 4) | |
129 | ||
130 | /* Largest value REGISTER_RAW_SIZE can have. */ | |
131 | ||
132 | #define MAX_REGISTER_RAW_SIZE 12 | |
133 | ||
134 | /* Largest value REGISTER_VIRTUAL_SIZE can have. */ | |
135 | ||
136 | #define MAX_REGISTER_VIRTUAL_SIZE 8 | |
137 | ||
138 | /* Nonzero if register N requires conversion | |
139 | from raw format to virtual format. */ | |
140 | ||
141 | #define REGISTER_CONVERTIBLE(N) (((unsigned)(N) - FP0_REGNUM) < 8) | |
142 | ||
de6060de JK |
143 | /* Put the declaration out here because if it's in the macros, PCC |
144 | will complain. */ | |
75af490b | 145 | extern const struct ext_format ext_format_68881; |
de6060de | 146 | |
dd3b648e RP |
147 | /* Convert data from raw format for register REGNUM |
148 | to virtual format for register REGNUM. */ | |
149 | ||
150 | #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ | |
151 | { \ | |
dd3b648e | 152 | if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ |
9fa28378 | 153 | ieee_extended_to_double (&ext_format_68881, (FROM), (double *)(TO)); \ |
dd3b648e | 154 | else \ |
75af490b | 155 | memcpy ((TO), (FROM), 4); \ |
dd3b648e RP |
156 | } |
157 | ||
158 | /* Convert data from virtual format for register REGNUM | |
159 | to raw format for register REGNUM. */ | |
160 | ||
161 | #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ | |
162 | { \ | |
dd3b648e | 163 | if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ |
9fa28378 | 164 | double_to_ieee_extended (&ext_format_68881, (double *)(FROM), (TO)); \ |
dd3b648e | 165 | else \ |
75af490b | 166 | memcpy ((TO), (FROM), 4); \ |
dd3b648e RP |
167 | } |
168 | ||
169 | /* Return the GDB type object for the "standard" data type | |
170 | of data in register N. */ | |
171 | /* Note, for registers which contain addresses return | |
172 | pointer to void, not pointer to char, because we don't | |
173 | want to attempt to print the string after printing the address. */ | |
174 | #define REGISTER_VIRTUAL_TYPE(N) \ | |
175 | (((unsigned)(N) - FP0_REGNUM) < 8 ? builtin_type_double : \ | |
176 | (N) == PC_REGNUM || (N) == FP_REGNUM || (N) == SP_REGNUM ? \ | |
177 | lookup_pointer_type (builtin_type_void) : builtin_type_int) | |
178 | ||
179 | #else /* no 68881. */ | |
180 | /* Index within `registers' of the first byte of the space for | |
181 | register N. */ | |
182 | ||
183 | #define REGISTER_BYTE(N) ((N) * 4) | |
184 | ||
185 | /* Number of bytes of storage in the actual machine representation | |
186 | for register N. On the 68000, all regs are 4 bytes. */ | |
187 | ||
188 | #define REGISTER_RAW_SIZE(N) 4 | |
189 | ||
190 | /* Number of bytes of storage in the program's representation | |
191 | for register N. On the 68000, all regs are 4 bytes. */ | |
192 | ||
193 | #define REGISTER_VIRTUAL_SIZE(N) 4 | |
194 | ||
195 | /* Largest value REGISTER_RAW_SIZE can have. */ | |
196 | ||
197 | #define MAX_REGISTER_RAW_SIZE 4 | |
198 | ||
199 | /* Largest value REGISTER_VIRTUAL_SIZE can have. */ | |
200 | ||
201 | #define MAX_REGISTER_VIRTUAL_SIZE 4 | |
202 | ||
203 | /* Nonzero if register N requires conversion | |
204 | from raw format to virtual format. */ | |
205 | ||
206 | #define REGISTER_CONVERTIBLE(N) 0 | |
207 | ||
208 | /* Convert data from raw format for register REGNUM | |
209 | to virtual format for register REGNUM. */ | |
210 | ||
75af490b | 211 | #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) memcpy ((TO), (FROM), 4); |
dd3b648e RP |
212 | |
213 | /* Convert data from virtual format for register REGNUM | |
214 | to raw format for register REGNUM. */ | |
215 | ||
75af490b | 216 | #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) memcpy ((TO), (FROM), 4); |
dd3b648e RP |
217 | |
218 | /* Return the GDB type object for the "standard" data type | |
219 | of data in register N. */ | |
220 | ||
221 | #define REGISTER_VIRTUAL_TYPE(N) builtin_type_int | |
222 | ||
223 | #endif /* No 68881. */ | |
224 | ||
225 | /* Initializer for an array of names of registers. | |
226 | Entries beyond the first NUM_REGS are ignored. */ | |
227 | ||
228 | #define REGISTER_NAMES \ | |
229 | {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \ | |
230 | "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp", \ | |
231 | "ps", "pc", \ | |
232 | "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7", \ | |
233 | "fpcontrol", "fpstatus", "fpiaddr", "fpcode", "fpflags" } | |
234 | ||
235 | /* Register numbers of various important registers. | |
236 | Note that some of these values are "real" register numbers, | |
237 | and correspond to the general registers of the machine, | |
238 | and some are "phony" register numbers which are too large | |
239 | to be actual register numbers as far as the user is concerned | |
240 | but do serve to get the desired values when passed to read_register. */ | |
241 | ||
242 | #define A1_REGNUM 9 | |
243 | #define FP_REGNUM 14 /* Contains address of executing stack frame */ | |
244 | #define SP_REGNUM 15 /* Contains address of top of stack */ | |
245 | #define PS_REGNUM 16 /* Contains processor status */ | |
246 | #define PC_REGNUM 17 /* Contains program counter */ | |
247 | #if defined (HAVE_68881) | |
248 | #define FP0_REGNUM 18 /* Floating point register 0 */ | |
249 | #define FPC_REGNUM 26 /* 68881 control register */ | |
250 | #define FPS_REGNUM 27 /* 68881 status register */ | |
afe4ca15 | 251 | #define FPI_REGNUM 28 /* 68881 iaddr register */ |
dd3b648e RP |
252 | #endif /* 68881. */ |
253 | ||
254 | /* Store the address of the place in which to copy the structure the | |
255 | subroutine will return. This is called from call_function. */ | |
256 | ||
257 | #define STORE_STRUCT_RETURN(ADDR, SP) \ | |
258 | { write_register (A1_REGNUM, (ADDR)); } | |
259 | ||
260 | /* Extract from an array REGBUF containing the (raw) register state | |
261 | a function return value of type TYPE, and copy that, in virtual format, | |
262 | into VALBUF. This is assuming that floating point values are returned | |
263 | as doubles in d0/d1. */ | |
264 | ||
265 | #if !defined (EXTRACT_RETURN_VALUE) | |
266 | #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ | |
75af490b JG |
267 | memcpy ((VALBUF), \ |
268 | (char *)(REGBUF) + \ | |
5ab580cc | 269 | (TYPE_LENGTH(TYPE) >= 4 ? 0 : 4 - TYPE_LENGTH(TYPE)), \ |
75af490b | 270 | TYPE_LENGTH(TYPE)) |
dd3b648e RP |
271 | #endif |
272 | ||
273 | /* Write into appropriate registers a function return value | |
274 | of type TYPE, given in virtual format. Assumes floats are passed | |
275 | in d0/d1. */ | |
276 | ||
277 | #if !defined (STORE_RETURN_VALUE) | |
278 | #define STORE_RETURN_VALUE(TYPE,VALBUF) \ | |
279 | write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) | |
280 | #endif | |
281 | ||
282 | /* Extract from an array REGBUF containing the (raw) register state | |
283 | the address in which a function should return its structure value, | |
284 | as a CORE_ADDR (or an expression that can be used as one). */ | |
285 | ||
e1ce8aa5 | 286 | #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(CORE_ADDR *)(REGBUF)) |
dd3b648e RP |
287 | \f |
288 | /* Describe the pointer in each stack frame to the previous stack frame | |
289 | (its caller). */ | |
290 | ||
5e2e79f8 FF |
291 | /* FRAME_CHAIN takes a frame's nominal address and produces the frame's |
292 | chain-pointer. | |
293 | In the case of the 68000, the frame's nominal address | |
dd3b648e RP |
294 | is the address of a 4-byte word containing the calling frame's address. */ |
295 | ||
296 | #define FRAME_CHAIN(thisframe) \ | |
5e2e79f8 | 297 | (!inside_entry_file ((thisframe)->pc) ? \ |
dd3b648e RP |
298 | read_memory_integer ((thisframe)->frame, 4) :\ |
299 | 0) | |
300 | ||
dd3b648e RP |
301 | /* Define other aspects of the stack frame. */ |
302 | ||
303 | /* A macro that tells us whether the function invocation represented | |
304 | by FI does not have a frame on the stack associated with it. If it | |
305 | does not, FRAMELESS is set to 1, else 0. */ | |
306 | #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ | |
307 | (FRAMELESS) = frameless_look_for_prologue(FI) | |
308 | ||
309 | #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) | |
310 | ||
311 | #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) | |
312 | ||
313 | #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) | |
314 | ||
315 | /* Set VAL to the number of args passed to frame described by FI. | |
316 | Can set VAL to -1, meaning no way to tell. */ | |
317 | ||
318 | /* We can't tell how many args there are | |
319 | now that the C compiler delays popping them. */ | |
320 | #if !defined (FRAME_NUM_ARGS) | |
321 | #define FRAME_NUM_ARGS(val,fi) (val = -1) | |
322 | #endif | |
323 | ||
324 | /* Return number of bytes at start of arglist that are not really args. */ | |
325 | ||
326 | #define FRAME_ARGS_SKIP 8 | |
327 | ||
328 | /* Put here the code to store, into a struct frame_saved_regs, | |
329 | the addresses of the saved registers of frame described by FRAME_INFO. | |
330 | This includes special registers such as pc and fp saved in special | |
331 | ways in the stack frame. sp is even more special: | |
332 | the address we return for it IS the sp for the next frame. */ | |
333 | ||
334 | #if !defined (FRAME_FIND_SAVED_REGS) | |
335 | #if defined (HAVE_68881) | |
336 | #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ | |
337 | { register int regnum; \ | |
338 | register int regmask; \ | |
339 | register CORE_ADDR next_addr; \ | |
340 | register CORE_ADDR pc; \ | |
341 | int nextinsn; \ | |
342 | bzero (&frame_saved_regs, sizeof frame_saved_regs); \ | |
343 | if ((frame_info)->pc >= (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 8*12 - 4 \ | |
344 | && (frame_info)->pc <= (frame_info)->frame) \ | |
345 | { next_addr = (frame_info)->frame; \ | |
346 | pc = (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 8*12 - 4; }\ | |
347 | else \ | |
348 | { pc = get_pc_function_start ((frame_info)->pc); \ | |
349 | /* Verify we have a link a6 instruction next; \ | |
350 | if not we lose. If we win, find the address above the saved \ | |
351 | regs using the amount of storage from the link instruction. */\ | |
352 | if (044016 == read_memory_integer (pc, 2)) \ | |
353 | next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 4), pc+=4; \ | |
354 | else if (047126 == read_memory_integer (pc, 2)) \ | |
355 | next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 2), pc+=2; \ | |
356 | else goto lose; \ | |
357 | /* If have an addal #-n, sp next, adjust next_addr. */ \ | |
358 | if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \ | |
359 | next_addr += read_memory_integer (pc += 2, 4), pc += 4; \ | |
360 | } \ | |
361 | /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \ | |
362 | regmask = read_memory_integer (pc + 2, 2); \ | |
363 | /* But before that can come an fmovem. Check for it. */ \ | |
364 | nextinsn = 0xffff & read_memory_integer (pc, 2); \ | |
365 | if (0xf227 == nextinsn \ | |
366 | && (regmask & 0xff00) == 0xe000) \ | |
367 | { pc += 4; /* Regmask's low bit is for register fp7, the first pushed */ \ | |
368 | for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \ | |
369 | if (regmask & 1) \ | |
370 | (frame_saved_regs).regs[regnum] = (next_addr -= 12); \ | |
371 | regmask = read_memory_integer (pc + 2, 2); } \ | |
372 | if (0044327 == read_memory_integer (pc, 2)) \ | |
373 | { pc += 4; /* Regmask's low bit is for register 0, the first written */ \ | |
374 | for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \ | |
375 | if (regmask & 1) \ | |
376 | (frame_saved_regs).regs[regnum] = (next_addr += 4) - 4; } \ | |
377 | else if (0044347 == read_memory_integer (pc, 2)) \ | |
378 | { pc += 4; /* Regmask's low bit is for register 15, the first pushed */ \ | |
379 | for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \ | |
380 | if (regmask & 1) \ | |
381 | (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ | |
382 | else if (0x2f00 == (0xfff0 & read_memory_integer (pc, 2))) \ | |
383 | { regnum = 0xf & read_memory_integer (pc, 2); pc += 2; \ | |
384 | (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ | |
385 | /* fmovemx to index of sp may follow. */ \ | |
386 | regmask = read_memory_integer (pc + 2, 2); \ | |
387 | nextinsn = 0xffff & read_memory_integer (pc, 2); \ | |
388 | if (0xf236 == nextinsn \ | |
389 | && (regmask & 0xff00) == 0xf000) \ | |
390 | { pc += 10; /* Regmask's low bit is for register fp0, the first written */ \ | |
391 | for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \ | |
392 | if (regmask & 1) \ | |
393 | (frame_saved_regs).regs[regnum] = (next_addr += 12) - 12; \ | |
394 | regmask = read_memory_integer (pc + 2, 2); } \ | |
395 | /* clrw -(sp); movw ccr,-(sp) may follow. */ \ | |
396 | if (0x426742e7 == read_memory_integer (pc, 4)) \ | |
397 | (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \ | |
398 | lose: ; \ | |
399 | (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 8; \ | |
400 | (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \ | |
401 | (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \ | |
402 | } | |
403 | #else /* no 68881. */ | |
404 | #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ | |
405 | { register int regnum; \ | |
406 | register int regmask; \ | |
407 | register CORE_ADDR next_addr; \ | |
408 | register CORE_ADDR pc; \ | |
409 | bzero (&frame_saved_regs, sizeof frame_saved_regs); \ | |
410 | if ((frame_info)->pc >= (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 4 \ | |
411 | && (frame_info)->pc <= (frame_info)->frame) \ | |
412 | { next_addr = (frame_info)->frame; \ | |
413 | pc = (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 4; }\ | |
414 | else \ | |
415 | { pc = get_pc_function_start ((frame_info)->pc); \ | |
416 | /* Verify we have a link a6 instruction next; \ | |
417 | if not we lose. If we win, find the address above the saved \ | |
418 | regs using the amount of storage from the link instruction. */\ | |
419 | if (044016 == read_memory_integer (pc, 2)) \ | |
420 | next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 4), pc+=4; \ | |
421 | else if (047126 == read_memory_integer (pc, 2)) \ | |
422 | next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 2), pc+=2; \ | |
423 | else goto lose; \ | |
424 | /* If have an addal #-n, sp next, adjust next_addr. */ \ | |
425 | if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \ | |
426 | next_addr += read_memory_integer (pc += 2, 4), pc += 4; \ | |
427 | } \ | |
428 | /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \ | |
429 | regmask = read_memory_integer (pc + 2, 2); \ | |
430 | if (0044327 == read_memory_integer (pc, 2)) \ | |
431 | { pc += 4; /* Regmask's low bit is for register 0, the first written */ \ | |
432 | for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \ | |
433 | if (regmask & 1) \ | |
434 | (frame_saved_regs).regs[regnum] = (next_addr += 4) - 4; } \ | |
435 | else if (0044347 == read_memory_integer (pc, 2)) \ | |
436 | { pc += 4; /* Regmask's low bit is for register 15, the first pushed */ \ | |
437 | for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \ | |
438 | if (regmask & 1) \ | |
439 | (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ | |
6c316cfd | 440 | else if (0x2f00 == (0xfff0 & read_memory_integer (pc, 2))) \ |
dd3b648e RP |
441 | { regnum = 0xf & read_memory_integer (pc, 2); pc += 2; \ |
442 | (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ | |
443 | /* clrw -(sp); movw ccr,-(sp) may follow. */ \ | |
444 | if (0x426742e7 == read_memory_integer (pc, 4)) \ | |
445 | (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \ | |
446 | lose: ; \ | |
447 | (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 8; \ | |
448 | (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \ | |
449 | (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \ | |
450 | } | |
451 | #endif /* no 68881. */ | |
452 | #endif /* no FIND_FRAME_SAVED_REGS. */ | |
453 | ||
dcd15e5e FF |
454 | \f |
455 | /* Things needed for making the inferior call functions. | |
456 | It seems like every m68k based machine has almost identical definitions | |
457 | in the individual machine's configuration files. Most other cpu types | |
458 | (mips, i386, etc) have routines in their *-tdep.c files to handle this | |
459 | for most configurations. The m68k family should be able to do this as | |
460 | well. These macros can still be overridden when necessary. */ | |
461 | ||
84d82b1c FF |
462 | /* The CALL_DUMMY macro is the sequence of instructions, as disassembled |
463 | by gdb itself: | |
464 | ||
465 | fmovemx fp0-fp7,sp@- 0xf227 0xe0ff | |
466 | moveml d0-a5,sp@- 0x48e7 0xfffc | |
467 | clrw sp@- 0x4267 | |
468 | movew ccr,sp@- 0x42e7 | |
469 | ||
470 | /..* The arguments are pushed at this point by GDB; | |
dcd15e5e FF |
471 | no code is needed in the dummy for this. |
472 | The CALL_DUMMY_START_OFFSET gives the position of | |
473 | the following jsr instruction. *../ | |
dcd15e5e | 474 | |
84d82b1c FF |
475 | jsr @#0x32323232 0x4eb9 0x3232 0x3232 |
476 | addal #0x69696969,sp 0xdffc 0x6969 0x6969 | |
477 | trap #<your BPT_VECTOR number here> 0x4e4? | |
478 | nop 0x4e71 | |
479 | ||
480 | Note this is CALL_DUMMY_LENGTH bytes (28 for the above example). | |
481 | We actually start executing at the jsr, since the pushing of the | |
482 | registers is done by PUSH_DUMMY_FRAME. If this were real code, | |
483 | the arguments for the function called by the jsr would be pushed | |
484 | between the moveml and the jsr, and we could allow it to execute through. | |
485 | But the arguments have to be pushed by GDB after the PUSH_DUMMY_FRAME is | |
486 | done, and we cannot allow the moveml to push the registers again lest | |
487 | they be taken for the arguments. */ | |
488 | ||
489 | #if defined (HAVE_68881) | |
490 | ||
491 | #define CALL_DUMMY {0xf227e0ff, 0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, (0x4e404e71 | (BPT_VECTOR << 16))} | |
492 | #define CALL_DUMMY_LENGTH 28 /* Size of CALL_DUMMY */ | |
493 | #define CALL_DUMMY_START_OFFSET 12 /* Offset to jsr instruction*/ | |
494 | ||
495 | #else | |
dcd15e5e | 496 | |
84d82b1c FF |
497 | #define CALL_DUMMY {0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, (0x4e404e71 | (BPT_VECTOR << 16))} |
498 | #define CALL_DUMMY_LENGTH 24 /* Size of CALL_DUMMY */ | |
499 | #define CALL_DUMMY_START_OFFSET 8 /* Offset to jsr instruction*/ | |
dcd15e5e | 500 | |
84d82b1c | 501 | #endif /* HAVE_68881 */ |
dcd15e5e FF |
502 | |
503 | /* Insert the specified number of args and function address | |
f70be3e4 JG |
504 | into a call sequence of the above form stored at DUMMYNAME. |
505 | We use the BFD routines to store a big-endian value of known size. */ | |
dcd15e5e FF |
506 | |
507 | #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \ | |
f70be3e4 JG |
508 | { _do_putb32 (fun, (char *) dummyname + CALL_DUMMY_START_OFFSET + 2); \ |
509 | _do_putb32 (nargs*4, (char *) dummyname + CALL_DUMMY_START_OFFSET + 8); } | |
dcd15e5e FF |
510 | |
511 | /* Push an empty stack frame, to record the current PC, etc. */ | |
512 | ||
513 | #define PUSH_DUMMY_FRAME { m68k_push_dummy_frame (); } | |
514 | ||
75af490b JG |
515 | extern void m68k_push_dummy_frame PARAMS ((void)); |
516 | ||
30875e1c SG |
517 | extern void m68k_pop_frame PARAMS ((void)); |
518 | ||
dcd15e5e FF |
519 | /* Discard from the stack the innermost frame, restoring all registers. */ |
520 | ||
84d82b1c | 521 | #define POP_FRAME { m68k_pop_frame (); } |
dcd15e5e | 522 | |
30875e1c | 523 | /* Offset from SP to first arg on stack at first instruction of a function */ |
75af490b | 524 | |
30875e1c | 525 | #define SP_ARG0 (1 * 4) |