/* Disassembler for the Pyramid Technology 90x
Copyright (C) 1988,1989 Free Software Foundation, Inc.
This file is part of GDB, the GNU disassembler.
GDB is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
GDB is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GDB; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* A couple of functions used for debugging frame-handling on
Pyramids. (The Pyramid-dependent handling of register values for
windowed registers is known to be buggy.)
When debugging, these functions supplant the normal definitions of some
of the macros in m-pyramid.h The quantity of information produced
when these functions are used makes the gdb unusable as a
debugger for user programs. */
extern unsigned pyr_saved_pc(), pyr_frame_chain();
CORE_ADDR
pyr_frame_chain(frame
)
int foo
=frame
- CONTROL_STACK_FRAME_SIZE
;
/* printf ("...following chain from %x: got %x\n", frame, foo);*/
CORE_ADDR
pyr_saved_pc(frame
)
foo
= read_memory_integer (((CORE_ADDR
)(frame
))+60, 4);
printf ("..reading pc from frame 0x%0x+%d regs: got %0x\n",
/* Pyramid instructions are never longer than this many bytes. */
/* Number of elements in the opcode table. */
/*const*/ static int nopcodes
= (sizeof (pyr_opcodes
) / sizeof( pyr_opcodes
[0]));
#define NOPCODES (nopcodes)
extern char *reg_names
[];
/* Let's be byte-independent so we can use this as a cross-assembler.
(will this ever be useful?
(p += 4, (((((p[-4] << 8) + p[-3]) << 8) + p[-2]) << 8) + p[-1])
/* Print one instruction at address MEMADDR in debugged memory,
on STREAM. Returns length of the instruction, in bytes. */
print_insn (memaddr
, stream
)
unsigned char buffer
[MAXLEN
];
register int i
, nargs
, insn_size
=4;
register unsigned char *p
;
register int insn_opcode
, operand_mode
;
register int index_multiplier
, index_reg_regno
, op_1_regno
, op_2_regno
;
long insn
; /* first word of the insn, not broken down. */
pyr_insn_format insn_decode
; /* the same, broken out into op{code,erands} */
read_memory (memaddr
, buffer
, MAXLEN
);
insn_decode
= *((pyr_insn_format
*) buffer
);
insn
= * ((int *) buffer
);
insn_opcode
= insn_decode
.operator;
operand_mode
= insn_decode
.mode
;
index_multiplier
= insn_decode
.index_scale
;
index_reg_regno
= insn_decode
.index_reg
;
op_1_regno
= insn_decode
.operand_1
;
op_2_regno
= insn_decode
.operand_2
;
if (*((int *)buffer
) == 0x0) {
/* "halt" looks just like an invalid "jump" to the insn decoder,
so is dealt with as a special case */
fprintf (stream
, "halt");
for (i
= 0; i
< NOPCODES
; i
++)
if (pyr_opcodes
[i
].datum
.code
== insn_opcode
)
/* FIXME: Handle unrecognised instructions better. */
fprintf (stream
, "???\t#%08x\t(op=%x mode =%x)",
insn
, insn_decode
.operator, insn_decode
.mode
);
/* Print the mnemonic for the instruction. Pyramid insn operands
are so regular that we can deal with almost all of them
Unconditional branches are an exception: they are encoded as
conditional branches (branch if false condition, I think)
with no condition specified. The average user will not be
aware of this. To maintain their illusion that an
unconditional branch insn exists, we will have to FIXME to
treat the insn mnemnonic of all branch instructions here as a
special case: check the operands of branch insn and print an
fprintf (stream
, "%s\t", pyr_opcodes
[i
].name
);
/* Print the operands of the insn (as specified in
Branch operands of branches are a special case: they are a word
offset, not a byte offset. */
if (insn_decode
.operator == 0x01 || insn_decode
.operator == 0x02) {
register int bit_codes
=(insn
>> 16)&0xf;
register int displacement
= (insn
& 0x0000ffff) << 2;
static char cc_bit_names
[] = "cvzn"; /* z,n,c,v: strange order? */
/* Is bfc and no bits specified an unconditional branch?*/
fputc (cc_bit_names
[i
], stream
);
fprintf (stream
, "%s,%s",
fprintf (stream
, " 0x%0x,%s",
read_memory (memaddr
+4, buffer
, MAXLEN
);
extra_1
= * ((int *) buffer
);
fprintf (stream
, " $0x%0x,%s",
fprintf (stream
, " (%s),%s",
read_memory (memaddr
+4, buffer
, MAXLEN
);
extra_1
= * ((int *) buffer
);
fprintf (stream
, " 0x%0x(%s),%s",
/* S1 destination mode */
((index_reg_regno
) ? "%s,(%s)[%s*%1d]" : "%s,(%s)"),
reg_names
[index_reg_regno
],
((index_reg_regno
) ? " $%#0x,(%s)[%s*%1d]"
reg_names
[index_reg_regno
],
read_memory (memaddr
+4, buffer
, MAXLEN
);
extra_1
= * ((int *) buffer
);
((index_reg_regno
) ? " $%#0x,(%s)[%s*%1d]"
reg_names
[index_reg_regno
],
((index_reg_regno
) ? " (%s),(%s)[%s*%1d]" : " (%s),(%s)"),
reg_names
[index_reg_regno
],
read_memory (memaddr
+4, buffer
, MAXLEN
);
extra_1
= * ((int *) buffer
);
? "%#0x(%s),(%s)[%s*%1d]"
reg_names
[index_reg_regno
],
/* S2 destination mode */
read_memory (memaddr
+4, buffer
, MAXLEN
);
extra_1
= * ((int *) buffer
);
((index_reg_regno
) ? "%s,%#0x(%s)[%s*%1d]" : "%s,%#0x(%s)"),
reg_names
[index_reg_regno
],
read_memory (memaddr
+4, buffer
, MAXLEN
);
extra_1
= * ((int *) buffer
);
" $%#0x,%#0x(%s)[%s*%1d]" : " $%#0x,%#0x(%s)"),
reg_names
[index_reg_regno
],
read_memory (memaddr
+4, buffer
, MAXLEN
);
extra_1
= * ((int *) buffer
);
read_memory (memaddr
+8, buffer
, MAXLEN
);
extra_2
= * ((int *) buffer
);
" $%#0x,%#0x(%s)[%s*%1d]" : " $%#0x,%#0x(%s)"),
reg_names
[index_reg_regno
],
read_memory (memaddr
+4, buffer
, MAXLEN
);
extra_1
= * ((int *) buffer
);
? " (%s),%#0x(%s)[%s*%1d]"
reg_names
[index_reg_regno
],
read_memory (memaddr
+4, buffer
, MAXLEN
);
extra_1
= * ((int *) buffer
);
read_memory (memaddr
+8, buffer
, MAXLEN
);
extra_2
= * ((int *) buffer
);
((index_reg_regno
) ? "%#0x(%s),%#0x(%s)[%s*%1d]"
reg_names
[index_reg_regno
],
((index_reg_regno
) ? "%s,%s [%s*%1d]" : "%s,%s"),
reg_names
[index_reg_regno
],
"\t\t# unknown mode in %08x",