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 /* Print the vax instruction at address MEMADDR in debugged memory,
33 from disassembler info INFO.
34 Returns length of the instruction, in bytes. */
37 vax_print_insn (memaddr
, info
)
39 disassemble_info
*info
;
41 unsigned char buffer
[MAXLEN
];
43 register unsigned char *p
;
46 int status
= (*info
->read_memory_func
) (memaddr
, buffer
, MAXLEN
, info
);
49 (*info
->memory_error_func
) (status
, memaddr
, info
);
53 for (i
= 0; i
< NOPCODES
; i
++)
54 if (votstrs
[i
].detail
.code
== buffer
[0]
55 || votstrs
[i
].detail
.code
== *(unsigned short *)buffer
)
58 /* Handle undefined instructions. */
61 (*info
->fprintf_func
) (info
->stream
, "0%o", buffer
[0]);
65 (*info
->fprintf_func
) (info
->stream
, "%s", votstrs
[i
].name
);
67 /* Point at first byte of argument data,
68 and at descriptor for first argument. */
69 p
= buffer
+ 1 + (votstrs
[i
].detail
.code
>= 0x100);
70 d
= votstrs
[i
].detail
.args
;
73 (*info
->fprintf_func
) (info
->stream
, " ");
77 p
= print_insn_arg (d
, p
, memaddr
+ (p
- buffer
), info
);
80 (*info
->fprintf_func
) (info
->stream
, ",");
85 static unsigned char *
86 print_insn_arg (d
, p
, addr
, info
)
90 disassemble_info
*info
;
92 register int regnum
= *p
& 0xf;
98 (*info
->fprintf_func
) (info
->stream
, "0x%x", addr
+ *p
++ + 1);
101 (*info
->fprintf_func
) (info
->stream
, "0x%x", addr
+ *(short *)p
+ 2);
106 switch ((*p
++ >> 4) & 0xf)
111 case 3: /* Literal mode */
112 if (d
[1] == 'd' || d
[1] == 'f' || d
[1] == 'g' || d
[1] == 'h')
114 *(int *)&floatlitbuf
= 0x4000 + ((p
[-1] & 0x3f) << 4);
115 (*info
->fprintf_func
) (info
->stream
, "$%f", floatlitbuf
);
118 (*info
->fprintf_func
) (info
->stream
, "$%d", p
[-1] & 0x3f);
121 case 4: /* Indexed */
122 p
= (char *) print_insn_arg (d
, p
, addr
+ 1, info
);
123 (*info
->fprintf_func
) (info
->stream
, "[%s]", reg_names
[regnum
]);
126 case 5: /* Register */
127 (*info
->fprintf_func
) (info
->stream
, reg_names
[regnum
]);
130 case 7: /* Autodecrement */
131 (*info
->fprintf_func
) (info
->stream
, "-");
132 case 6: /* Register deferred */
133 (*info
->fprintf_func
) (info
->stream
, "(%s)", reg_names
[regnum
]);
136 case 9: /* Autoincrement deferred */
137 (*info
->fprintf_func
) (info
->stream
, "@");
138 if (regnum
== PC_REGNUM
)
140 (*info
->fprintf_func
) (info
->stream
, "#");
141 info
->target
= *(long *)p
;
142 (*info
->print_address_func
) (info
->target
, info
);
146 case 8: /* Autoincrement */
147 if (regnum
== PC_REGNUM
)
149 (*info
->fprintf_func
) (info
->stream
, "#");
153 (*info
->fprintf_func
) (info
->stream
, "%d", *p
++);
157 (*info
->fprintf_func
) (info
->stream
, "%d", *(short *)p
);
162 (*info
->fprintf_func
) (info
->stream
, "%d", *(long *)p
);
167 (*info
->fprintf_func
) (info
->stream
, "0x%x%08x",
168 ((long *)p
)[1], ((long *)p
)[0]);
173 (*info
->fprintf_func
) (info
->stream
, "0x%x%08x%08x%08x",
174 ((long *)p
)[3], ((long *)p
)[2],
175 ((long *)p
)[1], ((long *)p
)[0]);
180 if (INVALID_FLOAT (p
, 4))
181 (*info
->fprintf_func
) (info
->stream
,
182 "<<invalid float 0x%x>>",
185 (*info
->fprintf_func
) (info
->stream
, "%f", *(float *) p
);
190 if (INVALID_FLOAT (p
, 8))
191 (*info
->fprintf_func
) (info
->stream
,
192 "<<invalid float 0x%x%08x>>",
193 ((long *)p
)[1], ((long *)p
)[0]);
195 (*info
->fprintf_func
) (info
->stream
, "%f", *(double *) p
);
200 (*info
->fprintf_func
) (info
->stream
, "g-float");
205 (*info
->fprintf_func
) (info
->stream
, "h-float");
212 (*info
->fprintf_func
) (info
->stream
, "(%s)+", reg_names
[regnum
]);
215 case 11: /* Byte displacement deferred */
216 (*info
->fprintf_func
) (info
->stream
, "@");
217 case 10: /* Byte displacement */
218 if (regnum
== PC_REGNUM
)
220 info
->target
= addr
+ *p
+ 2;
221 (*info
->print_address_func
) (info
->target
, info
);
224 (*info
->fprintf_func
) (info
->stream
, "%d(%s)", *p
, reg_names
[regnum
]);
228 case 13: /* Word displacement deferred */
229 (*info
->fprintf_func
) (info
->stream
, "@");
230 case 12: /* Word displacement */
231 if (regnum
== PC_REGNUM
)
233 info
->target
= addr
+ *(short *)p
+ 3;
234 (*info
->print_address_func
) (info
->target
, info
);
237 (*info
->fprintf_func
) (info
->stream
, "%d(%s)",
238 *(short *)p
, reg_names
[regnum
]);
242 case 15: /* Long displacement deferred */
243 (*info
->fprintf_func
) (info
->stream
, "@");
244 case 14: /* Long displacement */
245 if (regnum
== PC_REGNUM
)
247 info
->target
= addr
+ *(short *)p
+ 5;
248 (*info
->print_address_func
) (info
->target
, info
);
251 (*info
->fprintf_func
) (info
->stream
, "%d(%s)",
252 *(long *)p
, reg_names
[regnum
]);
256 return (unsigned char *) p
;
260 _initialize_vax_tdep ()
262 tm_print_insn
= vax_print_insn
;
This page took 0.033834 seconds and 4 git commands to generate.