#include "symtab.h"
#include "gdbcmd.h"
#include "gdbtypes.h"
-
+#include "dis-asm.h"
/* Return the saved PC from this frame.
If the frame has a memory copy of SRP_REGNUM, use that. If not,
int regno;
for (regno = 0; regno < NUM_REGS; regno++)
- regs->regs[regno] = 0;
+ regs->regs[regno] = 0;
while (IS_PUSHW (w) || IS_PUSHL (w))
- {
- /* work out which register is being pushed to where */
- if (IS_PUSHL (w))
- {
- regs->regs[w & 0xf] = offset;
- regs->regs[(w & 0xf) + 1] = offset + 2;
- offset += 4;
- }
- else
{
- regs->regs[w & 0xf] = offset;
- offset += 2;
+ /* work out which register is being pushed to where */
+ if (IS_PUSHL (w))
+ {
+ regs->regs[w & 0xf] = offset;
+ regs->regs[(w & 0xf) + 1] = offset + 2;
+ offset += 4;
+ }
+ else
+ {
+ regs->regs[w & 0xf] = offset;
+ offset += 2;
+ }
+ pc += 2;
+ w = read_memory_short (pc);
}
- pc += 2;
- w = read_memory_short (pc);
- }
if (IS_MOVE_FP (w))
- {
- /* We know the fp */
+ {
+ /* We know the fp */
- }
+ }
else if (IS_SUB_SP (w))
- {
- /* Subtracting a value from the sp, so were in a function
+ {
+ /* Subtracting a value from the sp, so were in a function
which needs stack space for locals, but has no fp. We fake up
the values as if we had an fp */
- regs->regs[FP_REGNUM] = sp;
- }
+ regs->regs[FP_REGNUM] = sp;
+ }
else
- {
- /* This one didn't have an fp, we'll fake it up */
- regs->regs[SP_REGNUM] = sp;
- }
+ {
+ /* This one didn't have an fp, we'll fake it up */
+ regs->regs[SP_REGNUM] = sp;
+ }
/* stack pointer contains address of next frame */
/* regs->regs[fp_regnum()] = fp;*/
regs->regs[SP_REGNUM] = sp;
return pc;
}
-CORE_ADDR
+CORE_ADDR
z8k_skip_prologue (start_pc)
CORE_ADDR start_pc;
{
return examine_frame (start_pc, &dummy, 0);
}
-CORE_ADDR
+CORE_ADDR
addr_bits_remove (x)
CORE_ADDR x;
{
ways in the stack frame. sp is even more special:
the address we return for it IS the sp for the next frame. */
-void
+void
get_frame_saved_regs (frame_info, frame_saved_regs)
struct frame_info *frame_info;
struct frame_saved_regs *frame_saved_regs;
CORE_ADDR pc;
int w;
- bzero (frame_saved_regs, sizeof (*frame_saved_regs));
+ memset (frame_saved_regs, '\0', sizeof (*frame_saved_regs));
pc = get_pc_function_start (frame_info->pc);
/* wander down the instruction stream */
}
-void
+void
z8k_push_dummy_frame ()
{
abort ();
}
-int
+int
print_insn (memaddr, stream)
CORE_ADDR memaddr;
FILE *stream;
{
- char temp[20];
+ disassemble_info info;
+
+ GDB_INIT_DISASSEMBLE_INFO(info, stream);
- read_memory (memaddr, temp, 20);
if (BIG)
{
- return print_insn_z8001 (memaddr, temp, stream);
+ return print_insn_z8001 ((bfd_vma) memaddr, &info);
}
else
{
- return print_insn_z8002 (memaddr, temp, stream);
+ return print_insn_z8002 ((bfd_vma) memaddr, &info);
}
}
CORE_ADDR lim;
short *pword1;
{
+ char buf[2];
if (addr < lim + 8)
{
- read_memory (addr, pword1, sizeof (*pword1));
- SWAP_TARGET_AND_HOST (pword1, sizeof (short));
+ read_memory (addr, buf, 2);
+ *pword1 = extract_signed_integer (buf, 2);
return addr + 2;
}
-
return 0;
-
}
/* Put here the code to store, into a struct frame_saved_regs,
}
+int
+saved_pc_after_call ()
+{
+ return addr_bits_remove
+ (read_memory_integer (read_register (SP_REGNUM), PTR_SIZE));
+}
+
+
+extract_return_value(type, regbuf, valbuf)
+struct type *type;
+char *regbuf;
+char *valbuf;
+{
+ int b;
+ int len = TYPE_LENGTH(type);
+
+ for (b = 0; b < len; b += 2) {
+ int todo = len - b;
+ if (todo > 2)
+ todo = 2;
+ memcpy(valbuf + b, regbuf + b, todo);
+ }
+}
+
void
-addr_bits_set ()
+write_return_value(type, valbuf)
+struct type *type;
+char *valbuf;
{
- abort ();
+ int reg;
+ int len;
+ for (len = 0; len < TYPE_LENGTH(type); len += 2)
+ {
+ write_register_bytes(REGISTER_BYTE(len /2 + 2), valbuf + len, 2);
+ }
}
-int
-saved_pc_after_call ()
+void
+store_struct_return(addr, sp)
+CORE_ADDR addr;
+CORE_ADDR sp;
{
- return addr_bits_remove (read_memory_integer (read_register (SP_REGNUM), PTR_SIZE));
+ write_register(2, addr);
}
+
void
print_register_hook (regno)
int regno;
{
-
if ((regno & 1) == 0 && regno < 16)
{
unsigned short l[2];
{
unsigned short l[4];
- read_relative_register_raw_bytes (regno, l + 0);
- read_relative_register_raw_bytes (regno + 1, l + 1);
- read_relative_register_raw_bytes (regno + 2, l + 2);
- read_relative_register_raw_bytes (regno + 3, l + 3);
+ read_relative_register_raw_bytes (regno, (char *) (l + 0));
+ read_relative_register_raw_bytes (regno + 1, (char *) (l + 1));
+ read_relative_register_raw_bytes (regno + 2, (char *) (l + 2));
+ read_relative_register_raw_bytes (regno + 3, (char *) (l + 3));
printf ("\t");
printf ("%04x%04x%04x%04x", l[0], l[1], l[2], l[3]);
to[3] = from[3];
}
-void
+void
z8k_pop_frame ()
{
}
struct cmd_list_element *setmemorylist;
-void
+void
z8k_set_pointer_size (newsize)
int newsize;
{
char *args;
int from_tty;
{
- z8k_set_pointer_size (16);
+ z8k_set_pointer_size (32);
}
static void