/* Target-machine dependent code for Hitachi H8/500, for GDB.
- Copyright (C) 1993 Free Software Foundation, Inc.
+ Copyright 1993, 1994, 1995 Free Software Foundation, Inc.
This file is part of GDB.
;
#define UNSIGNED_SHORT(X) ((X) & 0xffff)
+int code_size = 2;
+int data_size = 2;
/* Shape of an H8/500 frame :
return start_pc;
}
-int
-print_insn (memaddr, stream)
- CORE_ADDR memaddr;
- GDB_FILE *stream;
-{
- disassemble_info info;
- GDB_INIT_DISASSEMBLE_INFO (info, stream);
- return print_insn_h8500 (memaddr, &info);
-}
-
/* Given a GDB frame, determine the address of the calling function's frame.
This will be used to create a new GDB frame struct, and then
INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC will be called for the new frame.
For us, the frame address is its stack pointer value, so we look up
the function prologue to determine the caller's sp value, and return it. */
-FRAME_ADDR
+CORE_ADDR
h8500_frame_chain (thisframe)
- FRAME thisframe;
+ struct frame_info *thisframe;
{
if (!inside_entry_file (thisframe->pc))
return (read_memory_integer (FRAME_FP (thisframe), PTR_SIZE));
CORE_ADDR
frame_saved_pc (frame)
- FRAME frame;
+ struct frame_info *frame;
{
- return read_memory_integer ((frame)->frame + 2, PTR_SIZE);
+ return read_memory_integer (FRAME_FP (frame) + 2, PTR_SIZE);
}
CORE_ADDR
{
unsigned regnum;
struct frame_saved_regs fsr;
- struct frame_info *fi;
-
- FRAME frame = get_current_frame ();
+ struct frame_info *frame = get_current_frame ();
- fi = get_frame_info (frame);
- get_frame_saved_regs (fi, &fsr);
+ get_frame_saved_regs (frame, &fsr);
for (regnum = 0; regnum < 8; regnum++)
{
if (fsr.regs[regnum])
- {
write_register (regnum, read_memory_short (fsr.regs[regnum]));
- }
flush_cached_frames ();
- set_current_frame (create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
-
}
}
{
int x;
int a = read_register (SP_REGNUM);
- x = read_memory_integer (a, PTR_SIZE);
+ x = read_memory_integer (a, code_size);
+ if (code_size == 2)
+ {
+ /* Stick current code segement onto top */
+ x &= 0xffff;
+ x |= read_register (SEG_C_REGNUM) << 16;
+ }
+ x &= 0xffffff;
return x;
}
struct cmd_list_element *setmemorylist;
-static void
-segmented_command (args, from_tty)
- char *args;
- int from_tty;
-{
- h8500_set_pointer_size (32);
-}
+#define C(name,a,b,c) name () { h8500_set_pointer_size(a); code_size = b; data_size = c; }
-static void
-unsegmented_command (args, from_tty)
- char *args;
- int from_tty;
-{
- h8500_set_pointer_size (16);
-}
+C(big_command, 32,4,4);
+C(medium_command, 32, 4,2);
+C(compact_command, 32,2,4);
+C(small_command, 16,2,2);
static void
set_memory (args, from_tty)
return 0;
}
-value
+value_ptr
h8500_value_of_trapped_internalvar (var)
struct internalvar *var;
{
h8500_set_trapped_internalvar (var, newval, bitpos, bitsize, offset)
struct internalvar *var;
int offset, bitpos, bitsize;
- value newval;
+ value_ptr newval;
{
char *page_regnum, *regnum;
char expression[100];
add_prefix_cmd ("memory", no_class, set_memory,
"set the memory model", &setmemorylist, "set memory ", 0,
&setlist);
- add_cmd ("segmented", class_support, segmented_command,
- "Set segmented memory model.", &setmemorylist);
- add_cmd ("unsegmented", class_support, unsegmented_command,
- "Set unsegmented memory model.", &setmemorylist);
+
+ add_cmd ("small", class_support, small_command,
+ "Set small memory model. (16 bit code, 16 bit data)", &setmemorylist);
+
+ add_cmd ("big", class_support, big_command,
+ "Set big memory model. (32 bit code, 32 bit data)", &setmemorylist);
+
+ add_cmd ("medium", class_support, medium_command,
+ "Set medium memory model. (32 bit code, 16 bit data)", &setmemorylist);
+
+ add_cmd ("compact", class_support, compact_command,
+ "Set compact memory model. (16 bit code, 32 bit data)", &setmemorylist);
}
CORE_ADDR
-target_read_sp ()
+h8500_read_sp ()
{
return read_register (PR7_REGNUM);
}
void
-target_write_sp (v)
+h8500_write_sp (v)
CORE_ADDR v;
{
write_register (PR7_REGNUM, v);
}
CORE_ADDR
-target_read_pc ()
+h8500_read_pc (pid)
+ int pid;
{
return read_register (PC_REGNUM);
}
void
-target_write_pc (v)
+h8500_write_pc (v, pid)
CORE_ADDR v;
+ int pid;
{
write_register (PC_REGNUM, v);
}
CORE_ADDR
-target_read_fp ()
+h8500_read_fp ()
{
return read_register (PR6_REGNUM);
}
void
-target_write_fp (v)
+h8500_write_fp (v)
CORE_ADDR v;
{
write_register (PR6_REGNUM, v);
}
+void
+_initialize_h8500_tdep ()
+{
+ tm_print_insn = gdb_print_insn_sh;
+}