1 /* Print Convex instructions for GDB, the GNU debugger.
2 Copyright (C) 1989 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. */
26 /* reg (fmt_field, inst_field) --
27 the {first,second,third} operand of instruction as fmt_field = [ijk]
28 gets the value of the field from the [ijk] position of the instruction */
30 #define reg(a,b) ((char (*)[3])(op[fmt->a]))[inst.f0.b]
32 /* lit (fmt_field) -- field [ijk] is a literal (PSW, VL, eg) */
34 #define lit(i) op[fmt->i]
36 /* aj[j] -- name for A register j */
38 #define aj ((char (*)[3])(op[A]))
58 unsigned char byte
[8];
59 unsigned short half
[4];
65 int mask
; /* opcode mask */
66 int shift
; /* opcode align */
67 struct formstr
*formstr
[3]; /* ST, E0, E1 */
71 unsigned lop
:8, rop
:5; /* opcode */
72 unsigned fmt
:5; /* inst format */
73 unsigned i
:5, j
:5, k
:2; /* operand formats */
76 #include "convx-opcode.h"
78 unsigned char formdecode
[] = {
79 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
80 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
81 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
82 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
83 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
84 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
85 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
86 4,4,4,4,4,4,4,4,5,5,5,5,6,6,7,8,
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,
94 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
97 struct opform opdecode
[] = {
98 0x7e00, 9, format0
, e0_format0
, e1_format0
,
99 0x3f00, 8, format1
, e0_format1
, e1_format1
,
100 0x1fc0, 6, format2
, e0_format2
, e1_format2
,
101 0x0fc0, 6, format3
, e0_format3
, e1_format3
,
102 0x0700, 8, format4
, e0_format4
, e1_format4
,
103 0x03c0, 6, format5
, e0_format5
, e1_format5
,
104 0x01f8, 3, format6
, e0_format6
, e1_format6
,
105 0x00f8, 3, format7
, e0_format7
, e1_format7
,
106 0x0000, 0, formatx
, formatx
, formatx
,
107 0x0f80, 7, formatx
, formatx
, formatx
,
108 0x0f80, 7, formatx
, formatx
, formatx
,
111 /* Print the instruction at address MEMADDR in debugged memory,
112 on STREAM. Returns length of the instruction, in bytes. */
115 print_insn (memaddr
, stream
)
121 register int format
, op1
, pfx
;
124 read_memory (memaddr
, &inst
, sizeof inst
);
126 /* Remove and note prefix, if present */
129 if ((pfx
& 0xfff0) == 0x7ef0)
131 pfx
= ((pfx
>> 3) & 1) + 1;
132 *(long long *) &inst
= *(long long *) &inst
.half
[1];
136 /* Split opcode into format.op1 and look up in appropriate table */
138 format
= formdecode
[inst
.byte
[0]];
139 op1
= (inst
.half
[0] & opdecode
[format
].mask
) >> opdecode
[format
].shift
;
144 else if (inst
.f1
.j
== 0)
145 fmt
= &format1a
[op1
];
146 else if (inst
.f1
.j
== 1)
147 fmt
= &format1b
[op1
];
152 fmt
= &opdecode
[format
].formstr
[pfx
][op1
];
159 fprintf (stream
, "0x%04x", pfx
? pfx
: inst
.half
[0]);
166 fprintf (stream
, "%s%s%s", lop
[fmt
->lop
], rop
[fmt
->rop
],
167 &" "[strlen(lop
[fmt
->lop
]) + strlen(rop
[fmt
->rop
])]);
171 case rrr
: /* three register */
172 fprintf (stream
, "%s,%s,%s", reg(i
,i
), reg(j
,j
), reg(k
,k
));
175 case rr
: /* two register */
176 fprintf (stream
, "%s,%s", reg(i
,j
), reg(j
,k
));
179 case rxr
: /* two register, reversed i and j fields */
180 fprintf (stream
, "%s,%s", reg(i
,k
), reg(j
,j
));
183 case r
: /* one register */
184 fprintf (stream
, "%s", reg(i
,k
));
187 case nops
: /* no operands */
190 case nr
: /* short immediate, one register */
191 fprintf (stream
, "#%d,%s", inst
.f0
.j
, reg(i
,k
));
194 case pcrel
: /* pc relative */
195 print_address (memaddr
+ 2 * inst
.signed_byte
[1], stream
);
198 case lr
: /* literal, one register */
199 fprintf (stream
, "%s,%s", lit(i
), reg(j
,k
));
202 case rxl
: /* one register, literal */
203 fprintf (stream
, "%s,%s", reg(i
,k
), lit(j
));
206 case rlr
: /* register, literal, register */
207 fprintf (stream
, "%s,%s,%s", reg(i
,j
), lit(j
), reg(k
,k
));
210 case rrl
: /* register, register, literal */
211 fprintf (stream
, "%s,%s,%s", reg(i
,j
), reg(j
,k
), lit(k
));
214 case iml
: /* immediate, literal */
217 fprintf (stream
, "#%#x,%s",
218 (inst
.signed_half
[1] << 16) + inst
.half
[2], lit(i
));
223 fprintf (stream
, "#%d,%s", inst
.signed_half
[1], lit(i
));
227 case imr
: /* immediate, register */
230 fprintf (stream
, "#%#x,%s",
231 (inst
.signed_half
[1] << 16) + inst
.half
[2], reg(i
,k
));
236 fprintf (stream
, "#%d,%s", inst
.signed_half
[1], reg(i
,k
));
240 case a1r
: /* memory, register */
241 l
= print_effa (inst
, stream
);
242 fprintf (stream
, ",%s", reg(i
,k
));
245 case a1l
: /* memory, literal */
246 l
= print_effa (inst
, stream
);
247 fprintf (stream
, ",%s", lit(i
));
250 case a2r
: /* register, memory */
251 fprintf (stream
, "%s,", reg(i
,k
));
252 return pfx
+ print_effa (inst
, stream
);
254 case a2l
: /* literal, memory */
255 fprintf (stream
, "%s,", lit(i
));
256 return pfx
+ print_effa (inst
, stream
);
258 case a3
: /* memory */
259 return pfx
+ print_effa (inst
, stream
);
261 case a4
: /* system call */
268 unsigned int m
= (inst
.signed_half
[1] << 16) + inst
.half
[2];
269 fprintf (stream
, "#%d,#%d", m
>> l
, m
& (-1 >> (32-l
)));
274 unsigned int m
= inst
.signed_half
[1];
275 fprintf (stream
, "#%d,#%d", m
>> l
, m
& (-1 >> (32-l
)));
282 /* print effective address @nnn(aj), return instruction length */
284 int print_effa (inst
, stream
)
292 n
= (inst
.signed_half
[1] << 16) + inst
.half
[2];
297 n
= inst
.signed_half
[1];
306 print_address (n
, stream
);
310 fprintf (stream
, (n
& 0xf0000000) == 0x80000000 ? "%#x(%s)" : "%d(%s)",
This page took 0.036545 seconds and 4 git commands to generate.