1 /* Print Convex instructions for GDB, the GNU debugger.
2 Copyright 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. */
25 /* reg (fmt_field, inst_field) --
26 the {first,second,third} operand of instruction as fmt_field = [ijk]
27 gets the value of the field from the [ijk] position of the instruction */
29 #define reg(a,b) ((char (*)[3])(op[fmt->a]))[inst.f0.b]
31 /* lit (fmt_field) -- field [ijk] is a literal (PSW, VL, eg) */
33 #define lit(i) op[fmt->i]
35 /* aj[j] -- name for A register j */
37 #define aj ((char (*)[3])(op[A]))
57 unsigned char byte
[8];
58 unsigned short half
[4];
64 int mask
; /* opcode mask */
65 int shift
; /* opcode align */
66 struct formstr
*formstr
[3]; /* ST, E0, E1 */
70 unsigned lop
:8, rop
:5; /* opcode */
71 unsigned fmt
:5; /* inst format */
72 unsigned i
:5, j
:5, k
:2; /* operand formats */
75 #include "convx-opcode.h"
77 unsigned char formdecode
[] = {
78 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
79 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
80 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
81 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
82 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
83 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
84 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
85 4,4,4,4,4,4,4,4,5,5,5,5,6,6,7,8,
86 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
87 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
88 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
89 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
90 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
91 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
92 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
93 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
96 struct opform opdecode
[] = {
97 0x7e00, 9, format0
, e0_format0
, e1_format0
,
98 0x3f00, 8, format1
, e0_format1
, e1_format1
,
99 0x1fc0, 6, format2
, e0_format2
, e1_format2
,
100 0x0fc0, 6, format3
, e0_format3
, e1_format3
,
101 0x0700, 8, format4
, e0_format4
, e1_format4
,
102 0x03c0, 6, format5
, e0_format5
, e1_format5
,
103 0x01f8, 3, format6
, e0_format6
, e1_format6
,
104 0x00f8, 3, format7
, e0_format7
, e1_format7
,
105 0x0000, 0, formatx
, formatx
, formatx
,
106 0x0f80, 7, formatx
, formatx
, formatx
,
107 0x0f80, 7, formatx
, formatx
, formatx
,
110 /* Print the instruction at address MEMADDR in debugged memory,
111 on STREAM. Returns length of the instruction, in bytes. */
114 print_insn (memaddr
, stream
)
120 register int format
, op1
, pfx
;
123 read_memory (memaddr
, &inst
, sizeof inst
);
125 /* Remove and note prefix, if present */
128 if ((pfx
& 0xfff0) == 0x7ef0)
130 pfx
= ((pfx
>> 3) & 1) + 1;
131 *(long long *) &inst
= *(long long *) &inst
.half
[1];
135 /* Split opcode into format.op1 and look up in appropriate table */
137 format
= formdecode
[inst
.byte
[0]];
138 op1
= (inst
.half
[0] & opdecode
[format
].mask
) >> opdecode
[format
].shift
;
143 else if (inst
.f1
.j
== 0)
144 fmt
= &format1a
[op1
];
145 else if (inst
.f1
.j
== 1)
146 fmt
= &format1b
[op1
];
151 fmt
= &opdecode
[format
].formstr
[pfx
][op1
];
158 fprintf (stream
, "0x%04x", pfx
? pfx
: inst
.half
[0]);
165 fprintf (stream
, "%s%s%s", lop
[fmt
->lop
], rop
[fmt
->rop
],
166 &" "[strlen(lop
[fmt
->lop
]) + strlen(rop
[fmt
->rop
])]);
170 case rrr
: /* three register */
171 fprintf (stream
, "%s,%s,%s", reg(i
,i
), reg(j
,j
), reg(k
,k
));
174 case rr
: /* two register */
175 fprintf (stream
, "%s,%s", reg(i
,j
), reg(j
,k
));
178 case rxr
: /* two register, reversed i and j fields */
179 fprintf (stream
, "%s,%s", reg(i
,k
), reg(j
,j
));
182 case r
: /* one register */
183 fprintf (stream
, "%s", reg(i
,k
));
186 case nops
: /* no operands */
189 case nr
: /* short immediate, one register */
190 fprintf (stream
, "#%d,%s", inst
.f0
.j
, reg(i
,k
));
193 case pcrel
: /* pc relative */
194 print_address (memaddr
+ 2 * inst
.signed_byte
[1], stream
);
197 case lr
: /* literal, one register */
198 fprintf (stream
, "%s,%s", lit(i
), reg(j
,k
));
201 case rxl
: /* one register, literal */
202 fprintf (stream
, "%s,%s", reg(i
,k
), lit(j
));
205 case rlr
: /* register, literal, register */
206 fprintf (stream
, "%s,%s,%s", reg(i
,j
), lit(j
), reg(k
,k
));
209 case rrl
: /* register, register, literal */
210 fprintf (stream
, "%s,%s,%s", reg(i
,j
), reg(j
,k
), lit(k
));
213 case iml
: /* immediate, literal */
216 fprintf (stream
, "#%#x,%s",
217 (inst
.signed_half
[1] << 16) + inst
.half
[2], lit(i
));
222 fprintf (stream
, "#%d,%s", inst
.signed_half
[1], lit(i
));
226 case imr
: /* immediate, register */
229 fprintf (stream
, "#%#x,%s",
230 (inst
.signed_half
[1] << 16) + inst
.half
[2], reg(i
,k
));
235 fprintf (stream
, "#%d,%s", inst
.signed_half
[1], reg(i
,k
));
239 case a1r
: /* memory, register */
240 l
= print_effa (inst
, stream
);
241 fprintf (stream
, ",%s", reg(i
,k
));
244 case a1l
: /* memory, literal */
245 l
= print_effa (inst
, stream
);
246 fprintf (stream
, ",%s", lit(i
));
249 case a2r
: /* register, memory */
250 fprintf (stream
, "%s,", reg(i
,k
));
251 return pfx
+ print_effa (inst
, stream
);
253 case a2l
: /* literal, memory */
254 fprintf (stream
, "%s,", lit(i
));
255 return pfx
+ print_effa (inst
, stream
);
257 case a3
: /* memory */
258 return pfx
+ print_effa (inst
, stream
);
260 case a4
: /* system call */
267 unsigned int m
= (inst
.signed_half
[1] << 16) + inst
.half
[2];
268 fprintf (stream
, "#%d,#%d", m
>> l
, m
& (-1 >> (32-l
)));
273 unsigned int m
= inst
.signed_half
[1];
274 fprintf (stream
, "#%d,#%d", m
>> l
, m
& (-1 >> (32-l
)));
281 /* print effective address @nnn(aj), return instruction length */
283 int print_effa (inst
, stream
)
291 n
= (inst
.signed_half
[1] << 16) + inst
.half
[2];
296 n
= inst
.signed_half
[1];
305 print_address (n
, stream
);
309 fprintf (stream
, (n
& 0xf0000000) == 0x80000000 ? "%#x(%s)" : "%d(%s)",
This page took 0.042415 seconds and 4 git commands to generate.