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"
28 /* Vax instructions are never longer than this. */
31 /* Number of elements in the opcode table. */
32 #define NOPCODES (sizeof votstrs / sizeof votstrs[0])
34 static unsigned char *print_insn_arg ();
36 /* Advance PC across any function entry prologue instructions
37 to reach some "real" code. */
40 vax_skip_prologue (CORE_ADDR 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 vax_frame_num_args (struct frame_info
*fi
)
71 return (0xff & read_memory_integer (FRAME_ARGS_ADDRESS (fi
), 1));
76 /* Print the vax instruction at address MEMADDR in debugged memory,
77 from disassembler info INFO.
78 Returns length of the instruction, in bytes. */
81 vax_print_insn (CORE_ADDR memaddr
, disassemble_info
*info
)
83 unsigned char buffer
[MAXLEN
];
85 register unsigned char *p
;
88 int status
= (*info
->read_memory_func
) (memaddr
, buffer
, MAXLEN
, info
);
91 (*info
->memory_error_func
) (status
, memaddr
, info
);
95 for (i
= 0; i
< NOPCODES
; i
++)
96 if (votstrs
[i
].detail
.code
== buffer
[0]
97 || votstrs
[i
].detail
.code
== *(unsigned short *) buffer
)
100 /* Handle undefined instructions. */
103 (*info
->fprintf_func
) (info
->stream
, "0%o", buffer
[0]);
107 (*info
->fprintf_func
) (info
->stream
, "%s", votstrs
[i
].name
);
109 /* Point at first byte of argument data,
110 and at descriptor for first argument. */
111 p
= buffer
+ 1 + (votstrs
[i
].detail
.code
>= 0x100);
112 d
= votstrs
[i
].detail
.args
;
115 (*info
->fprintf_func
) (info
->stream
, " ");
119 p
= print_insn_arg (d
, p
, memaddr
+ (p
- buffer
), info
);
122 (*info
->fprintf_func
) (info
->stream
, ",");
127 static unsigned char *
128 print_insn_arg (char *d
, register char *p
, CORE_ADDR addr
,
129 disassemble_info
*info
)
131 register int regnum
= *p
& 0xf;
137 (*info
->fprintf_func
) (info
->stream
, "0x%x", addr
+ *p
++ + 1);
140 (*info
->fprintf_func
) (info
->stream
, "0x%x", addr
+ *(short *) p
+ 2);
145 switch ((*p
++ >> 4) & 0xf)
150 case 3: /* Literal mode */
151 if (d
[1] == 'd' || d
[1] == 'f' || d
[1] == 'g' || d
[1] == 'h')
153 *(int *) &floatlitbuf
= 0x4000 + ((p
[-1] & 0x3f) << 4);
154 (*info
->fprintf_func
) (info
->stream
, "$%f", floatlitbuf
);
157 (*info
->fprintf_func
) (info
->stream
, "$%d", p
[-1] & 0x3f);
160 case 4: /* Indexed */
161 p
= (char *) print_insn_arg (d
, p
, addr
+ 1, info
);
162 (*info
->fprintf_func
) (info
->stream
, "[%s]", REGISTER_NAME (regnum
));
165 case 5: /* Register */
166 (*info
->fprintf_func
) (info
->stream
, REGISTER_NAME (regnum
));
169 case 7: /* Autodecrement */
170 (*info
->fprintf_func
) (info
->stream
, "-");
171 case 6: /* Register deferred */
172 (*info
->fprintf_func
) (info
->stream
, "(%s)", REGISTER_NAME (regnum
));
175 case 9: /* Autoincrement deferred */
176 (*info
->fprintf_func
) (info
->stream
, "@");
177 if (regnum
== PC_REGNUM
)
179 (*info
->fprintf_func
) (info
->stream
, "#");
180 info
->target
= *(long *) p
;
181 (*info
->print_address_func
) (info
->target
, info
);
185 case 8: /* Autoincrement */
186 if (regnum
== PC_REGNUM
)
188 (*info
->fprintf_func
) (info
->stream
, "#");
192 (*info
->fprintf_func
) (info
->stream
, "%d", *p
++);
196 (*info
->fprintf_func
) (info
->stream
, "%d", *(short *) p
);
201 (*info
->fprintf_func
) (info
->stream
, "%d", *(long *) p
);
206 (*info
->fprintf_func
) (info
->stream
, "0x%x%08x",
207 ((long *) p
)[1], ((long *) p
)[0]);
212 (*info
->fprintf_func
) (info
->stream
, "0x%x%08x%08x%08x",
213 ((long *) p
)[3], ((long *) p
)[2],
214 ((long *) p
)[1], ((long *) p
)[0]);
219 if (INVALID_FLOAT (p
, 4))
220 (*info
->fprintf_func
) (info
->stream
,
221 "<<invalid float 0x%x>>",
224 (*info
->fprintf_func
) (info
->stream
, "%f", *(float *) p
);
229 if (INVALID_FLOAT (p
, 8))
230 (*info
->fprintf_func
) (info
->stream
,
231 "<<invalid float 0x%x%08x>>",
232 ((long *) p
)[1], ((long *) p
)[0]);
234 (*info
->fprintf_func
) (info
->stream
, "%f", *(double *) p
);
239 (*info
->fprintf_func
) (info
->stream
, "g-float");
244 (*info
->fprintf_func
) (info
->stream
, "h-float");
251 (*info
->fprintf_func
) (info
->stream
, "(%s)+", REGISTER_NAME (regnum
));
254 case 11: /* Byte displacement deferred */
255 (*info
->fprintf_func
) (info
->stream
, "@");
256 case 10: /* Byte displacement */
257 if (regnum
== PC_REGNUM
)
259 info
->target
= addr
+ *p
+ 2;
260 (*info
->print_address_func
) (info
->target
, info
);
263 (*info
->fprintf_func
) (info
->stream
, "%d(%s)", *p
, REGISTER_NAME (regnum
));
267 case 13: /* Word displacement deferred */
268 (*info
->fprintf_func
) (info
->stream
, "@");
269 case 12: /* Word displacement */
270 if (regnum
== PC_REGNUM
)
272 info
->target
= addr
+ *(short *) p
+ 3;
273 (*info
->print_address_func
) (info
->target
, info
);
276 (*info
->fprintf_func
) (info
->stream
, "%d(%s)",
277 *(short *) p
, REGISTER_NAME (regnum
));
281 case 15: /* Long displacement deferred */
282 (*info
->fprintf_func
) (info
->stream
, "@");
283 case 14: /* Long displacement */
284 if (regnum
== PC_REGNUM
)
286 info
->target
= addr
+ *(short *) p
+ 5;
287 (*info
->print_address_func
) (info
->target
, info
);
290 (*info
->fprintf_func
) (info
->stream
, "%d(%s)",
291 *(long *) p
, REGISTER_NAME (regnum
));
295 return (unsigned char *) p
;
299 _initialize_vax_tdep (void)
301 tm_print_insn
= vax_print_insn
;
This page took 0.051506 seconds and 4 git commands to generate.