]>
Commit | Line | Data |
---|---|---|
908f682f | 1 | /* Target-dependent code for Motorola 68HC11 & 68HC12 |
51603483 | 2 | Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. |
ffe1f3ee | 3 | Contributed by Stephane Carrez, [email protected] |
78073dd8 AC |
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 2 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, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
20 | ||
78073dd8 | 21 | |
82c230c2 SC |
22 | #include "defs.h" |
23 | #include "frame.h" | |
82c230c2 SC |
24 | #include "symtab.h" |
25 | #include "gdbtypes.h" | |
26 | #include "gdbcmd.h" | |
27 | #include "gdbcore.h" | |
28 | #include "gdb_string.h" | |
29 | #include "value.h" | |
30 | #include "inferior.h" | |
31 | #include "dis-asm.h" | |
32 | #include "symfile.h" | |
33 | #include "objfiles.h" | |
34 | #include "arch-utils.h" | |
4e052eda | 35 | #include "regcache.h" |
b631436b | 36 | #include "reggroups.h" |
78073dd8 | 37 | |
82c230c2 SC |
38 | #include "target.h" |
39 | #include "opcode/m68hc11.h" | |
81967506 SC |
40 | #include "elf/m68hc11.h" |
41 | #include "elf-bfd.h" | |
78073dd8 | 42 | |
7df11f59 SC |
43 | /* Macros for setting and testing a bit in a minimal symbol. |
44 | For 68HC11/68HC12 we have two flags that tell which return | |
45 | type the function is using. This is used for prologue and frame | |
46 | analysis to compute correct stack frame layout. | |
47 | ||
48 | The MSB of the minimal symbol's "info" field is used for this purpose. | |
49 | This field is already being used to store the symbol size, so the | |
50 | assumption is that the symbol size cannot exceed 2^30. | |
51 | ||
52 | MSYMBOL_SET_RTC Actually sets the "RTC" bit. | |
53 | MSYMBOL_SET_RTI Actually sets the "RTI" bit. | |
54 | MSYMBOL_IS_RTC Tests the "RTC" bit in a minimal symbol. | |
55 | MSYMBOL_IS_RTI Tests the "RTC" bit in a minimal symbol. | |
56 | MSYMBOL_SIZE Returns the size of the minimal symbol, | |
57 | i.e. the "info" field with the "special" bit | |
58 | masked out. */ | |
59 | ||
60 | #define MSYMBOL_SET_RTC(msym) \ | |
61 | MSYMBOL_INFO (msym) = (char *) (((long) MSYMBOL_INFO (msym)) \ | |
62 | | 0x80000000) | |
63 | ||
64 | #define MSYMBOL_SET_RTI(msym) \ | |
65 | MSYMBOL_INFO (msym) = (char *) (((long) MSYMBOL_INFO (msym)) \ | |
66 | | 0x40000000) | |
67 | ||
68 | #define MSYMBOL_IS_RTC(msym) \ | |
69 | (((long) MSYMBOL_INFO (msym) & 0x80000000) != 0) | |
70 | ||
71 | #define MSYMBOL_IS_RTI(msym) \ | |
72 | (((long) MSYMBOL_INFO (msym) & 0x40000000) != 0) | |
73 | ||
74 | #define MSYMBOL_SIZE(msym) \ | |
75 | ((long) MSYMBOL_INFO (msym) & 0x3fffffff) | |
76 | ||
77 | enum insn_return_kind { | |
78 | RETURN_RTS, | |
79 | RETURN_RTC, | |
80 | RETURN_RTI | |
81 | }; | |
82 | ||
83 | ||
78073dd8 AC |
84 | /* Register numbers of various important registers. |
85 | Note that some of these values are "real" register numbers, | |
86 | and correspond to the general registers of the machine, | |
87 | and some are "phony" register numbers which are too large | |
88 | to be actual register numbers as far as the user is concerned | |
89 | but do serve to get the desired values when passed to read_register. */ | |
90 | ||
82c230c2 SC |
91 | #define HARD_X_REGNUM 0 |
92 | #define HARD_D_REGNUM 1 | |
93 | #define HARD_Y_REGNUM 2 | |
94 | #define HARD_SP_REGNUM 3 | |
95 | #define HARD_PC_REGNUM 4 | |
96 | ||
97 | #define HARD_A_REGNUM 5 | |
98 | #define HARD_B_REGNUM 6 | |
99 | #define HARD_CCR_REGNUM 7 | |
5706502a SC |
100 | |
101 | /* 68HC12 page number register. | |
102 | Note: to keep a compatibility with gcc register naming, we must | |
103 | not have to rename FP and other soft registers. The page register | |
104 | is a real hard register and must therefore be counted by NUM_REGS. | |
105 | For this it has the same number as Z register (which is not used). */ | |
106 | #define HARD_PAGE_REGNUM 8 | |
107 | #define M68HC11_LAST_HARD_REG (HARD_PAGE_REGNUM) | |
82c230c2 SC |
108 | |
109 | /* Z is replaced by X or Y by gcc during machine reorg. | |
110 | ??? There is no way to get it and even know whether | |
111 | it's in X or Y or in ZS. */ | |
112 | #define SOFT_Z_REGNUM 8 | |
113 | ||
114 | /* Soft registers. These registers are special. There are treated | |
115 | like normal hard registers by gcc and gdb (ie, within dwarf2 info). | |
116 | They are physically located in memory. */ | |
117 | #define SOFT_FP_REGNUM 9 | |
118 | #define SOFT_TMP_REGNUM 10 | |
119 | #define SOFT_ZS_REGNUM 11 | |
120 | #define SOFT_XY_REGNUM 12 | |
f91a8b6b SC |
121 | #define SOFT_UNUSED_REGNUM 13 |
122 | #define SOFT_D1_REGNUM 14 | |
82c230c2 SC |
123 | #define SOFT_D32_REGNUM (SOFT_D1_REGNUM+31) |
124 | #define M68HC11_MAX_SOFT_REGS 32 | |
125 | ||
126 | #define M68HC11_NUM_REGS (8) | |
127 | #define M68HC11_NUM_PSEUDO_REGS (M68HC11_MAX_SOFT_REGS+5) | |
128 | #define M68HC11_ALL_REGS (M68HC11_NUM_REGS+M68HC11_NUM_PSEUDO_REGS) | |
129 | ||
130 | #define M68HC11_REG_SIZE (2) | |
131 | ||
548bcbec SC |
132 | #define M68HC12_NUM_REGS (9) |
133 | #define M68HC12_NUM_PSEUDO_REGS ((M68HC11_MAX_SOFT_REGS+5)+1-1) | |
134 | #define M68HC12_HARD_PC_REGNUM (SOFT_D32_REGNUM+1) | |
135 | ||
908f682f | 136 | struct insn_sequence; |
82c230c2 SC |
137 | struct gdbarch_tdep |
138 | { | |
5d1a66bd SC |
139 | /* Stack pointer correction value. For 68hc11, the stack pointer points |
140 | to the next push location. An offset of 1 must be applied to obtain | |
141 | the address where the last value is saved. For 68hc12, the stack | |
142 | pointer points to the last value pushed. No offset is necessary. */ | |
143 | int stack_correction; | |
908f682f SC |
144 | |
145 | /* Description of instructions in the prologue. */ | |
146 | struct insn_sequence *prologue; | |
81967506 | 147 | |
7df11f59 SC |
148 | /* True if the page memory bank register is available |
149 | and must be used. */ | |
150 | int use_page_register; | |
151 | ||
81967506 SC |
152 | /* ELF flags for ABI. */ |
153 | int elf_flags; | |
82c230c2 SC |
154 | }; |
155 | ||
5d1a66bd SC |
156 | #define M6811_TDEP gdbarch_tdep (current_gdbarch) |
157 | #define STACK_CORRECTION (M6811_TDEP->stack_correction) | |
7df11f59 | 158 | #define USE_PAGE_REGISTER (M6811_TDEP->use_page_register) |
5d1a66bd | 159 | |
82c230c2 SC |
160 | struct frame_extra_info |
161 | { | |
82c230c2 | 162 | CORE_ADDR return_pc; |
82c230c2 SC |
163 | int frameless; |
164 | int size; | |
7df11f59 | 165 | enum insn_return_kind return_kind; |
82c230c2 | 166 | }; |
78073dd8 | 167 | |
82c230c2 SC |
168 | /* Table of registers for 68HC11. This includes the hard registers |
169 | and the soft registers used by GCC. */ | |
170 | static char * | |
171 | m68hc11_register_names[] = | |
172 | { | |
173 | "x", "d", "y", "sp", "pc", "a", "b", | |
5706502a | 174 | "ccr", "page", "frame","tmp", "zs", "xy", 0, |
82c230c2 SC |
175 | "d1", "d2", "d3", "d4", "d5", "d6", "d7", |
176 | "d8", "d9", "d10", "d11", "d12", "d13", "d14", | |
177 | "d15", "d16", "d17", "d18", "d19", "d20", "d21", | |
178 | "d22", "d23", "d24", "d25", "d26", "d27", "d28", | |
179 | "d29", "d30", "d31", "d32" | |
180 | }; | |
78073dd8 | 181 | |
82c230c2 SC |
182 | struct m68hc11_soft_reg |
183 | { | |
184 | const char *name; | |
185 | CORE_ADDR addr; | |
186 | }; | |
78073dd8 | 187 | |
82c230c2 | 188 | static struct m68hc11_soft_reg soft_regs[M68HC11_ALL_REGS]; |
78073dd8 | 189 | |
82c230c2 | 190 | #define M68HC11_FP_ADDR soft_regs[SOFT_FP_REGNUM].addr |
78073dd8 | 191 | |
82c230c2 SC |
192 | static int soft_min_addr; |
193 | static int soft_max_addr; | |
194 | static int soft_reg_initialized = 0; | |
78073dd8 | 195 | |
82c230c2 SC |
196 | /* Look in the symbol table for the address of a pseudo register |
197 | in memory. If we don't find it, pretend the register is not used | |
198 | and not available. */ | |
199 | static void | |
200 | m68hc11_get_register_info (struct m68hc11_soft_reg *reg, const char *name) | |
201 | { | |
202 | struct minimal_symbol *msymbol; | |
78073dd8 | 203 | |
82c230c2 SC |
204 | msymbol = lookup_minimal_symbol (name, NULL, NULL); |
205 | if (msymbol) | |
206 | { | |
207 | reg->addr = SYMBOL_VALUE_ADDRESS (msymbol); | |
208 | reg->name = xstrdup (name); | |
209 | ||
210 | /* Keep track of the address range for soft registers. */ | |
211 | if (reg->addr < (CORE_ADDR) soft_min_addr) | |
212 | soft_min_addr = reg->addr; | |
213 | if (reg->addr > (CORE_ADDR) soft_max_addr) | |
214 | soft_max_addr = reg->addr; | |
215 | } | |
216 | else | |
217 | { | |
218 | reg->name = 0; | |
219 | reg->addr = 0; | |
220 | } | |
221 | } | |
78073dd8 | 222 | |
82c230c2 SC |
223 | /* Initialize the table of soft register addresses according |
224 | to the symbol table. */ | |
225 | static void | |
226 | m68hc11_initialize_register_info (void) | |
227 | { | |
228 | int i; | |
78073dd8 | 229 | |
82c230c2 SC |
230 | if (soft_reg_initialized) |
231 | return; | |
232 | ||
233 | soft_min_addr = INT_MAX; | |
234 | soft_max_addr = 0; | |
235 | for (i = 0; i < M68HC11_ALL_REGS; i++) | |
236 | { | |
237 | soft_regs[i].name = 0; | |
238 | } | |
239 | ||
240 | m68hc11_get_register_info (&soft_regs[SOFT_FP_REGNUM], "_.frame"); | |
241 | m68hc11_get_register_info (&soft_regs[SOFT_TMP_REGNUM], "_.tmp"); | |
242 | m68hc11_get_register_info (&soft_regs[SOFT_ZS_REGNUM], "_.z"); | |
243 | soft_regs[SOFT_Z_REGNUM] = soft_regs[SOFT_ZS_REGNUM]; | |
244 | m68hc11_get_register_info (&soft_regs[SOFT_XY_REGNUM], "_.xy"); | |
78073dd8 | 245 | |
82c230c2 SC |
246 | for (i = SOFT_D1_REGNUM; i < M68HC11_MAX_SOFT_REGS; i++) |
247 | { | |
248 | char buf[10]; | |
78073dd8 | 249 | |
82c230c2 SC |
250 | sprintf (buf, "_.d%d", i - SOFT_D1_REGNUM + 1); |
251 | m68hc11_get_register_info (&soft_regs[i], buf); | |
252 | } | |
78073dd8 | 253 | |
82c230c2 SC |
254 | if (soft_regs[SOFT_FP_REGNUM].name == 0) |
255 | { | |
256 | warning ("No frame soft register found in the symbol table.\n"); | |
257 | warning ("Stack backtrace will not work.\n"); | |
258 | } | |
259 | soft_reg_initialized = 1; | |
260 | } | |
78073dd8 | 261 | |
82c230c2 SC |
262 | /* Given an address in memory, return the soft register number if |
263 | that address corresponds to a soft register. Returns -1 if not. */ | |
264 | static int | |
265 | m68hc11_which_soft_register (CORE_ADDR addr) | |
266 | { | |
267 | int i; | |
268 | ||
269 | if (addr < soft_min_addr || addr > soft_max_addr) | |
270 | return -1; | |
271 | ||
272 | for (i = SOFT_FP_REGNUM; i < M68HC11_ALL_REGS; i++) | |
273 | { | |
274 | if (soft_regs[i].name && soft_regs[i].addr == addr) | |
275 | return i; | |
276 | } | |
277 | return -1; | |
278 | } | |
78073dd8 | 279 | |
82c230c2 SC |
280 | /* Fetch a pseudo register. The 68hc11 soft registers are treated like |
281 | pseudo registers. They are located in memory. Translate the register | |
282 | fetch into a memory read. */ | |
46ce284d AC |
283 | static void |
284 | m68hc11_pseudo_register_read (struct gdbarch *gdbarch, | |
285 | struct regcache *regcache, | |
286 | int regno, void *buf) | |
82c230c2 | 287 | { |
548bcbec SC |
288 | /* The PC is a pseudo reg only for 68HC12 with the memory bank |
289 | addressing mode. */ | |
290 | if (regno == M68HC12_HARD_PC_REGNUM) | |
291 | { | |
292 | const int regsize = TYPE_LENGTH (builtin_type_uint32); | |
293 | CORE_ADDR pc = read_register (HARD_PC_REGNUM); | |
294 | int page = read_register (HARD_PAGE_REGNUM); | |
295 | ||
296 | if (pc >= 0x8000 && pc < 0xc000) | |
297 | { | |
298 | pc -= 0x8000; | |
299 | pc += (page << 14); | |
300 | pc += 0x1000000; | |
301 | } | |
302 | store_unsigned_integer (buf, regsize, pc); | |
303 | return; | |
304 | } | |
305 | ||
82c230c2 SC |
306 | m68hc11_initialize_register_info (); |
307 | ||
308 | /* Fetch a soft register: translate into a memory read. */ | |
309 | if (soft_regs[regno].name) | |
310 | { | |
311 | target_read_memory (soft_regs[regno].addr, buf, 2); | |
312 | } | |
313 | else | |
314 | { | |
315 | memset (buf, 0, 2); | |
316 | } | |
82c230c2 | 317 | } |
78073dd8 | 318 | |
82c230c2 SC |
319 | /* Store a pseudo register. Translate the register store |
320 | into a memory write. */ | |
321 | static void | |
46ce284d AC |
322 | m68hc11_pseudo_register_write (struct gdbarch *gdbarch, |
323 | struct regcache *regcache, | |
324 | int regno, const void *buf) | |
82c230c2 | 325 | { |
548bcbec SC |
326 | /* The PC is a pseudo reg only for 68HC12 with the memory bank |
327 | addressing mode. */ | |
328 | if (regno == M68HC12_HARD_PC_REGNUM) | |
329 | { | |
330 | const int regsize = TYPE_LENGTH (builtin_type_uint32); | |
331 | char *tmp = alloca (regsize); | |
332 | CORE_ADDR pc; | |
333 | ||
334 | memcpy (tmp, buf, regsize); | |
335 | pc = extract_unsigned_integer (tmp, regsize); | |
336 | if (pc >= 0x1000000) | |
337 | { | |
338 | pc -= 0x1000000; | |
339 | write_register (HARD_PAGE_REGNUM, (pc >> 14) & 0x0ff); | |
340 | pc &= 0x03fff; | |
341 | write_register (HARD_PC_REGNUM, pc + 0x8000); | |
342 | } | |
343 | else | |
344 | write_register (HARD_PC_REGNUM, pc); | |
345 | return; | |
346 | } | |
347 | ||
82c230c2 | 348 | m68hc11_initialize_register_info (); |
78073dd8 | 349 | |
82c230c2 SC |
350 | /* Store a soft register: translate into a memory write. */ |
351 | if (soft_regs[regno].name) | |
352 | { | |
46ce284d AC |
353 | const int regsize = 2; |
354 | char *tmp = alloca (regsize); | |
355 | memcpy (tmp, buf, regsize); | |
356 | target_write_memory (soft_regs[regno].addr, tmp, regsize); | |
82c230c2 SC |
357 | } |
358 | } | |
78073dd8 | 359 | |
fa88f677 | 360 | static const char * |
82c230c2 | 361 | m68hc11_register_name (int reg_nr) |
78073dd8 | 362 | { |
548bcbec SC |
363 | if (reg_nr == M68HC12_HARD_PC_REGNUM && USE_PAGE_REGISTER) |
364 | return "pc"; | |
365 | if (reg_nr == HARD_PC_REGNUM && USE_PAGE_REGISTER) | |
366 | return "ppc"; | |
367 | ||
82c230c2 SC |
368 | if (reg_nr < 0) |
369 | return NULL; | |
370 | if (reg_nr >= M68HC11_ALL_REGS) | |
371 | return NULL; | |
372 | ||
373 | /* If we don't know the address of a soft register, pretend it | |
374 | does not exist. */ | |
375 | if (reg_nr > M68HC11_LAST_HARD_REG && soft_regs[reg_nr].name == 0) | |
376 | return NULL; | |
377 | return m68hc11_register_names[reg_nr]; | |
378 | } | |
78073dd8 | 379 | |
f4f9705a | 380 | static const unsigned char * |
82c230c2 | 381 | m68hc11_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr) |
78073dd8 | 382 | { |
82c230c2 SC |
383 | static unsigned char breakpoint[] = {0x0}; |
384 | ||
385 | *lenptr = sizeof (breakpoint); | |
386 | return breakpoint; | |
78073dd8 AC |
387 | } |
388 | ||
389 | /* Immediately after a function call, return the saved pc before the frame | |
82c230c2 | 390 | is setup. */ |
78073dd8 | 391 | |
82c230c2 | 392 | static CORE_ADDR |
78073dd8 AC |
393 | m68hc11_saved_pc_after_call (struct frame_info *frame) |
394 | { | |
82c230c2 SC |
395 | CORE_ADDR addr; |
396 | ||
5d1a66bd | 397 | addr = read_register (HARD_SP_REGNUM) + STACK_CORRECTION; |
78073dd8 AC |
398 | addr &= 0x0ffff; |
399 | return read_memory_integer (addr, 2) & 0x0FFFF; | |
400 | } | |
401 | ||
82c230c2 SC |
402 | static CORE_ADDR |
403 | m68hc11_frame_saved_pc (struct frame_info *frame) | |
404 | { | |
da50a4b7 | 405 | return get_frame_extra_info (frame)->return_pc; |
82c230c2 SC |
406 | } |
407 | ||
408 | static CORE_ADDR | |
409 | m68hc11_frame_args_address (struct frame_info *frame) | |
410 | { | |
7df11f59 SC |
411 | CORE_ADDR addr; |
412 | ||
da50a4b7 AC |
413 | addr = get_frame_base (frame) + get_frame_extra_info (frame)->size + STACK_CORRECTION + 2; |
414 | if (get_frame_extra_info (frame)->return_kind == RETURN_RTC) | |
7df11f59 | 415 | addr += 1; |
da50a4b7 | 416 | else if (get_frame_extra_info (frame)->return_kind == RETURN_RTI) |
7df11f59 SC |
417 | addr += 7; |
418 | ||
419 | return addr; | |
82c230c2 SC |
420 | } |
421 | ||
422 | static CORE_ADDR | |
423 | m68hc11_frame_locals_address (struct frame_info *frame) | |
424 | { | |
1e2330ba | 425 | return get_frame_base (frame); |
82c230c2 SC |
426 | } |
427 | ||
78073dd8 AC |
428 | /* Discard from the stack the innermost frame, restoring all saved |
429 | registers. */ | |
430 | ||
82c230c2 | 431 | static void |
fba45db2 | 432 | m68hc11_pop_frame (void) |
78073dd8 | 433 | { |
82c230c2 SC |
434 | register struct frame_info *frame = get_current_frame (); |
435 | register CORE_ADDR fp, sp; | |
436 | register int regnum; | |
437 | ||
1e2330ba AC |
438 | if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (frame), |
439 | get_frame_base (frame), | |
440 | get_frame_base (frame))) | |
82c230c2 SC |
441 | generic_pop_dummy_frame (); |
442 | else | |
443 | { | |
c193f6ac | 444 | fp = get_frame_base (frame); |
f30ee0bc | 445 | DEPRECATED_FRAME_INIT_SAVED_REGS (frame); |
82c230c2 SC |
446 | |
447 | /* Copy regs from where they were saved in the frame. */ | |
448 | for (regnum = 0; regnum < M68HC11_ALL_REGS; regnum++) | |
b2fb4676 | 449 | if (get_frame_saved_regs (frame)[regnum]) |
82c230c2 | 450 | write_register (regnum, |
b2fb4676 | 451 | read_memory_integer (get_frame_saved_regs (frame)[regnum], 2)); |
82c230c2 | 452 | |
da50a4b7 AC |
453 | write_register (HARD_PC_REGNUM, get_frame_extra_info (frame)->return_pc); |
454 | sp = (fp + get_frame_extra_info (frame)->size + 2) & 0x0ffff; | |
82c230c2 SC |
455 | write_register (HARD_SP_REGNUM, sp); |
456 | } | |
457 | flush_cached_frames (); | |
78073dd8 AC |
458 | } |
459 | ||
908f682f SC |
460 | \f |
461 | /* 68HC11 & 68HC12 prologue analysis. | |
462 | ||
463 | */ | |
464 | #define MAX_CODES 12 | |
465 | ||
466 | /* 68HC11 opcodes. */ | |
467 | #undef M6811_OP_PAGE2 | |
b94a41a1 SC |
468 | #define M6811_OP_PAGE2 (0x18) |
469 | #define M6811_OP_LDX (0xde) | |
470 | #define M6811_OP_LDX_EXT (0xfe) | |
471 | #define M6811_OP_PSHX (0x3c) | |
472 | #define M6811_OP_STS (0x9f) | |
473 | #define M6811_OP_STS_EXT (0xbf) | |
474 | #define M6811_OP_TSX (0x30) | |
475 | #define M6811_OP_XGDX (0x8f) | |
476 | #define M6811_OP_ADDD (0xc3) | |
477 | #define M6811_OP_TXS (0x35) | |
478 | #define M6811_OP_DES (0x34) | |
908f682f SC |
479 | |
480 | /* 68HC12 opcodes. */ | |
b94a41a1 SC |
481 | #define M6812_OP_PAGE2 (0x18) |
482 | #define M6812_OP_MOVW (0x01) | |
483 | #define M6812_PB_PSHW (0xae) | |
484 | #define M6812_OP_STS (0x5f) | |
485 | #define M6812_OP_STS_EXT (0x7f) | |
486 | #define M6812_OP_LEAS (0x1b) | |
487 | #define M6812_OP_PSHX (0x34) | |
488 | #define M6812_OP_PSHY (0x35) | |
908f682f SC |
489 | |
490 | /* Operand extraction. */ | |
491 | #define OP_DIRECT (0x100) /* 8-byte direct addressing. */ | |
492 | #define OP_IMM_LOW (0x200) /* Low part of 16-bit constant/address. */ | |
493 | #define OP_IMM_HIGH (0x300) /* High part of 16-bit constant/address. */ | |
494 | #define OP_PBYTE (0x400) /* 68HC12 indexed operand. */ | |
495 | ||
496 | /* Identification of the sequence. */ | |
497 | enum m6811_seq_type | |
498 | { | |
499 | P_LAST = 0, | |
500 | P_SAVE_REG, /* Save a register on the stack. */ | |
501 | P_SET_FRAME, /* Setup the frame pointer. */ | |
502 | P_LOCAL_1, /* Allocate 1 byte for locals. */ | |
503 | P_LOCAL_2, /* Allocate 2 bytes for locals. */ | |
504 | P_LOCAL_N /* Allocate N bytes for locals. */ | |
505 | }; | |
506 | ||
507 | struct insn_sequence { | |
508 | enum m6811_seq_type type; | |
509 | unsigned length; | |
510 | unsigned short code[MAX_CODES]; | |
511 | }; | |
512 | ||
513 | /* Sequence of instructions in the 68HC11 function prologue. */ | |
514 | static struct insn_sequence m6811_prologue[] = { | |
515 | /* Sequences to save a soft-register. */ | |
516 | { P_SAVE_REG, 3, { M6811_OP_LDX, OP_DIRECT, | |
517 | M6811_OP_PSHX } }, | |
518 | { P_SAVE_REG, 5, { M6811_OP_PAGE2, M6811_OP_LDX, OP_DIRECT, | |
519 | M6811_OP_PAGE2, M6811_OP_PSHX } }, | |
b94a41a1 SC |
520 | { P_SAVE_REG, 4, { M6811_OP_LDX_EXT, OP_IMM_HIGH, OP_IMM_LOW, |
521 | M6811_OP_PSHX } }, | |
522 | { P_SAVE_REG, 6, { M6811_OP_PAGE2, M6811_OP_LDX_EXT, OP_IMM_HIGH, OP_IMM_LOW, | |
523 | M6811_OP_PAGE2, M6811_OP_PSHX } }, | |
908f682f SC |
524 | |
525 | /* Sequences to allocate local variables. */ | |
526 | { P_LOCAL_N, 7, { M6811_OP_TSX, | |
527 | M6811_OP_XGDX, | |
528 | M6811_OP_ADDD, OP_IMM_HIGH, OP_IMM_LOW, | |
529 | M6811_OP_XGDX, | |
530 | M6811_OP_TXS } }, | |
531 | { P_LOCAL_N, 11, { M6811_OP_PAGE2, M6811_OP_TSX, | |
532 | M6811_OP_PAGE2, M6811_OP_XGDX, | |
533 | M6811_OP_ADDD, OP_IMM_HIGH, OP_IMM_LOW, | |
534 | M6811_OP_PAGE2, M6811_OP_XGDX, | |
535 | M6811_OP_PAGE2, M6811_OP_TXS } }, | |
536 | { P_LOCAL_1, 1, { M6811_OP_DES } }, | |
537 | { P_LOCAL_2, 1, { M6811_OP_PSHX } }, | |
538 | { P_LOCAL_2, 2, { M6811_OP_PAGE2, M6811_OP_PSHX } }, | |
539 | ||
540 | /* Initialize the frame pointer. */ | |
541 | { P_SET_FRAME, 2, { M6811_OP_STS, OP_DIRECT } }, | |
b94a41a1 | 542 | { P_SET_FRAME, 3, { M6811_OP_STS_EXT, OP_IMM_HIGH, OP_IMM_LOW } }, |
908f682f SC |
543 | { P_LAST, 0, { 0 } } |
544 | }; | |
545 | ||
546 | ||
547 | /* Sequence of instructions in the 68HC12 function prologue. */ | |
548 | static struct insn_sequence m6812_prologue[] = { | |
549 | { P_SAVE_REG, 5, { M6812_OP_PAGE2, M6812_OP_MOVW, M6812_PB_PSHW, | |
550 | OP_IMM_HIGH, OP_IMM_LOW } }, | |
b94a41a1 SC |
551 | { P_SET_FRAME, 2, { M6812_OP_STS, OP_DIRECT } }, |
552 | { P_SET_FRAME, 3, { M6812_OP_STS_EXT, OP_IMM_HIGH, OP_IMM_LOW } }, | |
908f682f | 553 | { P_LOCAL_N, 2, { M6812_OP_LEAS, OP_PBYTE } }, |
ffe1f3ee SC |
554 | { P_LOCAL_2, 1, { M6812_OP_PSHX } }, |
555 | { P_LOCAL_2, 1, { M6812_OP_PSHY } }, | |
908f682f SC |
556 | { P_LAST, 0 } |
557 | }; | |
558 | ||
559 | ||
560 | /* Analyze the sequence of instructions starting at the given address. | |
561 | Returns a pointer to the sequence when it is recognized and | |
562 | the optional value (constant/address) associated with it. | |
563 | Advance the pc for the next sequence. */ | |
564 | static struct insn_sequence * | |
565 | m68hc11_analyze_instruction (struct insn_sequence *seq, CORE_ADDR *pc, | |
566 | CORE_ADDR *val) | |
567 | { | |
568 | unsigned char buffer[MAX_CODES]; | |
569 | unsigned bufsize; | |
570 | unsigned j; | |
571 | CORE_ADDR cur_val; | |
572 | short v = 0; | |
573 | ||
574 | bufsize = 0; | |
575 | for (; seq->type != P_LAST; seq++) | |
576 | { | |
577 | cur_val = 0; | |
578 | for (j = 0; j < seq->length; j++) | |
579 | { | |
580 | if (bufsize < j + 1) | |
581 | { | |
582 | buffer[bufsize] = read_memory_unsigned_integer (*pc + bufsize, | |
583 | 1); | |
584 | bufsize++; | |
585 | } | |
586 | /* Continue while we match the opcode. */ | |
587 | if (seq->code[j] == buffer[j]) | |
588 | continue; | |
589 | ||
590 | if ((seq->code[j] & 0xf00) == 0) | |
591 | break; | |
592 | ||
593 | /* Extract a sequence parameter (address or constant). */ | |
594 | switch (seq->code[j]) | |
595 | { | |
596 | case OP_DIRECT: | |
597 | cur_val = (CORE_ADDR) buffer[j]; | |
598 | break; | |
599 | ||
600 | case OP_IMM_HIGH: | |
601 | cur_val = cur_val & 0x0ff; | |
602 | cur_val |= (buffer[j] << 8); | |
603 | break; | |
604 | ||
605 | case OP_IMM_LOW: | |
606 | cur_val &= 0x0ff00; | |
607 | cur_val |= buffer[j]; | |
608 | break; | |
609 | ||
610 | case OP_PBYTE: | |
611 | if ((buffer[j] & 0xE0) == 0x80) | |
612 | { | |
613 | v = buffer[j] & 0x1f; | |
614 | if (v & 0x10) | |
615 | v |= 0xfff0; | |
616 | } | |
617 | else if ((buffer[j] & 0xfe) == 0xf0) | |
618 | { | |
619 | v = read_memory_unsigned_integer (*pc + j + 1, 1); | |
620 | if (buffer[j] & 1) | |
621 | v |= 0xff00; | |
b4fa4770 | 622 | *pc = *pc + 1; |
908f682f SC |
623 | } |
624 | else if (buffer[j] == 0xf2) | |
625 | { | |
626 | v = read_memory_unsigned_integer (*pc + j + 1, 2); | |
b4fa4770 | 627 | *pc = *pc + 2; |
908f682f SC |
628 | } |
629 | cur_val = v; | |
630 | break; | |
631 | } | |
632 | } | |
633 | ||
634 | /* We have a full match. */ | |
635 | if (j == seq->length) | |
636 | { | |
637 | *val = cur_val; | |
638 | *pc = *pc + j; | |
639 | return seq; | |
640 | } | |
641 | } | |
642 | return 0; | |
643 | } | |
644 | ||
7df11f59 SC |
645 | /* Return the instruction that the function at the PC is using. */ |
646 | static enum insn_return_kind | |
647 | m68hc11_get_return_insn (CORE_ADDR pc) | |
648 | { | |
649 | struct minimal_symbol *sym; | |
650 | ||
651 | /* A flag indicating that this is a STO_M68HC12_FAR or STO_M68HC12_INTERRUPT | |
652 | function is stored by elfread.c in the high bit of the info field. | |
653 | Use this to decide which instruction the function uses to return. */ | |
654 | sym = lookup_minimal_symbol_by_pc (pc); | |
655 | if (sym == 0) | |
656 | return RETURN_RTS; | |
657 | ||
658 | if (MSYMBOL_IS_RTC (sym)) | |
659 | return RETURN_RTC; | |
660 | else if (MSYMBOL_IS_RTI (sym)) | |
661 | return RETURN_RTI; | |
662 | else | |
663 | return RETURN_RTS; | |
664 | } | |
665 | ||
666 | ||
78073dd8 AC |
667 | /* Analyze the function prologue to find some information |
668 | about the function: | |
669 | - the PC of the first line (for m68hc11_skip_prologue) | |
670 | - the offset of the previous frame saved address (from current frame) | |
671 | - the soft registers which are pushed. */ | |
672 | static void | |
82c230c2 SC |
673 | m68hc11_guess_from_prologue (CORE_ADDR pc, CORE_ADDR fp, |
674 | CORE_ADDR *first_line, | |
675 | int *frame_offset, CORE_ADDR *pushed_regs) | |
78073dd8 | 676 | { |
82c230c2 | 677 | CORE_ADDR save_addr; |
78073dd8 | 678 | CORE_ADDR func_end; |
78073dd8 AC |
679 | int size; |
680 | int found_frame_point; | |
82c230c2 | 681 | int saved_reg; |
78073dd8 | 682 | CORE_ADDR first_pc; |
908f682f SC |
683 | int done = 0; |
684 | struct insn_sequence *seq_table; | |
78073dd8 AC |
685 | |
686 | first_pc = get_pc_function_start (pc); | |
687 | size = 0; | |
688 | ||
82c230c2 | 689 | m68hc11_initialize_register_info (); |
78073dd8 AC |
690 | if (first_pc == 0) |
691 | { | |
692 | *frame_offset = 0; | |
78073dd8 AC |
693 | *first_line = pc; |
694 | return; | |
695 | } | |
696 | ||
908f682f SC |
697 | seq_table = gdbarch_tdep (current_gdbarch)->prologue; |
698 | ||
78073dd8 AC |
699 | /* The 68hc11 stack is as follows: |
700 | ||
701 | ||
702 | | | | |
703 | +-----------+ | |
704 | | | | |
705 | | args | | |
706 | | | | |
707 | +-----------+ | |
708 | | PC-return | | |
709 | +-----------+ | |
710 | | Old frame | | |
711 | +-----------+ | |
712 | | | | |
713 | | Locals | | |
714 | | | | |
715 | +-----------+ <--- current frame | |
716 | | | | |
717 | ||
718 | With most processors (like 68K) the previous frame can be computed | |
719 | easily because it is always at a fixed offset (see link/unlink). | |
720 | That is, locals are accessed with negative offsets, arguments are | |
721 | accessed with positive ones. Since 68hc11 only supports offsets | |
722 | in the range [0..255], the frame is defined at the bottom of | |
723 | locals (see picture). | |
724 | ||
725 | The purpose of the analysis made here is to find out the size | |
726 | of locals in this function. An alternative to this is to use | |
727 | DWARF2 info. This would be better but I don't know how to | |
728 | access dwarf2 debug from this function. | |
729 | ||
730 | Walk from the function entry point to the point where we save | |
731 | the frame. While walking instructions, compute the size of bytes | |
732 | which are pushed. This gives us the index to access the previous | |
733 | frame. | |
734 | ||
735 | We limit the search to 128 bytes so that the algorithm is bounded | |
736 | in case of random and wrong code. We also stop and abort if | |
737 | we find an instruction which is not supposed to appear in the | |
738 | prologue (as generated by gcc 2.95, 2.96). | |
739 | */ | |
740 | pc = first_pc; | |
741 | func_end = pc + 128; | |
78073dd8 | 742 | found_frame_point = 0; |
908f682f | 743 | *frame_offset = 0; |
b4fa4770 | 744 | save_addr = fp + STACK_CORRECTION; |
908f682f | 745 | while (!done && pc + 2 < func_end) |
78073dd8 | 746 | { |
908f682f SC |
747 | struct insn_sequence *seq; |
748 | CORE_ADDR val; | |
78073dd8 | 749 | |
908f682f SC |
750 | seq = m68hc11_analyze_instruction (seq_table, &pc, &val); |
751 | if (seq == 0) | |
752 | break; | |
78073dd8 | 753 | |
908f682f | 754 | if (seq->type == P_SAVE_REG) |
78073dd8 | 755 | { |
908f682f SC |
756 | if (found_frame_point) |
757 | { | |
758 | saved_reg = m68hc11_which_soft_register (val); | |
759 | if (saved_reg < 0) | |
760 | break; | |
78073dd8 | 761 | |
908f682f SC |
762 | save_addr -= 2; |
763 | if (pushed_regs) | |
764 | pushed_regs[saved_reg] = save_addr; | |
765 | } | |
766 | else | |
767 | { | |
768 | size += 2; | |
769 | } | |
78073dd8 | 770 | } |
908f682f | 771 | else if (seq->type == P_SET_FRAME) |
78073dd8 AC |
772 | { |
773 | found_frame_point = 1; | |
908f682f | 774 | *frame_offset = size; |
78073dd8 | 775 | } |
908f682f | 776 | else if (seq->type == P_LOCAL_1) |
78073dd8 | 777 | { |
6148eca7 SC |
778 | size += 1; |
779 | } | |
908f682f | 780 | else if (seq->type == P_LOCAL_2) |
78073dd8 | 781 | { |
908f682f | 782 | size += 2; |
78073dd8 | 783 | } |
908f682f | 784 | else if (seq->type == P_LOCAL_N) |
78073dd8 | 785 | { |
908f682f SC |
786 | /* Stack pointer is decremented for the allocation. */ |
787 | if (val & 0x8000) | |
788 | size -= (int) (val) | 0xffff0000; | |
789 | else | |
790 | size -= val; | |
78073dd8 AC |
791 | } |
792 | } | |
78073dd8 AC |
793 | *first_line = pc; |
794 | } | |
795 | ||
82c230c2 | 796 | static CORE_ADDR |
78073dd8 AC |
797 | m68hc11_skip_prologue (CORE_ADDR pc) |
798 | { | |
799 | CORE_ADDR func_addr, func_end; | |
800 | struct symtab_and_line sal; | |
801 | int frame_offset; | |
78073dd8 | 802 | |
82c230c2 SC |
803 | /* If we have line debugging information, then the end of the |
804 | prologue should be the first assembly instruction of the | |
78073dd8 AC |
805 | first source line. */ |
806 | if (find_pc_partial_function (pc, NULL, &func_addr, &func_end)) | |
807 | { | |
808 | sal = find_pc_line (func_addr, 0); | |
809 | if (sal.end && sal.end < func_end) | |
810 | return sal.end; | |
811 | } | |
812 | ||
82c230c2 | 813 | m68hc11_guess_from_prologue (pc, 0, &pc, &frame_offset, 0); |
78073dd8 AC |
814 | return pc; |
815 | } | |
816 | ||
a5afb99f AC |
817 | /* Given a GDB frame, determine the address of the calling function's |
818 | frame. This will be used to create a new GDB frame struct, and | |
e9582e71 AC |
819 | then DEPRECATED_INIT_EXTRA_FRAME_INFO and DEPRECATED_INIT_FRAME_PC |
820 | will be called for the new frame. */ | |
78073dd8 | 821 | |
82c230c2 | 822 | static CORE_ADDR |
78073dd8 AC |
823 | m68hc11_frame_chain (struct frame_info *frame) |
824 | { | |
82c230c2 | 825 | CORE_ADDR addr; |
78073dd8 | 826 | |
1e2330ba AC |
827 | if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (frame), |
828 | get_frame_base (frame), | |
829 | get_frame_base (frame))) | |
830 | return get_frame_base (frame); /* dummy frame same as caller's frame */ | |
6148eca7 | 831 | |
da50a4b7 AC |
832 | if (get_frame_extra_info (frame)->return_pc == 0 |
833 | || inside_entry_file (get_frame_extra_info (frame)->return_pc)) | |
82c230c2 | 834 | return (CORE_ADDR) 0; |
78073dd8 | 835 | |
1e2330ba | 836 | if (get_frame_base (frame) == 0) |
78073dd8 AC |
837 | { |
838 | return (CORE_ADDR) 0; | |
839 | } | |
840 | ||
da50a4b7 | 841 | addr = get_frame_base (frame) + get_frame_extra_info (frame)->size + STACK_CORRECTION - 2; |
78073dd8 | 842 | addr = read_memory_unsigned_integer (addr, 2) & 0x0FFFF; |
78073dd8 AC |
843 | return addr; |
844 | } | |
845 | ||
846 | /* Put here the code to store, into a struct frame_saved_regs, the | |
847 | addresses of the saved registers of frame described by FRAME_INFO. | |
848 | This includes special registers such as pc and fp saved in special | |
849 | ways in the stack frame. sp is even more special: the address we | |
850 | return for it IS the sp for the next frame. */ | |
82c230c2 SC |
851 | static void |
852 | m68hc11_frame_init_saved_regs (struct frame_info *fi) | |
78073dd8 AC |
853 | { |
854 | CORE_ADDR pc; | |
184651e3 | 855 | CORE_ADDR addr; |
7df11f59 | 856 | |
b2fb4676 | 857 | if (get_frame_saved_regs (fi) == NULL) |
82c230c2 SC |
858 | frame_saved_regs_zalloc (fi); |
859 | else | |
b2fb4676 | 860 | memset (get_frame_saved_regs (fi), 0, SIZEOF_FRAME_SAVED_REGS); |
82c230c2 | 861 | |
50abf9e5 | 862 | pc = get_frame_pc (fi); |
da50a4b7 AC |
863 | get_frame_extra_info (fi)->return_kind = m68hc11_get_return_insn (pc); |
864 | m68hc11_guess_from_prologue (pc, get_frame_base (fi), &pc, | |
865 | &get_frame_extra_info (fi)->size, | |
b2fb4676 | 866 | get_frame_saved_regs (fi)); |
82c230c2 | 867 | |
da50a4b7 | 868 | addr = get_frame_base (fi) + get_frame_extra_info (fi)->size + STACK_CORRECTION; |
908f682f | 869 | if (soft_regs[SOFT_FP_REGNUM].name) |
b2fb4676 | 870 | get_frame_saved_regs (fi)[SOFT_FP_REGNUM] = addr - 2; |
7df11f59 SC |
871 | |
872 | /* Take into account how the function was called/returns. */ | |
da50a4b7 | 873 | if (get_frame_extra_info (fi)->return_kind == RETURN_RTC) |
7df11f59 | 874 | { |
b2fb4676 | 875 | get_frame_saved_regs (fi)[HARD_PAGE_REGNUM] = addr; |
7df11f59 SC |
876 | addr++; |
877 | } | |
da50a4b7 | 878 | else if (get_frame_extra_info (fi)->return_kind == RETURN_RTI) |
7df11f59 | 879 | { |
b2fb4676 AC |
880 | get_frame_saved_regs (fi)[HARD_CCR_REGNUM] = addr; |
881 | get_frame_saved_regs (fi)[HARD_D_REGNUM] = addr + 1; | |
882 | get_frame_saved_regs (fi)[HARD_X_REGNUM] = addr + 3; | |
883 | get_frame_saved_regs (fi)[HARD_Y_REGNUM] = addr + 5; | |
7df11f59 SC |
884 | addr += 7; |
885 | } | |
b2fb4676 AC |
886 | get_frame_saved_regs (fi)[HARD_SP_REGNUM] = addr; |
887 | get_frame_saved_regs (fi)[HARD_PC_REGNUM] = get_frame_saved_regs (fi)[HARD_SP_REGNUM]; | |
78073dd8 AC |
888 | } |
889 | ||
82c230c2 | 890 | static void |
78073dd8 AC |
891 | m68hc11_init_extra_frame_info (int fromleaf, struct frame_info *fi) |
892 | { | |
82c230c2 | 893 | CORE_ADDR addr; |
78073dd8 | 894 | |
a00a19e9 | 895 | frame_extra_info_zalloc (fi, sizeof (struct frame_extra_info)); |
82c230c2 | 896 | |
11c02a10 | 897 | if (get_next_frame (fi)) |
8bedc050 | 898 | deprecated_update_frame_pc_hack (fi, DEPRECATED_FRAME_SAVED_PC (get_next_frame (fi))); |
82c230c2 SC |
899 | |
900 | m68hc11_frame_init_saved_regs (fi); | |
78073dd8 AC |
901 | |
902 | if (fromleaf) | |
903 | { | |
da50a4b7 AC |
904 | get_frame_extra_info (fi)->return_kind = m68hc11_get_return_insn (get_frame_pc (fi)); |
905 | get_frame_extra_info (fi)->return_pc = m68hc11_saved_pc_after_call (fi); | |
78073dd8 AC |
906 | } |
907 | else | |
908 | { | |
b2fb4676 | 909 | addr = get_frame_saved_regs (fi)[HARD_PC_REGNUM]; |
82c230c2 | 910 | addr = read_memory_unsigned_integer (addr, 2) & 0x0ffff; |
7df11f59 SC |
911 | |
912 | /* Take into account the 68HC12 specific call (PC + page). */ | |
da50a4b7 | 913 | if (get_frame_extra_info (fi)->return_kind == RETURN_RTC |
7df11f59 SC |
914 | && addr >= 0x08000 && addr < 0x0c000 |
915 | && USE_PAGE_REGISTER) | |
916 | { | |
b2fb4676 | 917 | CORE_ADDR page_addr = get_frame_saved_regs (fi)[HARD_PAGE_REGNUM]; |
7df11f59 SC |
918 | |
919 | unsigned page = read_memory_unsigned_integer (page_addr, 1); | |
920 | addr -= 0x08000; | |
921 | addr += ((page & 0x0ff) << 14); | |
922 | addr += 0x1000000; | |
923 | } | |
da50a4b7 | 924 | get_frame_extra_info (fi)->return_pc = addr; |
78073dd8 AC |
925 | } |
926 | } | |
927 | ||
928 | /* Same as 'info reg' but prints the registers in a different way. */ | |
929 | static void | |
930 | show_regs (char *args, int from_tty) | |
931 | { | |
82c230c2 | 932 | int ccr = read_register (HARD_CCR_REGNUM); |
78073dd8 | 933 | int i; |
82c230c2 SC |
934 | int nr; |
935 | ||
78073dd8 | 936 | printf_filtered ("PC=%04x SP=%04x FP=%04x CCR=%02x %c%c%c%c%c%c%c%c\n", |
82c230c2 SC |
937 | (int) read_register (HARD_PC_REGNUM), |
938 | (int) read_register (HARD_SP_REGNUM), | |
939 | (int) read_register (SOFT_FP_REGNUM), | |
78073dd8 AC |
940 | ccr, |
941 | ccr & M6811_S_BIT ? 'S' : '-', | |
942 | ccr & M6811_X_BIT ? 'X' : '-', | |
943 | ccr & M6811_H_BIT ? 'H' : '-', | |
944 | ccr & M6811_I_BIT ? 'I' : '-', | |
945 | ccr & M6811_N_BIT ? 'N' : '-', | |
946 | ccr & M6811_Z_BIT ? 'Z' : '-', | |
947 | ccr & M6811_V_BIT ? 'V' : '-', | |
948 | ccr & M6811_C_BIT ? 'C' : '-'); | |
949 | ||
7df11f59 | 950 | printf_filtered ("D=%04x IX=%04x IY=%04x", |
82c230c2 SC |
951 | (int) read_register (HARD_D_REGNUM), |
952 | (int) read_register (HARD_X_REGNUM), | |
953 | (int) read_register (HARD_Y_REGNUM)); | |
954 | ||
7df11f59 SC |
955 | if (USE_PAGE_REGISTER) |
956 | { | |
957 | printf_filtered (" Page=%02x", | |
958 | (int) read_register (HARD_PAGE_REGNUM)); | |
959 | } | |
960 | printf_filtered ("\n"); | |
961 | ||
82c230c2 SC |
962 | nr = 0; |
963 | for (i = SOFT_D1_REGNUM; i < M68HC11_ALL_REGS; i++) | |
78073dd8 | 964 | { |
82c230c2 SC |
965 | /* Skip registers which are not defined in the symbol table. */ |
966 | if (soft_regs[i].name == 0) | |
967 | continue; | |
968 | ||
969 | printf_filtered ("D%d=%04x", | |
970 | i - SOFT_D1_REGNUM + 1, | |
971 | (int) read_register (i)); | |
972 | nr++; | |
973 | if ((nr % 8) == 7) | |
78073dd8 AC |
974 | printf_filtered ("\n"); |
975 | else | |
976 | printf_filtered (" "); | |
977 | } | |
82c230c2 SC |
978 | if (nr && (nr % 8) != 7) |
979 | printf_filtered ("\n"); | |
78073dd8 AC |
980 | } |
981 | ||
22df305e SC |
982 | static CORE_ADDR |
983 | m68hc11_stack_align (CORE_ADDR addr) | |
984 | { | |
985 | return ((addr + 1) & -2); | |
986 | } | |
987 | ||
82c230c2 | 988 | static CORE_ADDR |
78073dd8 | 989 | m68hc11_push_arguments (int nargs, |
ea7c478f | 990 | struct value **args, |
78073dd8 AC |
991 | CORE_ADDR sp, |
992 | int struct_return, | |
993 | CORE_ADDR struct_addr) | |
994 | { | |
82c230c2 SC |
995 | int stack_alloc; |
996 | int argnum; | |
997 | int first_stack_argnum; | |
998 | int stack_offset; | |
999 | struct type *type; | |
1000 | char *val; | |
1001 | int len; | |
1002 | ||
1003 | stack_alloc = 0; | |
1004 | first_stack_argnum = 0; | |
1005 | if (struct_return) | |
1006 | { | |
184651e3 SC |
1007 | /* The struct is allocated on the stack and gdb used the stack |
1008 | pointer for the address of that struct. We must apply the | |
1009 | stack offset on the address. */ | |
5d1a66bd | 1010 | write_register (HARD_D_REGNUM, struct_addr + STACK_CORRECTION); |
82c230c2 SC |
1011 | } |
1012 | else if (nargs > 0) | |
1013 | { | |
1014 | type = VALUE_TYPE (args[0]); | |
1015 | len = TYPE_LENGTH (type); | |
1016 | ||
1017 | /* First argument is passed in D and X registers. */ | |
1018 | if (len <= 4) | |
1019 | { | |
1020 | LONGEST v = extract_unsigned_integer (VALUE_CONTENTS (args[0]), len); | |
1021 | first_stack_argnum = 1; | |
1022 | write_register (HARD_D_REGNUM, v); | |
1023 | if (len > 2) | |
1024 | { | |
1025 | v >>= 16; | |
1026 | write_register (HARD_X_REGNUM, v); | |
1027 | } | |
1028 | } | |
1029 | } | |
1030 | for (argnum = first_stack_argnum; argnum < nargs; argnum++) | |
1031 | { | |
1032 | type = VALUE_TYPE (args[argnum]); | |
22df305e | 1033 | stack_alloc += (TYPE_LENGTH (type) + 1) & -2; |
82c230c2 SC |
1034 | } |
1035 | sp -= stack_alloc; | |
1036 | ||
5d1a66bd | 1037 | stack_offset = STACK_CORRECTION; |
82c230c2 SC |
1038 | for (argnum = first_stack_argnum; argnum < nargs; argnum++) |
1039 | { | |
1040 | type = VALUE_TYPE (args[argnum]); | |
1041 | len = TYPE_LENGTH (type); | |
1042 | ||
1043 | val = (char*) VALUE_CONTENTS (args[argnum]); | |
1044 | write_memory (sp + stack_offset, val, len); | |
1045 | stack_offset += len; | |
22df305e SC |
1046 | if (len & 1) |
1047 | { | |
1048 | static char zero = 0; | |
1049 | ||
1050 | write_memory (sp + stack_offset, &zero, 1); | |
1051 | stack_offset++; | |
1052 | } | |
82c230c2 SC |
1053 | } |
1054 | return sp; | |
78073dd8 AC |
1055 | } |
1056 | ||
1057 | ||
82c230c2 SC |
1058 | /* Return a location where we can set a breakpoint that will be hit |
1059 | when an inferior function call returns. */ | |
78073dd8 | 1060 | CORE_ADDR |
fba45db2 | 1061 | m68hc11_call_dummy_address (void) |
78073dd8 | 1062 | { |
22df305e | 1063 | return entry_point_address (); |
78073dd8 AC |
1064 | } |
1065 | ||
82c230c2 SC |
1066 | static struct type * |
1067 | m68hc11_register_virtual_type (int reg_nr) | |
1068 | { | |
5706502a SC |
1069 | switch (reg_nr) |
1070 | { | |
1071 | case HARD_PAGE_REGNUM: | |
1072 | case HARD_A_REGNUM: | |
1073 | case HARD_B_REGNUM: | |
1074 | case HARD_CCR_REGNUM: | |
1075 | return builtin_type_uint8; | |
1076 | ||
548bcbec SC |
1077 | case M68HC12_HARD_PC_REGNUM: |
1078 | return builtin_type_uint32; | |
1079 | ||
5706502a SC |
1080 | default: |
1081 | return builtin_type_uint16; | |
1082 | } | |
82c230c2 SC |
1083 | } |
1084 | ||
1085 | static void | |
1086 | m68hc11_store_struct_return (CORE_ADDR addr, CORE_ADDR sp) | |
1087 | { | |
184651e3 SC |
1088 | /* The struct address computed by gdb is on the stack. |
1089 | It uses the stack pointer so we must apply the stack | |
1090 | correction offset. */ | |
5d1a66bd | 1091 | write_register (HARD_D_REGNUM, addr + STACK_CORRECTION); |
82c230c2 SC |
1092 | } |
1093 | ||
1094 | static void | |
1095 | m68hc11_store_return_value (struct type *type, char *valbuf) | |
1096 | { | |
22df305e SC |
1097 | int len; |
1098 | ||
1099 | len = TYPE_LENGTH (type); | |
1100 | ||
1101 | /* First argument is passed in D and X registers. */ | |
1102 | if (len <= 4) | |
1103 | { | |
1104 | LONGEST v = extract_unsigned_integer (valbuf, len); | |
1105 | ||
1106 | write_register (HARD_D_REGNUM, v); | |
1107 | if (len > 2) | |
1108 | { | |
1109 | v >>= 16; | |
1110 | write_register (HARD_X_REGNUM, v); | |
1111 | } | |
1112 | } | |
1113 | else | |
1114 | error ("return of value > 4 is not supported."); | |
82c230c2 SC |
1115 | } |
1116 | ||
1117 | ||
1118 | /* Given a return value in `regbuf' with a type `type', | |
78073dd8 AC |
1119 | extract and copy its value into `valbuf'. */ |
1120 | ||
82c230c2 SC |
1121 | static void |
1122 | m68hc11_extract_return_value (struct type *type, | |
78073dd8 AC |
1123 | char *regbuf, |
1124 | char *valbuf) | |
1125 | { | |
82c230c2 SC |
1126 | int len = TYPE_LENGTH (type); |
1127 | ||
22df305e | 1128 | switch (len) |
82c230c2 | 1129 | { |
22df305e SC |
1130 | case 1: |
1131 | memcpy (valbuf, ®buf[HARD_D_REGNUM * 2 + 1], len); | |
1132 | break; | |
1133 | ||
1134 | case 2: | |
1135 | memcpy (valbuf, ®buf[HARD_D_REGNUM * 2], len); | |
1136 | break; | |
1137 | ||
1138 | case 3: | |
1139 | memcpy (&valbuf[0], ®buf[HARD_X_REGNUM * 2 + 1], 1); | |
1140 | memcpy (&valbuf[1], ®buf[HARD_D_REGNUM * 2], 2); | |
1141 | break; | |
1142 | ||
1143 | case 4: | |
1144 | memcpy (&valbuf[0], ®buf[HARD_X_REGNUM * 2], 2); | |
1145 | memcpy (&valbuf[2], ®buf[HARD_D_REGNUM * 2], 2); | |
1146 | break; | |
1147 | ||
1148 | default: | |
82c230c2 SC |
1149 | error ("bad size for return value"); |
1150 | } | |
1151 | } | |
1152 | ||
1153 | /* Should call_function allocate stack space for a struct return? */ | |
1154 | static int | |
1155 | m68hc11_use_struct_convention (int gcc_p, struct type *type) | |
1156 | { | |
22df305e SC |
1157 | return (TYPE_CODE (type) == TYPE_CODE_STRUCT |
1158 | || TYPE_CODE (type) == TYPE_CODE_UNION | |
1159 | || TYPE_LENGTH (type) > 4); | |
82c230c2 SC |
1160 | } |
1161 | ||
1162 | static int | |
1163 | m68hc11_return_value_on_stack (struct type *type) | |
1164 | { | |
22df305e | 1165 | return TYPE_LENGTH (type) > 4; |
82c230c2 SC |
1166 | } |
1167 | ||
1168 | /* Extract from an array REGBUF containing the (raw) register state | |
1169 | the address in which a function should return its structure value, | |
1170 | as a CORE_ADDR (or an expression that can be used as one). */ | |
1171 | static CORE_ADDR | |
1172 | m68hc11_extract_struct_value_address (char *regbuf) | |
1173 | { | |
1174 | return extract_address (®buf[HARD_D_REGNUM * 2], | |
1175 | REGISTER_RAW_SIZE (HARD_D_REGNUM)); | |
1176 | } | |
1177 | ||
1178 | /* Function: push_return_address (pc) | |
1179 | Set up the return address for the inferior function call. | |
1180 | Needed for targets where we don't actually execute a JSR/BSR instruction */ | |
1181 | ||
1182 | static CORE_ADDR | |
1183 | m68hc11_push_return_address (CORE_ADDR pc, CORE_ADDR sp) | |
1184 | { | |
1185 | char valbuf[2]; | |
1186 | ||
22df305e | 1187 | pc = CALL_DUMMY_ADDRESS (); |
82c230c2 SC |
1188 | sp -= 2; |
1189 | store_unsigned_integer (valbuf, 2, pc); | |
5d1a66bd | 1190 | write_memory (sp + STACK_CORRECTION, valbuf, 2); |
82c230c2 SC |
1191 | return sp; |
1192 | } | |
1193 | ||
7df11f59 SC |
1194 | /* Test whether the ELF symbol corresponds to a function using rtc or |
1195 | rti to return. */ | |
1196 | ||
1197 | static void | |
1198 | m68hc11_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym) | |
1199 | { | |
1200 | unsigned char flags; | |
1201 | ||
1202 | flags = ((elf_symbol_type *)sym)->internal_elf_sym.st_other; | |
1203 | if (flags & STO_M68HC12_FAR) | |
1204 | MSYMBOL_SET_RTC (msym); | |
1205 | if (flags & STO_M68HC12_INTERRUPT) | |
1206 | MSYMBOL_SET_RTI (msym); | |
1207 | } | |
1208 | ||
ea3881d9 SC |
1209 | static int |
1210 | gdb_print_insn_m68hc11 (bfd_vma memaddr, disassemble_info *info) | |
1211 | { | |
1212 | if (TARGET_ARCHITECTURE->arch == bfd_arch_m68hc11) | |
1213 | return print_insn_m68hc11 (memaddr, info); | |
1214 | else | |
1215 | return print_insn_m68hc12 (memaddr, info); | |
1216 | } | |
1217 | ||
b631436b SC |
1218 | \f |
1219 | ||
1220 | /* 68HC11/68HC12 register groups. | |
1221 | Identify real hard registers and soft registers used by gcc. */ | |
1222 | ||
1223 | static struct reggroup *m68hc11_soft_reggroup; | |
1224 | static struct reggroup *m68hc11_hard_reggroup; | |
1225 | ||
1226 | static void | |
1227 | m68hc11_init_reggroups (void) | |
1228 | { | |
1229 | m68hc11_hard_reggroup = reggroup_new ("hard", USER_REGGROUP); | |
1230 | m68hc11_soft_reggroup = reggroup_new ("soft", USER_REGGROUP); | |
1231 | } | |
1232 | ||
1233 | static void | |
1234 | m68hc11_add_reggroups (struct gdbarch *gdbarch) | |
1235 | { | |
1236 | reggroup_add (gdbarch, m68hc11_hard_reggroup); | |
1237 | reggroup_add (gdbarch, m68hc11_soft_reggroup); | |
1238 | reggroup_add (gdbarch, general_reggroup); | |
1239 | reggroup_add (gdbarch, float_reggroup); | |
1240 | reggroup_add (gdbarch, all_reggroup); | |
1241 | reggroup_add (gdbarch, save_reggroup); | |
1242 | reggroup_add (gdbarch, restore_reggroup); | |
1243 | reggroup_add (gdbarch, vector_reggroup); | |
1244 | reggroup_add (gdbarch, system_reggroup); | |
1245 | } | |
1246 | ||
1247 | static int | |
1248 | m68hc11_register_reggroup_p (struct gdbarch *gdbarch, int regnum, | |
1249 | struct reggroup *group) | |
1250 | { | |
1251 | /* We must save the real hard register as well as gcc | |
1252 | soft registers including the frame pointer. */ | |
1253 | if (group == save_reggroup || group == restore_reggroup) | |
1254 | { | |
1255 | return (regnum <= gdbarch_num_regs (gdbarch) | |
1256 | || ((regnum == SOFT_FP_REGNUM | |
1257 | || regnum == SOFT_TMP_REGNUM | |
1258 | || regnum == SOFT_ZS_REGNUM | |
1259 | || regnum == SOFT_XY_REGNUM) | |
1260 | && m68hc11_register_name (regnum))); | |
1261 | } | |
1262 | ||
1263 | /* Group to identify gcc soft registers (d1..dN). */ | |
1264 | if (group == m68hc11_soft_reggroup) | |
1265 | { | |
1266 | return regnum >= SOFT_D1_REGNUM && m68hc11_register_name (regnum); | |
1267 | } | |
1268 | ||
1269 | if (group == m68hc11_hard_reggroup) | |
1270 | { | |
1271 | return regnum == HARD_PC_REGNUM || regnum == HARD_SP_REGNUM | |
1272 | || regnum == HARD_X_REGNUM || regnum == HARD_D_REGNUM | |
1273 | || regnum == HARD_Y_REGNUM || regnum == HARD_CCR_REGNUM; | |
1274 | } | |
1275 | return default_register_reggroup_p (gdbarch, regnum, group); | |
1276 | } | |
1277 | ||
82c230c2 SC |
1278 | static struct gdbarch * |
1279 | m68hc11_gdbarch_init (struct gdbarch_info info, | |
1280 | struct gdbarch_list *arches) | |
1281 | { | |
1282 | static LONGEST m68hc11_call_dummy_words[] = | |
1283 | {0}; | |
1284 | struct gdbarch *gdbarch; | |
1285 | struct gdbarch_tdep *tdep; | |
81967506 | 1286 | int elf_flags; |
82c230c2 SC |
1287 | |
1288 | soft_reg_initialized = 0; | |
81967506 SC |
1289 | |
1290 | /* Extract the elf_flags if available. */ | |
1291 | if (info.abfd != NULL | |
1292 | && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour) | |
1293 | elf_flags = elf_elfheader (info.abfd)->e_flags; | |
1294 | else | |
1295 | elf_flags = 0; | |
1296 | ||
82c230c2 SC |
1297 | /* try to find a pre-existing architecture */ |
1298 | for (arches = gdbarch_list_lookup_by_info (arches, &info); | |
1299 | arches != NULL; | |
1300 | arches = gdbarch_list_lookup_by_info (arches->next, &info)) | |
1301 | { | |
81967506 SC |
1302 | if (gdbarch_tdep (arches->gdbarch)->elf_flags != elf_flags) |
1303 | continue; | |
1304 | ||
82c230c2 SC |
1305 | return arches->gdbarch; |
1306 | } | |
1307 | ||
1308 | /* Need a new architecture. Fill in a target specific vector. */ | |
1309 | tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep)); | |
1310 | gdbarch = gdbarch_alloc (&info, tdep); | |
81967506 | 1311 | tdep->elf_flags = elf_flags; |
ed99b3d0 | 1312 | |
a5afb99f AC |
1313 | /* NOTE: cagney/2002-12-06: This can be deleted when this arch is |
1314 | ready to unwind the PC first (see frame.c:get_prev_frame()). */ | |
1315 | set_gdbarch_deprecated_init_frame_pc (gdbarch, init_frame_pc_default); | |
1316 | ||
5d1a66bd SC |
1317 | switch (info.bfd_arch_info->arch) |
1318 | { | |
1319 | case bfd_arch_m68hc11: | |
1320 | tdep->stack_correction = 1; | |
7df11f59 | 1321 | tdep->use_page_register = 0; |
908f682f | 1322 | tdep->prologue = m6811_prologue; |
548bcbec SC |
1323 | set_gdbarch_addr_bit (gdbarch, 16); |
1324 | set_gdbarch_num_pseudo_regs (gdbarch, M68HC11_NUM_PSEUDO_REGS); | |
1325 | set_gdbarch_pc_regnum (gdbarch, HARD_PC_REGNUM); | |
1326 | set_gdbarch_num_regs (gdbarch, M68HC11_NUM_REGS); | |
5d1a66bd | 1327 | break; |
82c230c2 | 1328 | |
5d1a66bd SC |
1329 | case bfd_arch_m68hc12: |
1330 | tdep->stack_correction = 0; | |
7df11f59 | 1331 | tdep->use_page_register = elf_flags & E_M68HC12_BANKS; |
908f682f | 1332 | tdep->prologue = m6812_prologue; |
548bcbec SC |
1333 | set_gdbarch_addr_bit (gdbarch, elf_flags & E_M68HC12_BANKS ? 32 : 16); |
1334 | set_gdbarch_num_pseudo_regs (gdbarch, | |
1335 | elf_flags & E_M68HC12_BANKS | |
1336 | ? M68HC12_NUM_PSEUDO_REGS | |
1337 | : M68HC11_NUM_PSEUDO_REGS); | |
1338 | set_gdbarch_pc_regnum (gdbarch, elf_flags & E_M68HC12_BANKS | |
1339 | ? M68HC12_HARD_PC_REGNUM : HARD_PC_REGNUM); | |
1340 | set_gdbarch_num_regs (gdbarch, elf_flags & E_M68HC12_BANKS | |
1341 | ? M68HC12_NUM_REGS : M68HC11_NUM_REGS); | |
5d1a66bd SC |
1342 | break; |
1343 | ||
1344 | default: | |
1345 | break; | |
1346 | } | |
7d32ba20 SC |
1347 | |
1348 | /* Initially set everything according to the ABI. | |
1349 | Use 16-bit integers since it will be the case for most | |
1350 | programs. The size of these types should normally be set | |
1351 | according to the dwarf2 debug information. */ | |
82c230c2 | 1352 | set_gdbarch_short_bit (gdbarch, 16); |
81967506 | 1353 | set_gdbarch_int_bit (gdbarch, elf_flags & E_M68HC11_I32 ? 32 : 16); |
82c230c2 | 1354 | set_gdbarch_float_bit (gdbarch, 32); |
81967506 | 1355 | set_gdbarch_double_bit (gdbarch, elf_flags & E_M68HC11_F64 ? 64 : 32); |
2417dd25 | 1356 | set_gdbarch_long_double_bit (gdbarch, 64); |
82c230c2 SC |
1357 | set_gdbarch_long_bit (gdbarch, 32); |
1358 | set_gdbarch_ptr_bit (gdbarch, 16); | |
1359 | set_gdbarch_long_long_bit (gdbarch, 64); | |
1360 | ||
1361 | /* Set register info. */ | |
1362 | set_gdbarch_fp0_regnum (gdbarch, -1); | |
a0ed5532 AC |
1363 | set_gdbarch_deprecated_max_register_raw_size (gdbarch, 2); |
1364 | set_gdbarch_deprecated_max_register_virtual_size (gdbarch, 2); | |
f30ee0bc | 1365 | set_gdbarch_deprecated_frame_init_saved_regs (gdbarch, m68hc11_frame_init_saved_regs); |
82c230c2 SC |
1366 | set_gdbarch_frame_args_skip (gdbarch, 0); |
1367 | ||
1368 | set_gdbarch_read_pc (gdbarch, generic_target_read_pc); | |
1369 | set_gdbarch_write_pc (gdbarch, generic_target_write_pc); | |
1370 | set_gdbarch_read_fp (gdbarch, generic_target_read_fp); | |
82c230c2 | 1371 | set_gdbarch_read_sp (gdbarch, generic_target_read_sp); |
6c0e89ed | 1372 | set_gdbarch_deprecated_dummy_write_sp (gdbarch, generic_target_write_sp); |
82c230c2 | 1373 | |
82c230c2 SC |
1374 | set_gdbarch_sp_regnum (gdbarch, HARD_SP_REGNUM); |
1375 | set_gdbarch_fp_regnum (gdbarch, SOFT_FP_REGNUM); | |
82c230c2 SC |
1376 | set_gdbarch_register_name (gdbarch, m68hc11_register_name); |
1377 | set_gdbarch_register_size (gdbarch, 2); | |
1378 | set_gdbarch_register_bytes (gdbarch, M68HC11_ALL_REGS * 2); | |
1379 | set_gdbarch_register_virtual_type (gdbarch, m68hc11_register_virtual_type); | |
46ce284d AC |
1380 | set_gdbarch_pseudo_register_read (gdbarch, m68hc11_pseudo_register_read); |
1381 | set_gdbarch_pseudo_register_write (gdbarch, m68hc11_pseudo_register_write); | |
82c230c2 | 1382 | |
82c230c2 | 1383 | set_gdbarch_call_dummy_address (gdbarch, m68hc11_call_dummy_address); |
82c230c2 SC |
1384 | set_gdbarch_call_dummy_words (gdbarch, m68hc11_call_dummy_words); |
1385 | set_gdbarch_sizeof_call_dummy_words (gdbarch, | |
1386 | sizeof (m68hc11_call_dummy_words)); | |
129c1cd6 | 1387 | set_gdbarch_deprecated_get_saved_register (gdbarch, deprecated_generic_get_saved_register); |
26e9b323 | 1388 | set_gdbarch_deprecated_extract_return_value (gdbarch, m68hc11_extract_return_value); |
b81774d8 | 1389 | set_gdbarch_deprecated_push_arguments (gdbarch, m68hc11_push_arguments); |
28f617b3 | 1390 | set_gdbarch_deprecated_push_return_address (gdbarch, m68hc11_push_return_address); |
82c230c2 SC |
1391 | set_gdbarch_return_value_on_stack (gdbarch, m68hc11_return_value_on_stack); |
1392 | ||
4183d812 | 1393 | set_gdbarch_deprecated_store_struct_return (gdbarch, m68hc11_store_struct_return); |
ebba8386 | 1394 | set_gdbarch_deprecated_store_return_value (gdbarch, m68hc11_store_return_value); |
26e9b323 | 1395 | set_gdbarch_deprecated_extract_struct_value_address (gdbarch, m68hc11_extract_struct_value_address); |
82c230c2 SC |
1396 | set_gdbarch_register_convertible (gdbarch, generic_register_convertible_not); |
1397 | ||
1398 | ||
618ce49f | 1399 | set_gdbarch_deprecated_frame_chain (gdbarch, m68hc11_frame_chain); |
8bedc050 | 1400 | set_gdbarch_deprecated_frame_saved_pc (gdbarch, m68hc11_frame_saved_pc); |
82c230c2 SC |
1401 | set_gdbarch_frame_args_address (gdbarch, m68hc11_frame_args_address); |
1402 | set_gdbarch_frame_locals_address (gdbarch, m68hc11_frame_locals_address); | |
6913c89a | 1403 | set_gdbarch_deprecated_saved_pc_after_call (gdbarch, m68hc11_saved_pc_after_call); |
82c230c2 SC |
1404 | set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown); |
1405 | ||
129c1cd6 | 1406 | set_gdbarch_deprecated_get_saved_register (gdbarch, deprecated_generic_get_saved_register); |
82c230c2 | 1407 | |
4183d812 | 1408 | set_gdbarch_deprecated_store_struct_return (gdbarch, m68hc11_store_struct_return); |
ebba8386 | 1409 | set_gdbarch_deprecated_store_return_value (gdbarch, m68hc11_store_return_value); |
26e9b323 | 1410 | set_gdbarch_deprecated_extract_struct_value_address |
82c230c2 SC |
1411 | (gdbarch, m68hc11_extract_struct_value_address); |
1412 | set_gdbarch_use_struct_convention (gdbarch, m68hc11_use_struct_convention); | |
e9582e71 | 1413 | set_gdbarch_deprecated_init_extra_frame_info (gdbarch, m68hc11_init_extra_frame_info); |
749b82f6 | 1414 | set_gdbarch_deprecated_pop_frame (gdbarch, m68hc11_pop_frame); |
82c230c2 SC |
1415 | set_gdbarch_skip_prologue (gdbarch, m68hc11_skip_prologue); |
1416 | set_gdbarch_inner_than (gdbarch, core_addr_lessthan); | |
1417 | set_gdbarch_decr_pc_after_break (gdbarch, 0); | |
1418 | set_gdbarch_function_start_offset (gdbarch, 0); | |
1419 | set_gdbarch_breakpoint_from_pc (gdbarch, m68hc11_breakpoint_from_pc); | |
22df305e | 1420 | set_gdbarch_stack_align (gdbarch, m68hc11_stack_align); |
f933a9c5 | 1421 | set_gdbarch_deprecated_extra_stack_alignment_needed (gdbarch, 1); |
70ed8774 | 1422 | set_gdbarch_print_insn (gdbarch, gdb_print_insn_m68hc11); |
82c230c2 | 1423 | |
b631436b SC |
1424 | m68hc11_add_reggroups (gdbarch); |
1425 | set_gdbarch_register_reggroup_p (gdbarch, m68hc11_register_reggroup_p); | |
1426 | ||
7df11f59 SC |
1427 | /* Minsymbol frobbing. */ |
1428 | set_gdbarch_elf_make_msymbol_special (gdbarch, | |
1429 | m68hc11_elf_make_msymbol_special); | |
1430 | ||
82c230c2 | 1431 | set_gdbarch_believe_pcc_promotion (gdbarch, 1); |
82c230c2 SC |
1432 | |
1433 | return gdbarch; | |
78073dd8 AC |
1434 | } |
1435 | ||
1436 | void | |
fba45db2 | 1437 | _initialize_m68hc11_tdep (void) |
78073dd8 | 1438 | { |
82c230c2 | 1439 | register_gdbarch_init (bfd_arch_m68hc11, m68hc11_gdbarch_init); |
ea3881d9 | 1440 | register_gdbarch_init (bfd_arch_m68hc12, m68hc11_gdbarch_init); |
b631436b | 1441 | m68hc11_init_reggroups (); |
78073dd8 AC |
1442 | |
1443 | add_com ("regs", class_vars, show_regs, "Print all registers"); | |
1444 | } | |
1445 |