--- src/gdb/h8300-tdep.c.orig	Mon Sep 15 10:43:31 2003
+++ src/gdb/h8300-tdep.c	Mon Sep 15 13:32:30 2003
@@ -49,7 +49,7 @@ enum
   h8300h_reg_size = 4,
   h8300_max_reg_size = 4,
 };
-#define BINWORD (h8300hmode ? h8300h_reg_size : h8300_reg_size)
+#define BINWORD (h8300hmode && 0 == NormalMode ? h8300h_reg_size : h8300_reg_size)
 
 enum gdb_regnum
 {
@@ -350,7 +350,7 @@ h8300_examine_prologue (register CORE_AD
     }
 
   /* If the PC isn't valid, quit now.  */
-  if (ip == 0 || ip & (h8300hmode ? ~0xffffff : ~0xffff))
+  if (ip == 0 || ip & (h8300hmode && 0 == NormalMode ? ~0xffffff : ~0xffff))
     return 0;
 
   next_ip = h8300_next_prologue_insn (ip, limit, &insn_word);
@@ -1214,8 +1214,26 @@ h8300_gdbarch_init (struct gdbarch_info 
       set_gdbarch_store_return_value (gdbarch, h8300_store_return_value);
       set_gdbarch_print_insn (gdbarch, print_insn_h8300);
       break;
-    case bfd_mach_h8300h:
     case bfd_mach_h8300hn:
+      NormalMode = 1;
+      h8300sxmode = 0;
+      h8300smode = 0;
+      h8300hmode = 1;
+      set_gdbarch_num_regs (gdbarch, 13);
+      set_gdbarch_num_pseudo_regs (gdbarch, 1);
+      set_gdbarch_ecoff_reg_to_regnum (gdbarch, h8300_dbg_reg_to_regnum);
+      set_gdbarch_dwarf_reg_to_regnum (gdbarch, h8300_dbg_reg_to_regnum);
+      set_gdbarch_dwarf2_reg_to_regnum (gdbarch, h8300_dbg_reg_to_regnum);
+      set_gdbarch_stab_reg_to_regnum (gdbarch, h8300_dbg_reg_to_regnum);
+      set_gdbarch_register_name (gdbarch, h8300_register_name);
+      set_gdbarch_ptr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
+      set_gdbarch_addr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
+      set_gdbarch_extract_return_value (gdbarch, h8300h_extract_return_value);
+      set_gdbarch_store_return_value (gdbarch, h8300h_store_return_value);
+      set_gdbarch_print_insn (gdbarch, print_insn_h8300h);
+      break;
+    case bfd_mach_h8300h:
+      NormalMode = 0;
       h8300sxmode = 0;
       h8300smode = 0;
       h8300hmode = 1;
@@ -1232,8 +1250,26 @@ h8300_gdbarch_init (struct gdbarch_info 
       set_gdbarch_store_return_value (gdbarch, h8300h_store_return_value);
       set_gdbarch_print_insn (gdbarch, print_insn_h8300h);
       break;
-    case bfd_mach_h8300s:
     case bfd_mach_h8300sn:
+      NormalMode = 1;
+      h8300sxmode = 0;
+      h8300smode = 1;
+      h8300hmode = 1;
+      set_gdbarch_num_regs (gdbarch, 16);
+      set_gdbarch_num_pseudo_regs (gdbarch, 2);
+      set_gdbarch_ecoff_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);
+      set_gdbarch_dwarf_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);
+      set_gdbarch_dwarf2_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);
+      set_gdbarch_stab_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);
+      set_gdbarch_register_name (gdbarch, h8300s_register_name);
+      set_gdbarch_ptr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
+      set_gdbarch_addr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
+      set_gdbarch_extract_return_value (gdbarch, h8300h_extract_return_value);
+      set_gdbarch_store_return_value (gdbarch, h8300h_store_return_value);
+      set_gdbarch_print_insn (gdbarch, print_insn_h8300s);
+      break;
+    case bfd_mach_h8300s:
+      NormalMode = 0;
       h8300sxmode = 0;
       h8300smode = 1;
       h8300hmode = 1;
@@ -1250,8 +1286,26 @@ h8300_gdbarch_init (struct gdbarch_info 
       set_gdbarch_store_return_value (gdbarch, h8300h_store_return_value);
       set_gdbarch_print_insn (gdbarch, print_insn_h8300s);
       break;
-    case bfd_mach_h8300sx:
     case bfd_mach_h8300sxn:
+      NormalMode = 1;
+      h8300sxmode = 1;
+      h8300smode = 1;
+      h8300hmode = 1;
+      set_gdbarch_num_regs (gdbarch, 18);
+      set_gdbarch_num_pseudo_regs (gdbarch, 2);
+      set_gdbarch_ecoff_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);
+      set_gdbarch_dwarf_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);
+      set_gdbarch_dwarf2_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);
+      set_gdbarch_stab_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);
+      set_gdbarch_register_name (gdbarch, h8300sx_register_name);
+      set_gdbarch_ptr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
+      set_gdbarch_addr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
+      set_gdbarch_extract_return_value (gdbarch, h8300h_extract_return_value);
+      set_gdbarch_store_return_value (gdbarch, h8300h_store_return_value);
+      set_gdbarch_print_insn (gdbarch, print_insn_h8300s);
+      break;
+    case bfd_mach_h8300sx:
+      NormalMode = 0;
       h8300sxmode = 1;
       h8300smode = 1;
       h8300hmode = 1;
