1 /* Target-machine dependent code for WDC-65816, for GDB.
2 Copyright (C) 1995 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,
19 Boston, MA 02111-1307, USA. */
22 Contributed by Steve Chamberlain
35 /* Return the saved PC from this frame. */
39 w65_frame_saved_pc (struct frame_info *frame)
41 return (read_memory_integer (frame->frame + 2, 4) & 0xffffff);
45 w65_addr_bits_remove (CORE_ADDR addr)
47 return ((addr) & 0xffffff);
50 read_memory_pointer (CORE_ADDR x)
52 return read_memory_integer (ADDR_BITS_REMOVE (x), 4);
61 w65_push_dummy_frame (void)
66 /* Put here the code to store, into a struct frame_saved_regs,
67 the addresses of the saved registers of frame described by FRAME_INFO.
68 This includes special registers such as pc and fp saved in special
69 ways in the stack frame. sp is even more special:
70 the address we return for it IS the sp for the next frame.
72 We cache the result of doing this in the frame_cache_obstack, since
73 it is fairly expensive. */
76 frame_find_saved_regs (struct frame_info *fip, struct frame_saved_regs *fsrp)
83 memset (fsrp, 0, sizeof *fsrp);
87 saved_pc_after_call (void)
89 int sp = read_register (SP_REGNUM);
90 int val = read_memory_integer (sp + 1, 4);
91 return ADDR_BITS_REMOVE (val);
95 extract_return_value (struct type *type, char *regbuf, char *valbuf)
98 int len = TYPE_LENGTH (type);
100 for (b = 0; b < len; b += 2)
105 memcpy (valbuf + b, regbuf + b, todo);
110 write_return_value (struct type *type, char *valbuf)
114 for (len = 0; len < TYPE_LENGTH (type); len += 2)
116 write_register_bytes (REGISTER_BYTE (len / 2 + 2), valbuf + len, 2);
121 store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
123 write_register (2, addr);
131 init_extra_frame_info (void)
139 w65_frame_chain (struct frame_info *thisframe)
141 return 0xffff & read_memory_integer ((thisframe)->frame, 2);
147 return read_memory_integer (x, 1) & 0xff;
151 w65_skip_prologue (CORE_ADDR pc)
153 CORE_ADDR too_far = pc + 20;
155 /* looking for bits of the prologue, we can expect to
156 see this in a frameful function:
185 /* Skip a stack adjust - any area between a tsc and tcs */
188 while (pc < too_far && gb (pc) != TCS)
193 /* Skip a stupid inc a */
198 /* Stack adjust can also be done with n pha's */
199 while (gb (pc) == PHA)
202 /* Skip a link - that's a ld/ph/tsc/inc/sta */
204 if (gb (pc) == LDADIR
205 && gb (pc + 5) == STADIR
206 && gb (pc + 1) == gb (pc + 6)
207 && gb (pc + 2) == PHA
208 && gb (pc + 3) == TSC
209 && gb (pc + 4) == INCA)
218 register_raw_size (int n)
220 return sim_reg_size (n);
225 print_register_hook (int regno)
227 if (regno == P_REGNUM)
231 int C, Z, N, V, I, D, X, M;
235 read_relative_register_raw_bytes (regno, b);
237 printf_unfiltered ("\t");
247 printf_unfiltered ("N-%d ", N);
248 printf_unfiltered ("V-%d ", V);
249 printf_unfiltered ("M-%d ", M);
250 printf_unfiltered ("X-%d ", X);
251 printf_unfiltered ("D-%d ", D);
252 printf_unfiltered ("I-%d ", I);
253 printf_unfiltered ("Z-%d ", Z);
254 printf_unfiltered ("C-%d ", C);
256 printf_unfiltered ("u> ");
258 printf_unfiltered ("u<= ");
260 printf_unfiltered ("u>= ");
262 printf_unfiltered ("u< ");
264 printf_unfiltered ("!= ");
266 printf_unfiltered ("== ");
268 printf_unfiltered (">= ");
270 printf_unfiltered ("< ");
271 if ((Z | (N ^ V)) == 0)
272 printf_unfiltered ("> ");
273 if ((Z | (N ^ V)) == 1)
274 printf_unfiltered ("<= ");
279 _initialize_w65_tdep (void)
281 tm_print_insn = print_insn_w65;