1 /* Print VAX instructions for GDB, the GNU debugger.
2 Copyright 1986, 1989, 1991 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 extern char *reg_names
[];
32 static unsigned char *print_insn_arg ();
34 /* Print the vax instruction at address MEMADDR in debugged memory,
35 on STREAM. Returns length of the instruction, in bytes. */
38 print_insn (memaddr
, stream
)
42 unsigned char buffer
[MAXLEN
];
44 register unsigned char *p
;
47 read_memory (memaddr
, buffer
, MAXLEN
);
49 for (i
= 0; i
< NOPCODES
; i
++)
50 if (votstrs
[i
].detail
.code
== buffer
[0]
51 || votstrs
[i
].detail
.code
== *(unsigned short *)buffer
)
54 /* Handle undefined instructions. */
57 fprintf (stream
, "0%o", buffer
[0]);
61 fprintf (stream
, "%s", votstrs
[i
].name
);
63 /* Point at first byte of argument data,
64 and at descriptor for first argument. */
65 p
= buffer
+ 1 + (votstrs
[i
].detail
.code
>= 0x100);
66 d
= votstrs
[i
].detail
.args
;
73 p
= print_insn_arg (d
, p
, memaddr
+ (p
- buffer
), stream
);
76 fprintf (stream
, ",");
81 static unsigned char *
82 print_insn_arg (d
, p
, addr
, stream
)
88 register int regnum
= *p
& 0xf;
94 fprintf (stream
, "0x%x", addr
+ *p
++ + 1);
97 fprintf (stream
, "0x%x", addr
+ *(short *)p
+ 2);
102 switch ((*p
++ >> 4) & 0xf)
107 case 3: /* Literal mode */
108 if (d
[1] == 'd' || d
[1] == 'f' || d
[1] == 'g' || d
[1] == 'h')
110 *(int *)&floatlitbuf
= 0x4000 + ((p
[-1] & 0x3f) << 4);
111 fprintf (stream
, "$%f", floatlitbuf
);
114 fprintf (stream
, "$%d", p
[-1] & 0x3f);
117 case 4: /* Indexed */
118 p
= (char *) print_insn_arg (d
, p
, addr
+ 1, stream
);
119 fprintf (stream
, "[%s]", reg_names
[regnum
]);
122 case 5: /* Register */
123 fprintf (stream
, reg_names
[regnum
]);
126 case 7: /* Autodecrement */
128 case 6: /* Register deferred */
129 fprintf (stream
, "(%s)", reg_names
[regnum
]);
132 case 9: /* Autoincrement deferred */
134 if (regnum
== PC_REGNUM
)
137 print_address (*(long *)p
, stream
);
141 case 8: /* Autoincrement */
142 if (regnum
== PC_REGNUM
)
148 fprintf (stream
, "%d", *p
++);
152 fprintf (stream
, "%d", *(short *)p
);
157 fprintf (stream
, "%d", *(long *)p
);
162 fprintf (stream
, "0x%x%08x", ((long *)p
)[1], ((long *)p
)[0]);
167 fprintf (stream
, "0x%x%08x%08x%08x",
168 ((long *)p
)[3], ((long *)p
)[2],
169 ((long *)p
)[1], ((long *)p
)[0]);
174 if (INVALID_FLOAT (p
, 4))
175 fprintf (stream
, "<<invalid float 0x%x>>", *(int *) p
);
177 fprintf (stream
, "%f", *(float *) p
);
182 if (INVALID_FLOAT (p
, 8))
183 fprintf (stream
, "<<invalid float 0x%x%08x>>",
184 ((long *)p
)[1], ((long *)p
)[0]);
186 fprintf (stream
, "%f", *(double *) p
);
191 fprintf (stream
, "g-float");
196 fprintf (stream
, "h-float");
203 fprintf (stream
, "(%s)+", reg_names
[regnum
]);
206 case 11: /* Byte displacement deferred */
208 case 10: /* Byte displacement */
209 if (regnum
== PC_REGNUM
)
210 print_address (addr
+ *p
+ 2, stream
);
212 fprintf (stream
, "%d(%s)", *p
, reg_names
[regnum
]);
216 case 13: /* Word displacement deferred */
218 case 12: /* Word displacement */
219 if (regnum
== PC_REGNUM
)
220 print_address (addr
+ *(short *)p
+ 3, stream
);
222 fprintf (stream
, "%d(%s)", *(short *)p
, reg_names
[regnum
]);
226 case 15: /* Long displacement deferred */
228 case 14: /* Long displacement */
229 if (regnum
== PC_REGNUM
)
230 print_address (addr
+ *(long *)p
+ 5, stream
);
232 fprintf (stream
, "%d(%s)", *(long *)p
, reg_names
[regnum
]);
236 return (unsigned char *) p
;
This page took 0.033533 seconds and 4 git commands to generate.