]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/tahoe-tdep.c
1 /* Print instructions for Tahoe target machines, for GDB.
2 Copyright 1986, 1989, 1991, 1992 Free Software Foundation, Inc.
3 Contributed by the State University of New York at Buffalo, by the
4 Distributed Computer Systems Lab, Department of Computer Science, 1991.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
25 #include "opcode/tahoe.h"
27 /* Tahoe instructions are never longer than this. */
30 /* Number of elements in the opcode table. */
31 #define NOPCODES (sizeof votstrs / sizeof votstrs[0])
33 static unsigned char *print_insn_arg ();
35 /* Advance PC across any function entry prologue instructions
36 to reach some "real" code. */
39 tahoe_skip_prologue (pc
)
42 register int op
= (unsigned char) read_memory_integer (pc
, 1);
44 pc
+= 2; /* skip brb */
46 pc
+= 3; /* skip brw */
48 && ((unsigned char) read_memory_integer (pc
+ 2, 1)) == 0x5e)
49 pc
+= 3; /* skip subl2 */
51 && ((unsigned char) read_memory_integer (pc
+ 1, 1)) == 0xae
52 && ((unsigned char) read_memory_integer (pc
+ 3, 1)) == 0x5e)
53 pc
+= 4; /* skip movab */
55 && ((unsigned char) read_memory_integer (pc
+ 1, 1)) == 0xce
56 && ((unsigned char) read_memory_integer (pc
+ 4, 1)) == 0x5e)
57 pc
+= 5; /* skip movab */
59 && ((unsigned char) read_memory_integer (pc
+ 1, 1)) == 0xee
60 && ((unsigned char) read_memory_integer (pc
+ 6, 1)) == 0x5e)
61 pc
+= 7; /* skip movab */
65 /* Return number of args passed to a frame.
66 Can return -1, meaning no way to tell. */
69 tahoe_frame_num_args (fi
)
70 struct frame_info
*fi
;
72 return (((0xffff & read_memory_integer (((fi
)->frame
- 4), 4)) - 4) >> 2);
75 /* Print the Tahoe instruction at address MEMADDR in debugged memory,
76 on STREAM. Returns length of the instruction, in bytes. */
79 tahoe_print_insn (memaddr
, stream
)
83 unsigned char buffer
[MAXLEN
];
85 register unsigned char *p
;
88 read_memory (memaddr
, buffer
, MAXLEN
);
90 for (i
= 0; i
< NOPCODES
; i
++)
91 if (votstrs
[i
].detail
.code
== buffer
[0]
92 || votstrs
[i
].detail
.code
== *(unsigned short *) buffer
)
95 /* Handle undefined instructions. */
98 fprintf_unfiltered (stream
, "0%o", buffer
[0]);
102 fprintf_unfiltered (stream
, "%s", votstrs
[i
].name
);
104 /* Point at first byte of argument data,
105 and at descriptor for first argument. */
106 p
= buffer
+ 1 + (votstrs
[i
].detail
.code
>= 0x100);
107 d
= votstrs
[i
].detail
.args
;
110 fputc_unfiltered ('\t', stream
);
114 p
= print_insn_arg (d
, p
, memaddr
+ (p
- buffer
), stream
);
117 fprintf_unfiltered (stream
, ",");
121 /*******************************************************************/
122 static unsigned char *
123 print_insn_arg (d
, p
, addr
, stream
)
130 register int regnum
= *p
& 0xf;
136 fprintf_unfiltered (stream
, "0x%x", addr
+ *p
++ + 1);
143 fprintf_unfiltered (stream
, "0x%x", addr
+ temp1
+ 2);
148 switch ((*p
++ >> 4) & 0xf)
153 case 3: /* Literal (short immediate byte) mode */
154 if (d
[1] == 'd' || d
[1] == 'f' || d
[1] == 'g' || d
[1] == 'h')
156 *(int *) &floatlitbuf
= 0x4000 + ((p
[-1] & 0x3f) << 4);
157 fprintf_unfiltered (stream
, "$%f", floatlitbuf
);
160 fprintf_unfiltered (stream
, "$%d", p
[-1] & 0x3f);
163 case 4: /* Indexed */
164 p
= (char *) print_insn_arg (d
, p
, addr
+ 1, stream
);
165 fprintf_unfiltered (stream
, "[%s]", REGISTER_NAME (regnum
));
168 case 5: /* Register */
169 fprintf_unfiltered (stream
, REGISTER_NAME (regnum
));
172 case 7: /* Autodecrement */
173 fputc_unfiltered ('-', stream
);
174 case 6: /* Register deferred */
175 fprintf_unfiltered (stream
, "(%s)", REGISTER_NAME (regnum
));
178 case 9: /* Absolute Address & Autoincrement deferred */
179 fputc_unfiltered ('*', stream
);
180 if (regnum
== PC_REGNUM
)
186 fputc_unfiltered ('$', stream
);
187 print_address (temp1
, stream
);
191 case 8: /*Immediate & Autoincrement SP */
192 if (regnum
== 8) /*88 is Immediate Byte Mode */
193 fprintf_unfiltered (stream
, "$%d", *p
++);
195 else if (regnum
== 9) /*89 is Immediate Word Mode */
200 fprintf_unfiltered (stream
, "$%d", temp1
);
204 else if (regnum
== PC_REGNUM
) /*8F is Immediate Long Mode */
213 fprintf_unfiltered (stream
, "$%d", temp1
);
217 else /*8E is Autoincrement SP Mode */
218 fprintf_unfiltered (stream
, "(%s)+", REGISTER_NAME (regnum
));
221 case 11: /* Register + Byte Displacement Deferred Mode */
222 fputc_unfiltered ('*', stream
);
223 case 10: /* Register + Byte Displacement Mode */
224 if (regnum
== PC_REGNUM
)
225 print_address (addr
+ *p
+ 2, stream
);
227 fprintf_unfiltered (stream
, "%d(%s)", *p
, REGISTER_NAME (regnum
));
231 case 13: /* Register + Word Displacement Deferred Mode */
232 fputc_unfiltered ('*', stream
);
233 case 12: /* Register + Word Displacement Mode */
237 if (regnum
== PC_REGNUM
)
238 print_address (addr
+ temp1
+ 3, stream
);
240 fprintf_unfiltered (stream
, "%d(%s)", temp1
, REGISTER_NAME (regnum
));
244 case 15: /* Register + Long Displacement Deferred Mode */
245 fputc_unfiltered ('*', stream
);
246 case 14: /* Register + Long Displacement Mode */
254 if (regnum
== PC_REGNUM
)
255 print_address (addr
+ temp1
+ 5, stream
);
257 fprintf_unfiltered (stream
, "%d(%s)", temp1
, REGISTER_NAME (regnum
));
261 return (unsigned char *) p
;