2 * Ported by the State University of New York at Buffalo by the Distributed
3 * Computer Systems Lab, Department of Computer Science, 1991.
13 /* Tahoe instructions are never longer than this. */
16 /* Number of elements in the opcode table. */
17 #define NOPCODES (sizeof votstrs / sizeof votstrs[0])
19 extern char *reg_names
[];
21 static unsigned char *print_insn_arg ();
23 /* Print the Tahoe instruction at address MEMADDR in debugged memory,
24 on STREAM. Returns length of the instruction, in bytes. */
27 print_insn (memaddr
, stream
)
31 unsigned char buffer
[MAXLEN
];
33 register unsigned char *p
;
36 read_memory (memaddr
, buffer
, MAXLEN
);
38 for (i
= 0; i
< NOPCODES
; i
++)
39 if (votstrs
[i
].detail
.code
== buffer
[0]
40 || votstrs
[i
].detail
.code
== *(unsigned short *)buffer
)
43 /* Handle undefined instructions. */
46 fprintf (stream
, "0%o", buffer
[0]);
50 fprintf (stream
, "%s", votstrs
[i
].name
);
52 /* Point at first byte of argument data,
53 and at descriptor for first argument. */
54 p
= buffer
+ 1 + (votstrs
[i
].detail
.code
>= 0x100);
55 d
= votstrs
[i
].detail
.args
;
62 p
= print_insn_arg (d
, p
, memaddr
+ (p
- buffer
), stream
);
65 fprintf (stream
, ",");
69 /*******************************************************************/
70 static unsigned char *
71 print_insn_arg (d
, p
, addr
, stream
)
78 register int regnum
= *p
& 0xf;
84 fprintf (stream
, "0x%x", addr
+ *p
++ + 1);
91 fprintf (stream
, "0x%x", addr
+ temp1
+ 2);
96 switch ((*p
++ >> 4) & 0xf)
101 case 3: /* Liter>al(short immediate byte) mode */
102 if (d
[1] == 'd' || d
[1] == 'f' || d
[1] == 'g' || d
[1] == 'h')
104 *(int *)&floatlitbuf
= 0x4000 + ((p
[-1] & 0x3f) << 4);
105 fprintf (stream
, "$%f", floatlitbuf
);
108 fprintf (stream
, "$%d", p
[-1] & 0x3f);
111 case 4: /* Indexed */
112 p
= (char *) print_insn_arg (d
, p
, addr
+ 1, stream
);
113 fprintf (stream
, "[%s]", reg_names
[regnum
]);
116 case 5: /* Register */
117 fprintf (stream
, reg_names
[regnum
]);
120 case 7: /* Autodecrement */
122 case 6: /* Register deferred */
123 fprintf (stream
, "(%s)", reg_names
[regnum
]);
126 case 9: /* Absolute Address & Autoincrement deferred */
128 if (regnum
== PC_REGNUM
)
135 print_address (temp1
, stream
);
139 case 8: /*Immediate & Autoincrement SP */
140 if (regnum
== 8) /*88 is Immediate Byte Mode*/
141 fprintf (stream
, "$%d", *p
++);
143 else if (regnum
== 9) /*89 is Immediate Word Mode*/
148 fprintf (stream
, "$%d", temp1
);
152 else if (regnum
== PC_REGNUM
) /*8F is Immediate Long Mode*/
161 fprintf (stream
, "$%d", temp1
);
165 else /*8E is Autoincrement SP Mode*/
166 fprintf (stream
, "(%s)+", reg_names
[regnum
]);
169 case 11: /* Register + Byte Displacement Deferred Mode*/
171 case 10: /* Register + Byte Displacement Mode*/
172 if (regnum
== PC_REGNUM
)
173 print_address (addr
+ *p
+ 2, stream
);
175 fprintf (stream
, "%d(%s)", *p
, reg_names
[regnum
]);
179 case 13: /* Register + Word Displacement Deferred Mode*/
181 case 12: /* Register + Word Displacement Mode*/
185 if (regnum
== PC_REGNUM
)
186 print_address (addr
+ temp1
+ 3, stream
);
188 fprintf (stream
, "%d(%s)", temp1
, reg_names
[regnum
]);
192 case 15: /* Register + Long Displacement Deferred Mode*/
194 case 14: /* Register + Long Displacement Mode*/
202 if (regnum
== PC_REGNUM
)
203 print_address (addr
+ temp1
+ 5, stream
);
205 fprintf (stream
, "%d(%s)", temp1
, reg_names
[regnum
]);
209 return (unsigned char *) p
;