1 /* Print instructions for Tahoe target machines, for GDB.
2 Copyright 1986, 1989, 1991, 1992 Free Software Foundation, Inc.
3 Contributed by the State University of New York at Buffalo, by the
4 Distributed Computer Systems Lab, Department of Computer Science, 1991.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24 #include "opcode/tahoe.h"
26 /* Tahoe instructions are never longer than this. */
29 /* Number of elements in the opcode table. */
30 #define NOPCODES (sizeof votstrs / sizeof votstrs[0])
32 static unsigned char *print_insn_arg ();
34 /* Print the Tahoe instruction at address MEMADDR in debugged memory,
35 on STREAM. Returns length of the instruction, in bytes. */
38 tahoe_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_unfiltered (stream
, "0%o", buffer
[0]);
61 fprintf_unfiltered (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
;
69 fputc_unfiltered ('\t', stream
);
73 p
= print_insn_arg (d
, p
, memaddr
+ (p
- buffer
), stream
);
76 fprintf_unfiltered (stream
, ",");
80 /*******************************************************************/
81 static unsigned char *
82 print_insn_arg (d
, p
, addr
, stream
)
89 register int regnum
= *p
& 0xf;
95 fprintf_unfiltered (stream
, "0x%x", addr
+ *p
++ + 1);
102 fprintf_unfiltered (stream
, "0x%x", addr
+ temp1
+ 2);
107 switch ((*p
++ >> 4) & 0xf)
112 case 3: /* Literal (short immediate byte) mode */
113 if (d
[1] == 'd' || d
[1] == 'f' || d
[1] == 'g' || d
[1] == 'h')
115 *(int *)&floatlitbuf
= 0x4000 + ((p
[-1] & 0x3f) << 4);
116 fprintf_unfiltered (stream
, "$%f", floatlitbuf
);
119 fprintf_unfiltered (stream
, "$%d", p
[-1] & 0x3f);
122 case 4: /* Indexed */
123 p
= (char *) print_insn_arg (d
, p
, addr
+ 1, stream
);
124 fprintf_unfiltered (stream
, "[%s]", reg_names
[regnum
]);
127 case 5: /* Register */
128 fprintf_unfiltered (stream
, reg_names
[regnum
]);
131 case 7: /* Autodecrement */
132 fputc_unfiltered ('-', stream
);
133 case 6: /* Register deferred */
134 fprintf_unfiltered (stream
, "(%s)", reg_names
[regnum
]);
137 case 9: /* Absolute Address & Autoincrement deferred */
138 fputc_unfiltered ('*', stream
);
139 if (regnum
== PC_REGNUM
)
145 fputc_unfiltered ('$', stream
);
146 print_address (temp1
, stream
);
150 case 8: /*Immediate & Autoincrement SP */
151 if (regnum
== 8) /*88 is Immediate Byte Mode*/
152 fprintf_unfiltered (stream
, "$%d", *p
++);
154 else if (regnum
== 9) /*89 is Immediate Word Mode*/
159 fprintf_unfiltered (stream
, "$%d", temp1
);
163 else if (regnum
== PC_REGNUM
) /*8F is Immediate Long Mode*/
172 fprintf_unfiltered (stream
, "$%d", temp1
);
176 else /*8E is Autoincrement SP Mode*/
177 fprintf_unfiltered (stream
, "(%s)+", reg_names
[regnum
]);
180 case 11: /* Register + Byte Displacement Deferred Mode*/
181 fputc_unfiltered ('*', stream
);
182 case 10: /* Register + Byte Displacement Mode*/
183 if (regnum
== PC_REGNUM
)
184 print_address (addr
+ *p
+ 2, stream
);
186 fprintf_unfiltered (stream
, "%d(%s)", *p
, reg_names
[regnum
]);
190 case 13: /* Register + Word Displacement Deferred Mode*/
191 fputc_unfiltered ('*', stream
);
192 case 12: /* Register + Word Displacement Mode*/
196 if (regnum
== PC_REGNUM
)
197 print_address (addr
+ temp1
+ 3, stream
);
199 fprintf_unfiltered (stream
, "%d(%s)", temp1
, reg_names
[regnum
]);
203 case 15: /* Register + Long Displacement Deferred Mode*/
204 fputc_unfiltered ('*', stream
);
205 case 14: /* Register + Long Displacement Mode*/
213 if (regnum
== PC_REGNUM
)
214 print_address (addr
+ temp1
+ 5, stream
);
216 fprintf_unfiltered (stream
, "%d(%s)", temp1
, reg_names
[regnum
]);
220 return (unsigned char *) p
;
This page took 0.038875 seconds and 4 git commands to generate.