c344b4334c85ca04146e809261acba75264db25f
1 /* Print VAX instructions for GDB, the GNU debugger.
2 Copyright 1986, 1989, 1991, 1992, 1996 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. */
23 #include "opcode/vax.h"
25 /* Vax instructions are never longer than this. */
28 /* Number of elements in the opcode table. */
29 #define NOPCODES (sizeof votstrs / sizeof votstrs[0])
31 static unsigned char *print_insn_arg ();
33 /* Advance PC across any function entry prologue instructions
34 to reach some "real" code. */
37 vax_skip_prologue (pc
)
40 register int op
= (unsigned char) read_memory_integer (pc
, 1);
42 pc
+= 2; /* skip brb */
44 pc
+= 3; /* skip brw */
46 && ((unsigned char) read_memory_integer (pc
+ 2, 1)) == 0x5E)
47 pc
+= 3; /* skip subl2 */
49 && ((unsigned char) read_memory_integer (pc
+ 1, 1)) == 0xAE
50 && ((unsigned char) read_memory_integer (pc
+ 3, 1)) == 0x5E)
51 pc
+= 4; /* skip movab */
53 && ((unsigned char) read_memory_integer (pc
+ 1, 1)) == 0xCE
54 && ((unsigned char) read_memory_integer (pc
+ 4, 1)) == 0x5E)
55 pc
+= 5; /* skip movab */
57 && ((unsigned char) read_memory_integer (pc
+ 1, 1)) == 0xEE
58 && ((unsigned char) read_memory_integer (pc
+ 6, 1)) == 0x5E)
59 pc
+= 7; /* skip movab */
63 /* Return number of args passed to a frame.
64 Can return -1, meaning no way to tell. */
67 vax_frame_num_args (fi
)
68 struct frame_info
*fi
;
70 return (0xff & read_memory_integer (FRAME_ARGS_ADDRESS (fi
), 1));
75 /* Print the vax instruction at address MEMADDR in debugged memory,
76 from disassembler info INFO.
77 Returns length of the instruction, in bytes. */
80 vax_print_insn (memaddr
, info
)
82 disassemble_info
*info
;
84 unsigned char buffer
[MAXLEN
];
86 register unsigned char *p
;
89 int status
= (*info
->read_memory_func
) (memaddr
, buffer
, MAXLEN
, info
);
92 (*info
->memory_error_func
) (status
, memaddr
, info
);
96 for (i
= 0; i
< NOPCODES
; i
++)
97 if (votstrs
[i
].detail
.code
== buffer
[0]
98 || votstrs
[i
].detail
.code
== *(unsigned short *) buffer
)
101 /* Handle undefined instructions. */
104 (*info
->fprintf_func
) (info
->stream
, "0%o", buffer
[0]);
108 (*info
->fprintf_func
) (info
->stream
, "%s", votstrs
[i
].name
);
110 /* Point at first byte of argument data,
111 and at descriptor for first argument. */
112 p
= buffer
+ 1 + (votstrs
[i
].detail
.code
>= 0x100);
113 d
= votstrs
[i
].detail
.args
;
116 (*info
->fprintf_func
) (info
->stream
, " ");
120 p
= print_insn_arg (d
, p
, memaddr
+ (p
- buffer
), info
);
123 (*info
->fprintf_func
) (info
->stream
, ",");
128 static unsigned char *
129 print_insn_arg (d
, p
, addr
, info
)
133 disassemble_info
*info
;
135 register int regnum
= *p
& 0xf;
141 (*info
->fprintf_func
) (info
->stream
, "0x%x", addr
+ *p
++ + 1);
144 (*info
->fprintf_func
) (info
->stream
, "0x%x", addr
+ *(short *) p
+ 2);
149 switch ((*p
++ >> 4) & 0xf)
154 case 3: /* Literal mode */
155 if (d
[1] == 'd' || d
[1] == 'f' || d
[1] == 'g' || d
[1] == 'h')
157 *(int *) &floatlitbuf
= 0x4000 + ((p
[-1] & 0x3f) << 4);
158 (*info
->fprintf_func
) (info
->stream
, "$%f", floatlitbuf
);
161 (*info
->fprintf_func
) (info
->stream
, "$%d", p
[-1] & 0x3f);
164 case 4: /* Indexed */
165 p
= (char *) print_insn_arg (d
, p
, addr
+ 1, info
);
166 (*info
->fprintf_func
) (info
->stream
, "[%s]", REGISTER_NAME (regnum
));
169 case 5: /* Register */
170 (*info
->fprintf_func
) (info
->stream
, REGISTER_NAME (regnum
));
173 case 7: /* Autodecrement */
174 (*info
->fprintf_func
) (info
->stream
, "-");
175 case 6: /* Register deferred */
176 (*info
->fprintf_func
) (info
->stream
, "(%s)", REGISTER_NAME (regnum
));
179 case 9: /* Autoincrement deferred */
180 (*info
->fprintf_func
) (info
->stream
, "@");
181 if (regnum
== PC_REGNUM
)
183 (*info
->fprintf_func
) (info
->stream
, "#");
184 info
->target
= *(long *) p
;
185 (*info
->print_address_func
) (info
->target
, info
);
189 case 8: /* Autoincrement */
190 if (regnum
== PC_REGNUM
)
192 (*info
->fprintf_func
) (info
->stream
, "#");
196 (*info
->fprintf_func
) (info
->stream
, "%d", *p
++);
200 (*info
->fprintf_func
) (info
->stream
, "%d", *(short *) p
);
205 (*info
->fprintf_func
) (info
->stream
, "%d", *(long *) p
);
210 (*info
->fprintf_func
) (info
->stream
, "0x%x%08x",
211 ((long *) p
)[1], ((long *) p
)[0]);
216 (*info
->fprintf_func
) (info
->stream
, "0x%x%08x%08x%08x",
217 ((long *) p
)[3], ((long *) p
)[2],
218 ((long *) p
)[1], ((long *) p
)[0]);
223 if (INVALID_FLOAT (p
, 4))
224 (*info
->fprintf_func
) (info
->stream
,
225 "<<invalid float 0x%x>>",
228 (*info
->fprintf_func
) (info
->stream
, "%f", *(float *) p
);
233 if (INVALID_FLOAT (p
, 8))
234 (*info
->fprintf_func
) (info
->stream
,
235 "<<invalid float 0x%x%08x>>",
236 ((long *) p
)[1], ((long *) p
)[0]);
238 (*info
->fprintf_func
) (info
->stream
, "%f", *(double *) p
);
243 (*info
->fprintf_func
) (info
->stream
, "g-float");
248 (*info
->fprintf_func
) (info
->stream
, "h-float");
255 (*info
->fprintf_func
) (info
->stream
, "(%s)+", REGISTER_NAME (regnum
));
258 case 11: /* Byte displacement deferred */
259 (*info
->fprintf_func
) (info
->stream
, "@");
260 case 10: /* Byte displacement */
261 if (regnum
== PC_REGNUM
)
263 info
->target
= addr
+ *p
+ 2;
264 (*info
->print_address_func
) (info
->target
, info
);
267 (*info
->fprintf_func
) (info
->stream
, "%d(%s)", *p
, REGISTER_NAME (regnum
));
271 case 13: /* Word displacement deferred */
272 (*info
->fprintf_func
) (info
->stream
, "@");
273 case 12: /* Word displacement */
274 if (regnum
== PC_REGNUM
)
276 info
->target
= addr
+ *(short *) p
+ 3;
277 (*info
->print_address_func
) (info
->target
, info
);
280 (*info
->fprintf_func
) (info
->stream
, "%d(%s)",
281 *(short *) p
, REGISTER_NAME (regnum
));
285 case 15: /* Long displacement deferred */
286 (*info
->fprintf_func
) (info
->stream
, "@");
287 case 14: /* Long displacement */
288 if (regnum
== PC_REGNUM
)
290 info
->target
= addr
+ *(short *) p
+ 5;
291 (*info
->print_address_func
) (info
->target
, info
);
294 (*info
->fprintf_func
) (info
->stream
, "%d(%s)",
295 *(long *) p
, REGISTER_NAME (regnum
));
299 return (unsigned char *) p
;
303 _initialize_vax_tdep ()
305 tm_print_insn
= vax_print_insn
;
This page took 0.036159 seconds and 4 git commands to generate.