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 (frame)
40 struct frame_info *frame;
42 return (read_memory_integer (frame->frame + 2, 4) & 0xffffff);
46 w65_addr_bits_remove (addr)
49 return ((addr) & 0xffffff);
52 read_memory_pointer (x)
55 return read_memory_integer (ADDR_BITS_REMOVE (x), 4);
64 w65_push_dummy_frame ()
69 /* Put here the code to store, into a struct frame_saved_regs,
70 the addresses of the saved registers of frame described by FRAME_INFO.
71 This includes special registers such as pc and fp saved in special
72 ways in the stack frame. sp is even more special:
73 the address we return for it IS the sp for the next frame.
75 We cache the result of doing this in the frame_cache_obstack, since
76 it is fairly expensive. */
79 frame_find_saved_regs (fip, fsrp)
80 struct frame_info *fip;
81 struct frame_saved_regs *fsrp;
88 memset (fsrp, 0, sizeof *fsrp);
92 saved_pc_after_call ()
94 int sp = read_register (SP_REGNUM);
95 int val = read_memory_integer (sp + 1, 4);
96 return ADDR_BITS_REMOVE (val);
100 extract_return_value (type, regbuf, valbuf)
106 int len = TYPE_LENGTH (type);
108 for (b = 0; b < len; b += 2)
113 memcpy (valbuf + b, regbuf + b, todo);
118 write_return_value (type, valbuf)
124 for (len = 0; len < TYPE_LENGTH (type); len += 2)
126 write_register_bytes (REGISTER_BYTE (len / 2 + 2), valbuf + len, 2);
131 store_struct_return (addr, sp)
135 write_register (2, addr);
143 init_extra_frame_info ()
151 w65_frame_chain (thisframe)
152 struct frame_info *thisframe;
154 return 0xffff & read_memory_integer ((thisframe)->frame, 2);
160 return read_memory_integer (x, 1) & 0xff;
164 w65_skip_prologue (pc)
167 CORE_ADDR too_far = pc + 20;
169 /* looking for bits of the prologue, we can expect to
170 see this in a frameful function:
199 /* Skip a stack adjust - any area between a tsc and tcs */
202 while (pc < too_far && gb (pc) != TCS)
207 /* Skip a stupid inc a */
212 /* Stack adjust can also be done with n pha's */
213 while (gb (pc) == PHA)
216 /* Skip a link - that's a ld/ph/tsc/inc/sta */
218 if (gb (pc) == LDADIR
219 && gb (pc + 5) == STADIR
220 && gb (pc + 1) == gb (pc + 6)
221 && gb (pc + 2) == PHA
222 && gb (pc + 3) == TSC
223 && gb (pc + 4) == INCA)
232 register_raw_size (n)
234 return sim_reg_size (n);
239 print_register_hook (regno)
241 if (regno == P_REGNUM)
245 int C, Z, N, V, I, D, X, M;
249 read_relative_register_raw_bytes (regno, b);
251 printf_unfiltered ("\t");
261 printf_unfiltered ("N-%d ", N);
262 printf_unfiltered ("V-%d ", V);
263 printf_unfiltered ("M-%d ", M);
264 printf_unfiltered ("X-%d ", X);
265 printf_unfiltered ("D-%d ", D);
266 printf_unfiltered ("I-%d ", I);
267 printf_unfiltered ("Z-%d ", Z);
268 printf_unfiltered ("C-%d ", C);
270 printf_unfiltered ("u> ");
272 printf_unfiltered ("u<= ");
274 printf_unfiltered ("u>= ");
276 printf_unfiltered ("u< ");
278 printf_unfiltered ("!= ");
280 printf_unfiltered ("== ");
282 printf_unfiltered (">= ");
284 printf_unfiltered ("< ");
285 if ((Z | (N ^ V)) == 0)
286 printf_unfiltered ("> ");
287 if ((Z | (N ^ V)) == 1)
288 printf_unfiltered ("<= ");
293 _initialize_w65_tdep ()
295 tm_print_insn = print_insn_w65;