* Fix for PR 18665, from sky branch.
[binutils-gdb.git] / gdb / mn10300-tdep.c
blobeb2426ff59ac22c50de306f2e5971f923f16edf7
1 /* Target-dependent code for the Matsushita MN10300 for GDB, the GNU debugger.
2 Copyright 1996, 1997, 1998 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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. */
20 #include "defs.h"
21 #include "frame.h"
22 #include "inferior.h"
23 #include "obstack.h"
24 #include "target.h"
25 #include "value.h"
26 #include "bfd.h"
27 #include "gdb_string.h"
28 #include "gdbcore.h"
29 #include "symfile.h"
31 static char *mn10300_generic_register_names[] =
32 { "d0", "d1", "d2", "d3", "a0", "a1", "a2", "a3",
33 "sp", "pc", "mdr", "psw", "lir", "lar", "", "",
34 "", "", "", "", "", "", "", "",
35 "", "", "", "", "", "", "", "fp" };
37 char **mn10300_register_names = mn10300_generic_register_names;
38 /* start-sanitize-am33 */
39 static char *am33_register_names [] =
40 { "d0", "d1", "d2", "d3", "a0", "a1", "a2", "a3",
41 "sp", "pc", "mdr", "psw", "lir", "lar", "",
42 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
43 "ssp", "msp", "usp", "mcrh", "mcrl", "mcvf", "", "", ""};
44 static int am33_mode;
45 /* end-sanitize-am33 */
47 static CORE_ADDR mn10300_analyze_prologue PARAMS ((struct frame_info *fi,
48 CORE_ADDR pc));
50 /* Values for frame_info.status */
52 #define MY_FRAME_IN_SP 0x1
53 #define MY_FRAME_IN_FP 0x2
54 #define NO_MORE_FRAMES 0x4
57 /* Should call_function allocate stack space for a struct return? */
58 int
59 mn10300_use_struct_convention (gcc_p, type)
60 int gcc_p;
61 struct type *type;
63 return (TYPE_NFIELDS (type) > 1 || TYPE_LENGTH (type) > 8);
66 /* The breakpoint instruction must be the same size as the smallest
67 instruction in the instruction set.
69 The Matsushita mn10x00 processors have single byte instructions
70 so we need a single byte breakpoint. Matsushita hasn't defined
71 one, so we defined it ourselves. */
73 unsigned char *
74 mn10300_breakpoint_from_pc (bp_addr, bp_size)
75 CORE_ADDR *bp_addr;
76 int *bp_size;
78 static char breakpoint[] = {0xff};
79 *bp_size = 1;
80 return breakpoint;
84 /* Fix fi->frame if it's bogus at this point. This is a helper
85 function for mn10300_analyze_prologue. */
87 static void
88 fix_frame_pointer (fi, stack_size)
89 struct frame_info *fi;
90 int stack_size;
92 if (fi && fi->next == NULL)
94 if (fi->status & MY_FRAME_IN_SP)
95 fi->frame = read_sp () - stack_size;
96 else if (fi->status & MY_FRAME_IN_FP)
97 fi->frame = read_register (A3_REGNUM);
102 /* Set offsets of registers saved by movm instruction.
103 This is a helper function for mn10300_analyze_prologue. */
105 static void
106 set_movm_offsets (fi, movm_args)
107 struct frame_info *fi;
108 int movm_args;
110 int offset = 0;
112 if (fi == NULL || movm_args == 0)
113 return;
115 if (movm_args & 0x10)
117 fi->fsr.regs[A3_REGNUM] = fi->frame + offset;
118 offset += 4;
120 if (movm_args & 0x20)
122 fi->fsr.regs[A2_REGNUM] = fi->frame + offset;
123 offset += 4;
125 if (movm_args & 0x40)
127 fi->fsr.regs[D3_REGNUM] = fi->frame + offset;
128 offset += 4;
130 if (movm_args & 0x80)
132 fi->fsr.regs[D2_REGNUM] = fi->frame + offset;
133 offset += 4;
135 /* start-sanitize-am33 */
136 if (am33_mode && movm_args & 0x02)
138 fi->fsr.regs[E0_REGNUM+5] = fi->frame + offset;
139 fi->fsr.regs[E0_REGNUM+4] = fi->frame + offset + 4;
140 fi->fsr.regs[E0_REGNUM+3] = fi->frame + offset + 8;
141 fi->fsr.regs[E0_REGNUM+2] = fi->frame + offset + 12;
143 /* end-sanitize-am33 */
147 /* The main purpose of this file is dealing with prologues to extract
148 information about stack frames and saved registers.
150 For reference here's how prologues look on the mn10300:
152 With frame pointer:
153 movm [d2,d3,a2,a3],sp
154 mov sp,a3
155 add <size>,sp
157 Without frame pointer:
158 movm [d2,d3,a2,a3],sp (if needed)
159 add <size>,sp
161 One day we might keep the stack pointer constant, that won't
162 change the code for prologues, but it will make the frame
163 pointerless case much more common. */
165 /* Analyze the prologue to determine where registers are saved,
166 the end of the prologue, etc etc. Return the end of the prologue
167 scanned.
169 We store into FI (if non-null) several tidbits of information:
171 * stack_size -- size of this stack frame. Note that if we stop in
172 certain parts of the prologue/epilogue we may claim the size of the
173 current frame is zero. This happens when the current frame has
174 not been allocated yet or has already been deallocated.
176 * fsr -- Addresses of registers saved in the stack by this frame.
178 * status -- A (relatively) generic status indicator. It's a bitmask
179 with the following bits:
181 MY_FRAME_IN_SP: The base of the current frame is actually in
182 the stack pointer. This can happen for frame pointerless
183 functions, or cases where we're stopped in the prologue/epilogue
184 itself. For these cases mn10300_analyze_prologue will need up
185 update fi->frame before returning or analyzing the register
186 save instructions.
188 MY_FRAME_IN_FP: The base of the current frame is in the
189 frame pointer register ($a2).
191 NO_MORE_FRAMES: Set this if the current frame is "start" or
192 if the first instruction looks like mov <imm>,sp. This tells
193 frame chain to not bother trying to unwind past this frame. */
195 static CORE_ADDR
196 mn10300_analyze_prologue (fi, pc)
197 struct frame_info *fi;
198 CORE_ADDR pc;
200 CORE_ADDR func_addr, func_end, addr, stop;
201 CORE_ADDR stack_size;
202 int imm_size;
203 unsigned char buf[4];
204 int status, movm_args = 0;
205 char *name;
207 /* Use the PC in the frame if it's provided to look up the
208 start of this function. */
209 pc = (fi ? fi->pc : pc);
211 /* Find the start of this function. */
212 status = find_pc_partial_function (pc, &name, &func_addr, &func_end);
214 /* Do nothing if we couldn't find the start of this function or if we're
215 stopped at the first instruction in the prologue. */
216 if (status == 0)
217 return pc;
219 /* If we're in start, then give up. */
220 if (strcmp (name, "start") == 0)
222 if (fi != NULL)
223 fi->status = NO_MORE_FRAMES;
224 return pc;
227 /* At the start of a function our frame is in the stack pointer. */
228 if (fi)
229 fi->status = MY_FRAME_IN_SP;
231 /* Get the next two bytes into buf, we need two because rets is a two
232 byte insn and the first isn't enough to uniquely identify it. */
233 status = read_memory_nobpt (pc, buf, 2);
234 if (status != 0)
235 return pc;
237 /* If we're physically on an "rets" instruction, then our frame has
238 already been deallocated. Note this can also be true for retf
239 and ret if they specify a size of zero.
241 In this case fi->frame is bogus, we need to fix it. */
242 if (fi && buf[0] == 0xf0 && buf[1] == 0xfc)
244 if (fi->next == NULL)
245 fi->frame = read_sp ();
246 return fi->pc;
249 /* Similarly if we're stopped on the first insn of a prologue as our
250 frame hasn't been allocated yet. */
251 if (fi && fi->pc == func_addr)
253 if (fi->next == NULL)
254 fi->frame = read_sp ();
255 return fi->pc;
258 /* Figure out where to stop scanning. */
259 stop = fi ? fi->pc : func_end;
261 /* Don't walk off the end of the function. */
262 stop = stop > func_end ? func_end : stop;
264 /* Start scanning on the first instruction of this function. */
265 addr = func_addr;
267 /* Suck in two bytes. */
268 status = read_memory_nobpt (addr, buf, 2);
269 if (status != 0)
271 fix_frame_pointer (fi, 0);
272 return addr;
275 /* First see if this insn sets the stack pointer; if so, it's something
276 we won't understand, so quit now. */
277 if (buf[0] == 0xf2 && (buf[1] & 0xf3) == 0xf0)
279 if (fi)
280 fi->status = NO_MORE_FRAMES;
281 return addr;
284 /* Now look for movm [regs],sp, which saves the callee saved registers.
286 At this time we don't know if fi->frame is valid, so we only note
287 that we encountered a movm instruction. Later, we'll set the entries
288 in fsr.regs as needed. */
289 if (buf[0] == 0xcf)
291 /* Extract the register list for the movm instruction. */
292 status = read_memory_nobpt (addr + 1, buf, 1);
293 movm_args = *buf;
295 addr += 2;
297 /* Quit now if we're beyond the stop point. */
298 if (addr >= stop)
300 /* Fix fi->frame since it's bogus at this point. */
301 if (fi && fi->next == NULL)
302 fi->frame = read_sp ();
304 /* Note if/where callee saved registers were saved. */
305 set_movm_offsets (fi, movm_args);
306 return addr;
309 /* Get the next two bytes so the prologue scan can continue. */
310 status = read_memory_nobpt (addr, buf, 2);
311 if (status != 0)
313 /* Fix fi->frame since it's bogus at this point. */
314 if (fi && fi->next == NULL)
315 fi->frame = read_sp ();
317 /* Note if/where callee saved registers were saved. */
318 set_movm_offsets (fi, movm_args);
319 return addr;
323 /* Now see if we set up a frame pointer via "mov sp,a3" */
324 if (buf[0] == 0x3f)
326 addr += 1;
328 /* The frame pointer is now valid. */
329 if (fi)
331 fi->status |= MY_FRAME_IN_FP;
332 fi->status &= ~MY_FRAME_IN_SP;
335 /* Quit now if we're beyond the stop point. */
336 if (addr >= stop)
338 /* Fix fi->frame if it's bogus at this point. */
339 fix_frame_pointer (fi, 0);
341 /* Note if/where callee saved registers were saved. */
342 set_movm_offsets (fi, movm_args);
343 return addr;
346 /* Get two more bytes so scanning can continue. */
347 status = read_memory_nobpt (addr, buf, 2);
348 if (status != 0)
350 /* Fix fi->frame if it's bogus at this point. */
351 fix_frame_pointer (fi, 0);
353 /* Note if/where callee saved registers were saved. */
354 set_movm_offsets (fi, movm_args);
355 return addr;
359 /* Next we should allocate the local frame. No more prologue insns
360 are found after allocating the local frame.
362 Search for add imm8,sp (0xf8feXX)
363 or add imm16,sp (0xfafeXXXX)
364 or add imm32,sp (0xfcfeXXXXXXXX).
366 If none of the above was found, then this prologue has no
367 additional stack. */
369 status = read_memory_nobpt (addr, buf, 2);
370 if (status != 0)
372 /* Fix fi->frame if it's bogus at this point. */
373 fix_frame_pointer (fi, 0);
375 /* Note if/where callee saved registers were saved. */
376 set_movm_offsets (fi, movm_args);
377 return addr;
380 imm_size = 0;
381 if (buf[0] == 0xf8 && buf[1] == 0xfe)
382 imm_size = 1;
383 else if (buf[0] == 0xfa && buf[1] == 0xfe)
384 imm_size = 2;
385 else if (buf[0] == 0xfc && buf[1] == 0xfe)
386 imm_size = 4;
388 if (imm_size != 0)
390 /* Suck in imm_size more bytes, they'll hold the size of the
391 current frame. */
392 status = read_memory_nobpt (addr + 2, buf, imm_size);
393 if (status != 0)
395 /* Fix fi->frame if it's bogus at this point. */
396 fix_frame_pointer (fi, 0);
398 /* Note if/where callee saved registers were saved. */
399 set_movm_offsets (fi, movm_args);
400 return addr;
403 /* Note the size of the stack in the frame info structure. */
404 stack_size = extract_signed_integer (buf, imm_size);
405 if (fi)
406 fi->stack_size = stack_size;
408 /* We just consumed 2 + imm_size bytes. */
409 addr += 2 + imm_size;
411 /* No more prologue insns follow, so begin preparation to return. */
412 /* Fix fi->frame if it's bogus at this point. */
413 fix_frame_pointer (fi, stack_size);
415 /* Note if/where callee saved registers were saved. */
416 set_movm_offsets (fi, movm_args);
417 return addr;
420 /* We never found an insn which allocates local stack space, regardless
421 this is the end of the prologue. */
422 /* Fix fi->frame if it's bogus at this point. */
423 fix_frame_pointer (fi, 0);
425 /* Note if/where callee saved registers were saved. */
426 set_movm_offsets (fi, movm_args);
427 return addr;
430 /* Function: frame_chain
431 Figure out and return the caller's frame pointer given current
432 frame_info struct.
434 We don't handle dummy frames yet but we would probably just return the
435 stack pointer that was in use at the time the function call was made? */
437 CORE_ADDR
438 mn10300_frame_chain (fi)
439 struct frame_info *fi;
441 struct frame_info dummy_frame;
443 /* Walk through the prologue to determine the stack size,
444 location of saved registers, end of the prologue, etc. */
445 if (fi->status == 0)
446 mn10300_analyze_prologue (fi, (CORE_ADDR)0);
448 /* Quit now if mn10300_analyze_prologue set NO_MORE_FRAMES. */
449 if (fi->status & NO_MORE_FRAMES)
450 return 0;
452 /* Now that we've analyzed our prologue, determine the frame
453 pointer for our caller.
455 If our caller has a frame pointer, then we need to
456 find the entry value of $a3 to our function.
458 If fsr.regs[A3_REGNUM] is nonzero, then it's at the memory
459 location pointed to by fsr.regs[A3_REGNUM].
461 Else it's still in $a3.
463 If our caller does not have a frame pointer, then his
464 frame base is fi->frame + -caller's stack size. */
466 /* The easiest way to get that info is to analyze our caller's frame.
468 So we set up a dummy frame and call mn10300_analyze_prologue to
469 find stuff for us. */
470 dummy_frame.pc = FRAME_SAVED_PC (fi);
471 dummy_frame.frame = fi->frame;
472 memset (dummy_frame.fsr.regs, '\000', sizeof dummy_frame.fsr.regs);
473 dummy_frame.status = 0;
474 dummy_frame.stack_size = 0;
475 mn10300_analyze_prologue (&dummy_frame, 0);
477 if (dummy_frame.status & MY_FRAME_IN_FP)
479 /* Our caller has a frame pointer. So find the frame in $a3 or
480 in the stack. */
481 if (fi->fsr.regs[A3_REGNUM])
482 return (read_memory_integer (fi->fsr.regs[A3_REGNUM], REGISTER_SIZE));
483 else
484 return read_register (A3_REGNUM);
486 else
488 int adjust = 0;
490 adjust += (fi->fsr.regs[D2_REGNUM] ? 4 : 0);
491 adjust += (fi->fsr.regs[D3_REGNUM] ? 4 : 0);
492 adjust += (fi->fsr.regs[A2_REGNUM] ? 4 : 0);
493 adjust += (fi->fsr.regs[A3_REGNUM] ? 4 : 0);
494 /* start-sanitize-am33 */
495 if (am33_mode)
497 adjust += (fi->fsr.regs[E0_REGNUM+5] ? 4 : 0);
498 adjust += (fi->fsr.regs[E0_REGNUM+4] ? 4 : 0);
499 adjust += (fi->fsr.regs[E0_REGNUM+3] ? 4 : 0);
500 adjust += (fi->fsr.regs[E0_REGNUM+2] ? 4 : 0);
502 /* end-sanitize-am33 */
504 /* Our caller does not have a frame pointer. So his frame starts
505 at the base of our frame (fi->frame) + register save space
506 + <his size>. */
507 return fi->frame + adjust + -dummy_frame.stack_size;
511 /* Function: skip_prologue
512 Return the address of the first inst past the prologue of the function. */
514 CORE_ADDR
515 mn10300_skip_prologue (pc)
516 CORE_ADDR pc;
518 /* We used to check the debug symbols, but that can lose if
519 we have a null prologue. */
520 return mn10300_analyze_prologue (NULL, pc);
524 /* Function: pop_frame
525 This routine gets called when either the user uses the `return'
526 command, or the call dummy breakpoint gets hit. */
528 void
529 mn10300_pop_frame (frame)
530 struct frame_info *frame;
532 int regnum;
534 if (PC_IN_CALL_DUMMY(frame->pc, frame->frame, frame->frame))
535 generic_pop_dummy_frame ();
536 else
538 write_register (PC_REGNUM, FRAME_SAVED_PC (frame));
540 /* Restore any saved registers. */
541 for (regnum = 0; regnum < NUM_REGS; regnum++)
542 if (frame->fsr.regs[regnum] != 0)
544 ULONGEST value;
546 value = read_memory_unsigned_integer (frame->fsr.regs[regnum],
547 REGISTER_RAW_SIZE (regnum));
548 write_register (regnum, value);
551 /* Actually cut back the stack. */
552 write_register (SP_REGNUM, FRAME_FP (frame));
554 /* Don't we need to set the PC?!? XXX FIXME. */
557 /* Throw away any cached frame information. */
558 flush_cached_frames ();
561 /* Function: push_arguments
562 Setup arguments for a call to the target. Arguments go in
563 order on the stack. */
565 CORE_ADDR
566 mn10300_push_arguments (nargs, args, sp, struct_return, struct_addr)
567 int nargs;
568 value_ptr *args;
569 CORE_ADDR sp;
570 unsigned char struct_return;
571 CORE_ADDR struct_addr;
573 int argnum = 0;
574 int len = 0;
575 int stack_offset = 0;
576 int regsused = struct_return ? 1 : 0;
578 /* This should be a nop, but align the stack just in case something
579 went wrong. Stacks are four byte aligned on the mn10300. */
580 sp &= ~3;
582 /* Now make space on the stack for the args.
584 XXX This doesn't appear to handle pass-by-invisible reference
585 arguments. */
586 for (argnum = 0; argnum < nargs; argnum++)
588 int arg_length = (TYPE_LENGTH (VALUE_TYPE (args[argnum])) + 3) & ~3;
590 while (regsused < 2 && arg_length > 0)
592 regsused++;
593 arg_length -= 4;
595 len += arg_length;
598 /* Allocate stack space. */
599 sp -= len;
601 regsused = struct_return ? 1 : 0;
602 /* Push all arguments onto the stack. */
603 for (argnum = 0; argnum < nargs; argnum++)
605 int len;
606 char *val;
608 /* XXX Check this. What about UNIONS? */
609 if (TYPE_CODE (VALUE_TYPE (*args)) == TYPE_CODE_STRUCT
610 && TYPE_LENGTH (VALUE_TYPE (*args)) > 8)
612 /* XXX Wrong, we want a pointer to this argument. */
613 len = TYPE_LENGTH (VALUE_TYPE (*args));
614 val = (char *)VALUE_CONTENTS (*args);
616 else
618 len = TYPE_LENGTH (VALUE_TYPE (*args));
619 val = (char *)VALUE_CONTENTS (*args);
622 while (regsused < 2 && len > 0)
624 write_register (regsused, extract_unsigned_integer (val, 4));
625 val += 4;
626 len -= 4;
627 regsused++;
630 while (len > 0)
632 write_memory (sp + stack_offset, val, 4);
633 len -= 4;
634 val += 4;
635 stack_offset += 4;
638 args++;
641 /* Make space for the flushback area. */
642 sp -= 8;
643 return sp;
646 /* Function: push_return_address (pc)
647 Set up the return address for the inferior function call.
648 Needed for targets where we don't actually execute a JSR/BSR instruction */
650 CORE_ADDR
651 mn10300_push_return_address (pc, sp)
652 CORE_ADDR pc;
653 CORE_ADDR sp;
655 unsigned char buf[4];
657 store_unsigned_integer (buf, 4, CALL_DUMMY_ADDRESS ());
658 write_memory (sp - 4, buf, 4);
659 return sp - 4;
662 /* Function: store_struct_return (addr,sp)
663 Store the structure value return address for an inferior function
664 call. */
666 CORE_ADDR
667 mn10300_store_struct_return (addr, sp)
668 CORE_ADDR addr;
669 CORE_ADDR sp;
671 /* The structure return address is passed as the first argument. */
672 write_register (0, addr);
673 return sp;
676 /* Function: frame_saved_pc
677 Find the caller of this frame. We do this by seeing if RP_REGNUM
678 is saved in the stack anywhere, otherwise we get it from the
679 registers. If the inner frame is a dummy frame, return its PC
680 instead of RP, because that's where "caller" of the dummy-frame
681 will be found. */
683 CORE_ADDR
684 mn10300_frame_saved_pc (fi)
685 struct frame_info *fi;
687 int adjust = 0;
689 adjust += (fi->fsr.regs[D2_REGNUM] ? 4 : 0);
690 adjust += (fi->fsr.regs[D3_REGNUM] ? 4 : 0);
691 adjust += (fi->fsr.regs[A2_REGNUM] ? 4 : 0);
692 adjust += (fi->fsr.regs[A3_REGNUM] ? 4 : 0);
693 /* start-sanitize-am33 */
694 if (am33_mode)
696 adjust += (fi->fsr.regs[E0_REGNUM+5] ? 4 : 0);
697 adjust += (fi->fsr.regs[E0_REGNUM+4] ? 4 : 0);
698 adjust += (fi->fsr.regs[E0_REGNUM+3] ? 4 : 0);
699 adjust += (fi->fsr.regs[E0_REGNUM+2] ? 4 : 0);
701 /* end-sanitize-am33 */
703 return (read_memory_integer (fi->frame + adjust, REGISTER_SIZE));
706 void
707 get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval)
708 char *raw_buffer;
709 int *optimized;
710 CORE_ADDR *addrp;
711 struct frame_info *frame;
712 int regnum;
713 enum lval_type *lval;
715 generic_get_saved_register (raw_buffer, optimized, addrp,
716 frame, regnum, lval);
719 /* Function: init_extra_frame_info
720 Setup the frame's frame pointer, pc, and frame addresses for saved
721 registers. Most of the work is done in mn10300_analyze_prologue().
723 Note that when we are called for the last frame (currently active frame),
724 that fi->pc and fi->frame will already be setup. However, fi->frame will
725 be valid only if this routine uses FP. For previous frames, fi-frame will
726 always be correct. mn10300_analyze_prologue will fix fi->frame if
727 it's not valid.
729 We can be called with the PC in the call dummy under two circumstances.
730 First, during normal backtracing, second, while figuring out the frame
731 pointer just prior to calling the target function (see run_stack_dummy). */
733 void
734 mn10300_init_extra_frame_info (fi)
735 struct frame_info *fi;
737 if (fi->next)
738 fi->pc = FRAME_SAVED_PC (fi->next);
740 memset (fi->fsr.regs, '\000', sizeof fi->fsr.regs);
741 fi->status = 0;
742 fi->stack_size = 0;
744 mn10300_analyze_prologue (fi, 0);
747 /* Function: mn10300_virtual_frame_pointer
748 Return the register that the function uses for a frame pointer,
749 plus any necessary offset to be applied to the register before
750 any frame pointer offsets. */
752 void
753 mn10300_virtual_frame_pointer (pc, reg, offset)
754 CORE_ADDR pc;
755 long *reg;
756 long *offset;
758 struct frame_info fi;
760 /* Set up a dummy frame_info. */
761 fi.next = NULL;
762 fi.prev = NULL;
763 fi.frame = 0;
764 fi.pc = pc;
766 /* Analyze the prolog and fill in the extra info. */
767 mn10300_init_extra_frame_info (&fi);
769 /* Results will tell us which type of frame it uses. */
770 if (fi.status & MY_FRAME_IN_SP)
772 *reg = SP_REGNUM;
773 *offset = -(fi.stack_size);
775 else
777 *reg = A3_REGNUM;
778 *offset = 0;
782 /* This can be made more generic later. */
783 static void
784 set_machine_hook (filename)
785 char *filename;
787 int i;
789 if (bfd_get_mach (exec_bfd) == bfd_mach_mn10300
790 || bfd_get_mach (exec_bfd) == 0)
792 mn10300_register_names = mn10300_generic_register_names;
795 /* start-sanitize-am33 */
796 am33_mode = 0;
797 if (bfd_get_mach (exec_bfd) == bfd_mach_am33)
800 mn10300_register_names = am33_register_names;
801 am33_mode = 1;
803 /* end-sanitize-am33 */
806 void
807 _initialize_mn10300_tdep ()
809 /* printf("_initialize_mn10300_tdep\n"); */
811 tm_print_insn = print_insn_mn10300;
813 specify_exec_file_hook (set_machine_hook);