7e0426035f181c8a7ba4b63ab3ff4a185f72c8c3
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, Boston, MA 02111-1307, USA. */
22 #include "opcode/vax.h"
24 /* Vax instructions are never longer than this. */
27 /* Number of elements in the opcode table. */
28 #define NOPCODES (sizeof votstrs / sizeof votstrs[0])
30 static unsigned char *print_insn_arg ();
32 /* Advance PC across any function entry prologue instructions
33 to reach some "real" code. */
36 vax_skip_prologue (pc
)
39 register int op
= (unsigned char) read_memory_integer (pc
, 1);
41 pc
+= 2; /* skip brb */
43 pc
+= 3; /* skip brw */
45 && ((unsigned char) read_memory_integer (pc
+2, 1)) == 0x5E)
46 pc
+= 3; /* skip subl2 */
48 && ((unsigned char) read_memory_integer (pc
+1, 1)) == 0xAE
49 && ((unsigned char) read_memory_integer(pc
+3, 1)) == 0x5E)
50 pc
+= 4; /* skip movab */
52 && ((unsigned char) read_memory_integer (pc
+1, 1)) == 0xCE
53 && ((unsigned char) read_memory_integer(pc
+4, 1)) == 0x5E)
54 pc
+= 5; /* skip movab */
56 && ((unsigned char) read_memory_integer (pc
+1, 1)) == 0xEE
57 && ((unsigned char) read_memory_integer(pc
+6, 1)) == 0x5E)
58 pc
+= 7; /* skip movab */
62 /* Print the vax instruction at address MEMADDR in debugged memory,
63 from disassembler info INFO.
64 Returns length of the instruction, in bytes. */
67 vax_print_insn (memaddr
, info
)
69 disassemble_info
*info
;
71 unsigned char buffer
[MAXLEN
];
73 register unsigned char *p
;
76 int status
= (*info
->read_memory_func
) (memaddr
, buffer
, MAXLEN
, info
);
79 (*info
->memory_error_func
) (status
, memaddr
, info
);
83 for (i
= 0; i
< NOPCODES
; i
++)
84 if (votstrs
[i
].detail
.code
== buffer
[0]
85 || votstrs
[i
].detail
.code
== *(unsigned short *)buffer
)
88 /* Handle undefined instructions. */
91 (*info
->fprintf_func
) (info
->stream
, "0%o", buffer
[0]);
95 (*info
->fprintf_func
) (info
->stream
, "%s", votstrs
[i
].name
);
97 /* Point at first byte of argument data,
98 and at descriptor for first argument. */
99 p
= buffer
+ 1 + (votstrs
[i
].detail
.code
>= 0x100);
100 d
= votstrs
[i
].detail
.args
;
103 (*info
->fprintf_func
) (info
->stream
, " ");
107 p
= print_insn_arg (d
, p
, memaddr
+ (p
- buffer
), info
);
110 (*info
->fprintf_func
) (info
->stream
, ",");
115 static unsigned char *
116 print_insn_arg (d
, p
, addr
, info
)
120 disassemble_info
*info
;
122 register int regnum
= *p
& 0xf;
128 (*info
->fprintf_func
) (info
->stream
, "0x%x", addr
+ *p
++ + 1);
131 (*info
->fprintf_func
) (info
->stream
, "0x%x", addr
+ *(short *)p
+ 2);
136 switch ((*p
++ >> 4) & 0xf)
141 case 3: /* Literal mode */
142 if (d
[1] == 'd' || d
[1] == 'f' || d
[1] == 'g' || d
[1] == 'h')
144 *(int *)&floatlitbuf
= 0x4000 + ((p
[-1] & 0x3f) << 4);
145 (*info
->fprintf_func
) (info
->stream
, "$%f", floatlitbuf
);
148 (*info
->fprintf_func
) (info
->stream
, "$%d", p
[-1] & 0x3f);
151 case 4: /* Indexed */
152 p
= (char *) print_insn_arg (d
, p
, addr
+ 1, info
);
153 (*info
->fprintf_func
) (info
->stream
, "[%s]", REGISTER_NAME (regnum
));
156 case 5: /* Register */
157 (*info
->fprintf_func
) (info
->stream
, REGISTER_NAME (regnum
));
160 case 7: /* Autodecrement */
161 (*info
->fprintf_func
) (info
->stream
, "-");
162 case 6: /* Register deferred */
163 (*info
->fprintf_func
) (info
->stream
, "(%s)", REGISTER_NAME (regnum
));
166 case 9: /* Autoincrement deferred */
167 (*info
->fprintf_func
) (info
->stream
, "@");
168 if (regnum
== PC_REGNUM
)
170 (*info
->fprintf_func
) (info
->stream
, "#");
171 info
->target
= *(long *)p
;
172 (*info
->print_address_func
) (info
->target
, info
);
176 case 8: /* Autoincrement */
177 if (regnum
== PC_REGNUM
)
179 (*info
->fprintf_func
) (info
->stream
, "#");
183 (*info
->fprintf_func
) (info
->stream
, "%d", *p
++);
187 (*info
->fprintf_func
) (info
->stream
, "%d", *(short *)p
);
192 (*info
->fprintf_func
) (info
->stream
, "%d", *(long *)p
);
197 (*info
->fprintf_func
) (info
->stream
, "0x%x%08x",
198 ((long *)p
)[1], ((long *)p
)[0]);
203 (*info
->fprintf_func
) (info
->stream
, "0x%x%08x%08x%08x",
204 ((long *)p
)[3], ((long *)p
)[2],
205 ((long *)p
)[1], ((long *)p
)[0]);
210 if (INVALID_FLOAT (p
, 4))
211 (*info
->fprintf_func
) (info
->stream
,
212 "<<invalid float 0x%x>>",
215 (*info
->fprintf_func
) (info
->stream
, "%f", *(float *) p
);
220 if (INVALID_FLOAT (p
, 8))
221 (*info
->fprintf_func
) (info
->stream
,
222 "<<invalid float 0x%x%08x>>",
223 ((long *)p
)[1], ((long *)p
)[0]);
225 (*info
->fprintf_func
) (info
->stream
, "%f", *(double *) p
);
230 (*info
->fprintf_func
) (info
->stream
, "g-float");
235 (*info
->fprintf_func
) (info
->stream
, "h-float");
242 (*info
->fprintf_func
) (info
->stream
, "(%s)+", REGISTER_NAME (regnum
));
245 case 11: /* Byte displacement deferred */
246 (*info
->fprintf_func
) (info
->stream
, "@");
247 case 10: /* Byte displacement */
248 if (regnum
== PC_REGNUM
)
250 info
->target
= addr
+ *p
+ 2;
251 (*info
->print_address_func
) (info
->target
, info
);
254 (*info
->fprintf_func
) (info
->stream
, "%d(%s)", *p
, REGISTER_NAME (regnum
));
258 case 13: /* Word displacement deferred */
259 (*info
->fprintf_func
) (info
->stream
, "@");
260 case 12: /* Word displacement */
261 if (regnum
== PC_REGNUM
)
263 info
->target
= addr
+ *(short *)p
+ 3;
264 (*info
->print_address_func
) (info
->target
, info
);
267 (*info
->fprintf_func
) (info
->stream
, "%d(%s)",
268 *(short *)p
, REGISTER_NAME (regnum
));
272 case 15: /* Long displacement deferred */
273 (*info
->fprintf_func
) (info
->stream
, "@");
274 case 14: /* Long displacement */
275 if (regnum
== PC_REGNUM
)
277 info
->target
= addr
+ *(short *)p
+ 5;
278 (*info
->print_address_func
) (info
->target
, info
);
281 (*info
->fprintf_func
) (info
->stream
, "%d(%s)",
282 *(long *)p
, REGISTER_NAME (regnum
));
286 return (unsigned char *) p
;
290 _initialize_vax_tdep ()
292 tm_print_insn
= vax_print_insn
;
This page took 0.034748 seconds and 4 git commands to generate.