1 /* Print VAX instructions for GDB, the GNU debugger.
2 Copyright 1986, 1989, 1991, 1992 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., 675 Mass Ave, Cambridge, MA 02139, 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 on STREAM. Returns length of the instruction, in bytes. */
36 print_insn (memaddr
, stream
)
40 unsigned char buffer
[MAXLEN
];
42 register unsigned char *p
;
45 read_memory (memaddr
, buffer
, MAXLEN
);
47 for (i
= 0; i
< NOPCODES
; i
++)
48 if (votstrs
[i
].detail
.code
== buffer
[0]
49 || votstrs
[i
].detail
.code
== *(unsigned short *)buffer
)
52 /* Handle undefined instructions. */
55 fprintf (stream
, "0%o", buffer
[0]);
59 fprintf (stream
, "%s", votstrs
[i
].name
);
61 /* Point at first byte of argument data,
62 and at descriptor for first argument. */
63 p
= buffer
+ 1 + (votstrs
[i
].detail
.code
>= 0x100);
64 d
= votstrs
[i
].detail
.args
;
71 p
= print_insn_arg (d
, p
, memaddr
+ (p
- buffer
), stream
);
74 fprintf (stream
, ",");
79 static unsigned char *
80 print_insn_arg (d
, p
, addr
, stream
)
86 register int regnum
= *p
& 0xf;
92 fprintf (stream
, "0x%x", addr
+ *p
++ + 1);
95 fprintf (stream
, "0x%x", addr
+ *(short *)p
+ 2);
100 switch ((*p
++ >> 4) & 0xf)
105 case 3: /* Literal mode */
106 if (d
[1] == 'd' || d
[1] == 'f' || d
[1] == 'g' || d
[1] == 'h')
108 *(int *)&floatlitbuf
= 0x4000 + ((p
[-1] & 0x3f) << 4);
109 fprintf (stream
, "$%f", floatlitbuf
);
112 fprintf (stream
, "$%d", p
[-1] & 0x3f);
115 case 4: /* Indexed */
116 p
= (char *) print_insn_arg (d
, p
, addr
+ 1, stream
);
117 fprintf (stream
, "[%s]", reg_names
[regnum
]);
120 case 5: /* Register */
121 fprintf (stream
, reg_names
[regnum
]);
124 case 7: /* Autodecrement */
126 case 6: /* Register deferred */
127 fprintf (stream
, "(%s)", reg_names
[regnum
]);
130 case 9: /* Autoincrement deferred */
132 if (regnum
== PC_REGNUM
)
135 print_address (*(long *)p
, stream
);
139 case 8: /* Autoincrement */
140 if (regnum
== PC_REGNUM
)
146 fprintf (stream
, "%d", *p
++);
150 fprintf (stream
, "%d", *(short *)p
);
155 fprintf (stream
, "%d", *(long *)p
);
160 fprintf (stream
, "0x%x%08x", ((long *)p
)[1], ((long *)p
)[0]);
165 fprintf (stream
, "0x%x%08x%08x%08x",
166 ((long *)p
)[3], ((long *)p
)[2],
167 ((long *)p
)[1], ((long *)p
)[0]);
172 if (INVALID_FLOAT (p
, 4))
173 fprintf (stream
, "<<invalid float 0x%x>>", *(int *) p
);
175 fprintf (stream
, "%f", *(float *) p
);
180 if (INVALID_FLOAT (p
, 8))
181 fprintf (stream
, "<<invalid float 0x%x%08x>>",
182 ((long *)p
)[1], ((long *)p
)[0]);
184 fprintf (stream
, "%f", *(double *) p
);
189 fprintf (stream
, "g-float");
194 fprintf (stream
, "h-float");
201 fprintf (stream
, "(%s)+", reg_names
[regnum
]);
204 case 11: /* Byte displacement deferred */
206 case 10: /* Byte displacement */
207 if (regnum
== PC_REGNUM
)
208 print_address (addr
+ *p
+ 2, stream
);
210 fprintf (stream
, "%d(%s)", *p
, reg_names
[regnum
]);
214 case 13: /* Word displacement deferred */
216 case 12: /* Word displacement */
217 if (regnum
== PC_REGNUM
)
218 print_address (addr
+ *(short *)p
+ 3, stream
);
220 fprintf (stream
, "%d(%s)", *(short *)p
, reg_names
[regnum
]);
224 case 15: /* Long displacement deferred */
226 case 14: /* Long displacement */
227 if (regnum
== PC_REGNUM
)
228 print_address (addr
+ *(long *)p
+ 5, stream
);
230 fprintf (stream
, "%d(%s)", *(long *)p
, reg_names
[regnum
]);
234 return (unsigned char *) p
;
This page took 0.034487 seconds and 4 git commands to generate.