Index: aki3068net/current/ChangeLog
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/aki3068net/current/ChangeLog,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- aki3068net/current/ChangeLog	4 Mar 2004 08:57:02 -0000	1.11
+++ aki3068net/current/ChangeLog	18 Mar 2004 16:19:38 -0000	1.12
@@ -1,3 +1,13 @@
+2004-03-17  Yoshinori Sato  <ysato@users.sourceforge.jp>
+
+	* include/hal_diag.h
+	fix warning.
+
+2004-03-02  Yoshinori Sato  <ysato@users.sourceforge.jp>
+
+	* include/platform.inc
+	add h8300_save_vectors macro.
+	
 2004-02-24  Yoshinori Sato  <ysato@users.sourceforge.jp>
 
 	* cdl/hal_h8300_h8300h_aki3068net.cdl
@@ -15,6 +25,10 @@
 	* src/plf_ide.c  
 	16bit bus mode fix.
 
+2003-12-04  Yoshinori Sato  <ysato@users.sourceforge.jp>
+	* include/pkgconf/mlt_h8300_h8300h_aki3068net_rom.ldi
+	fix vector location from CYGSEM_HAL_H8300_VECTOR_HOOK == 0
+	
 2003-07-18  Nick Garnett  <nickg@balti.calivar.com>
 
 	* cdl/hal_h8300_h8300h_aki3068net.cdl:
Index: aki3068net/current/src/hal_diag.c
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/aki3068net/current/src/hal_diag.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- aki3068net/current/src/hal_diag.c	8 Mar 2003 16:15:51 -0000	1.4
+++ aki3068net/current/src/hal_diag.c	17 Mar 2004 15:24:51 -0000	1.5
@@ -60,7 +60,7 @@
 
 #define SCI_BASE ((cyg_uint8*)CYGHAL_PLF_SCI_BASE)
 
-const static channel_data_t channel = { (cyg_uint8*)SCI_BASE, 0, 0};
+static channel_data_t channel = { (cyg_uint8*)SCI_BASE, 0, 0};
 
 void
 cyg_hal_plf_comms_init(void)
Index: arch/current/ChangeLog
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/arch/current/ChangeLog,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- arch/current/ChangeLog	24 Feb 2004 13:34:33 -0000	1.5
+++ arch/current/ChangeLog	18 Mar 2004 16:19:38 -0000	1.6
@@ -1,3 +1,12 @@
+2004-03-18  Yoshinori Sato <ysato@users.sourceforge.jp>
+
+	* src/context.S
+	fix broken ccr from context save.
+	* src/redboot_linux_exec.c
+	fix build error of undefined "CYGDAT_REDBOOT_H8300_LINUX_COMMAND_START"
+	* src/sci.c
+	delete waste code.
+
 2004-02-24  Yoshinori Sato <ysato@users.sourceforge.jp>
 
 	* src/vectors.S
@@ -6,6 +15,13 @@
 	* cdl/hal_h8300.cdl
 	add CYGSEM_HAL_SAVE_STUB_VECTOR
 	move CYGSEM_HAL_H8300_VECTOR_HOOK from target cdl's
+
+2003-12-04  Yoshinori Sato <ysato@users.sourceforge.jp>
+
+	* src/vector.S
+	add runtime vector setup.
+	add trace exception pc adjust.
+
 
 2003-07-10  Nick Garnett  <nickg@balti.calivar.com>
 
Index: arch/current/src/context.S
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/arch/current/src/context.S,v
retrieving revision 1.6
retrieving revision 1.8
diff -u -r1.6 -r1.8
--- arch/current/src/context.S	28 Nov 2003 15:34:06 -0000	1.6
+++ arch/current/src/context.S	18 Mar 2004 11:57:18 -0000	1.8
@@ -68,11 +68,14 @@
 #------------------------------------------------------------------------------
 # hal_thread_switch_context
 # Switch thread contexts
-# D0 = address of sp of next thread to execute
-# D1 = address of sp save location of current thread
+# er0 = address of sp of next thread to execute
+# er1 = address of sp save location of current thread
 
 	.global	CYG_LABEL_DEFN(hal_thread_switch_context)
 CYG_LABEL_DEFN(hal_thread_switch_context):
+	mov.w	@sp,r2		; save ccr
+	stc	ccr,r2h
+	mov.w	r2,@sp
 	hal_cpu_save_context
 	mov.l	sp,@er1
 	
Index: arch/current/src/redboot_linux_exec.c
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/arch/current/src/redboot_linux_exec.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- arch/current/src/redboot_linux_exec.c	4 Dec 2003 17:31:22 -0000	1.3
+++ arch/current/src/redboot_linux_exec.c	17 Mar 2004 15:29:01 -0000	1.4
@@ -58,22 +58,7 @@
 #define xstr(s) str(s)
 #define str(s...) #s
 
-static void do_exec(int argc, char *argv[]);
-static void do_set_mem(int argc, char *argv[]);
-
-RedBoot_cmd("exec", 
-            "Execute an image", 
-            "[-b <command line addr>] [-c \"kernel command line\"]\n"
-	    "        [<entry point>]",
-            do_exec
-    );
-RedBoot_cmd("set",
-	    "Set Memory",
-	    "-b address -[1|2|4] -d data",
-	    do_set_mem
-    );
-
-
+#if defined(CYGDAT_REDBOOT_H8300_LINUX_COMMAND_START)
 static void 
 do_exec(int argc, char *argv[])
 {
@@ -114,6 +99,14 @@
     asm ("jmp @%0" : : "r" (entry));
 }
 
+RedBoot_cmd("exec", 
+            "Execute an image", 
+            "[-b <command line addr>] [-c \"kernel command line\"]\n"
+	    "        [<entry point>]",
+            do_exec
+    );
+#endif
+
 static void
 do_set_mem(int argc, char *argv[])
 {
@@ -170,3 +163,10 @@
       break;
     }
 }
+
+RedBoot_cmd("set",
+	    "Set Memory",
+	    "-b address -[1|2|4] -d data",
+	    do_set_mem
+    );
+
Index: arch/current/src/sci.c
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/arch/current/src/sci.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- arch/current/src/sci.c	28 Mar 2003 12:50:09 -0000	1.2
+++ arch/current/src/sci.c	17 Mar 2004 15:28:16 -0000	1.3
@@ -109,7 +109,6 @@
 
     // Clear buffer full flag.
     HAL_WRITE_UINT8(base+_REG_SCSSR, sr & ~CYGARC_REG_SCSSR_RDRF);
-
     return true;
 }
 
@@ -210,17 +209,11 @@
     case __COMMCTL_IRQ_ENABLE:
         irq_state = 1;
         HAL_INTERRUPT_UNMASK(chan->isr_vector);
-        HAL_READ_UINT8(chan->base+_REG_SCSCR, scr);
-        scr |= CYGARC_REG_SCSCR_RIE;
-        HAL_WRITE_UINT8(chan->base+_REG_SCSCR, scr);
         break;
     case __COMMCTL_IRQ_DISABLE:
         ret = irq_state;
         irq_state = 0;
-        HAL_INTERRUPT_UNMASK(chan->isr_vector);
-        HAL_READ_UINT8(chan->base+_REG_SCSCR, scr);
-        scr &= ~CYGARC_REG_SCSCR_RIE;
-        HAL_WRITE_UINT8(chan->base+_REG_SCSCR, scr);
+        HAL_INTERRUPT_MASK(chan->isr_vector);
         break;
     case __COMMCTL_DBG_ISR_VECTOR:
         ret = chan->isr_vector;
Index: edosk2674/current/ChangeLog
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/edosk2674/current/ChangeLog,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- edosk2674/current/ChangeLog	4 Mar 2004 08:57:02 -0000	1.3
+++ edosk2674/current/ChangeLog	18 Mar 2004 16:19:38 -0000	1.4
@@ -1,8 +1,29 @@
+2004-03-18  Yoshinori Sato  <ysato@users.sourceforge.jp>
+
+	* include/hal_diag.h
+	fix warning.
+	
+2004-03-02  Yoshinori Sato  <ysato@users.sourceforge.jp>
+
+	* include/platform.inc
+	add h8300_save_vectors macro.
+
 2004-02-24  Yoshinori Sato  <ysato@users.sourceforge.jp>
 
 	* cdl/hal_h8300_h8s_edosk2674.cdl
 	add Linker flags "-mrelax"
 	move CYGSEM_HAL_H8300_VECTOR_HOOK to hal_h8300.cdl
+
+2003-12-04  Uwe Kindler <ukindler@htwm.de>,Yoshinori Sato <ysato@users.sourceforge.jp>
+
+	* include/platform.inc
+	fix ISCR setup.
+
+2003-11-29  Yoshinori Sato  <ysato@users.sourceforge.jp>
+
+	* include/plf_intr.h
+	target name fix
+
 
 2003-02-21  Yoshinori Sato  <qzb04471@nifty.ne.jp>
 
Index: edosk2674/current/src/hal_diag.c
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/edosk2674/current/src/hal_diag.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- edosk2674/current/src/hal_diag.c	8 Mar 2003 16:16:16 -0000	1.2
+++ edosk2674/current/src/hal_diag.c	17 Mar 2004 15:24:51 -0000	1.3
@@ -58,7 +58,7 @@
 
 #define SCI_BASE ((cyg_uint8*)CYGHAL_PLF_SCI_BASE)
 
-const static channel_data_t channel = { (cyg_uint8*)SCI_BASE, 0, 0};
+static channel_data_t channel = { (cyg_uint8*)SCI_BASE, 0, 0};
 
 void
 cyg_hal_plf_comms_init(void)
Index: h8300h/current/ChangeLog
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/h8300h/current/ChangeLog,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- h8300h/current/ChangeLog	28 Nov 2003 15:34:06 -0000	1.5
+++ h8300h/current/ChangeLog	18 Mar 2004 16:19:38 -0000	1.6
@@ -1,3 +1,20 @@
+2003-03-17  Yoshinori Sato  <ysato@users.sourceforge.jp>
+
+	* src/h8300h_stub.c
+	Bcc d:16 trace miss fix.
+	cleanup code.
+
+2003-12-12  Yoshinori Sato  <ysato@users.sourceforge.jp>
+
+	* src/h8300h_stub.c
+	deleet async_breakpoint.
+	rewrite single step support.
+
+2003-12-08  Yoshinori Sato  <ysato@users.sourceforge.jp>
+
+	* include/variant.inc
+	add h8300_trap_adjust_pc macro.
+	
 2003-07-10  Nick Garnett  <nickg@balti.calivar.com>
 
 	* <general>: Added Yoshinori Sato's changes, see entries below,
Index: h8300h/current/src/h8300h_stub.c
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/h8300h/current/src/h8300h_stub.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- h8300h/current/src/h8300h_stub.c	12 Dec 2003 16:26:54 -0000	1.5
+++ h8300h/current/src/h8300h_stub.c	17 Mar 2004 15:26:21 -0000	1.6
@@ -117,41 +117,13 @@
 {
     if ((long)InstBuffer.addr != -1L) {
 	*InstBuffer.addr = InstBuffer.inst;
-	(long)InstBuffer.addr = -1L;
+	InstBuffer.addr = (unsigned short *)-1;
     }
 }
 
 /* calculate next pc */
 
-#define JP_NONE 0
-#define JP_ABS  1
-#define JP_IND  2
-#define JP_REL  3
-#define JP_RET  4
-#define JP_REG  5     
-
-static unsigned short *getjumpaddr(unsigned short *pc,int type)
-{
-    unsigned long *sp;
-    unsigned long addr;
-    switch (type) {
-    case JP_ABS:
-	addr = *(unsigned long *)pc;
-	return (unsigned short *)(addr & 0x00ffffff);
-    case JP_IND:
-	addr = *pc & 0xff;
-	return (unsigned short *)(*(unsigned long *)addr);
-    case JP_RET:
-	
-	sp = (unsigned long *)get_register(SP);
-	return (unsigned short *)(*(sp+3) & 0x00ffffff);
-    case JP_REG:
-	addr = get_register((*pc >> 4) & 0x07);
-	return (unsigned short *)addr;
-    default:
-	return NULL;
-    }
-}
+enum jump_type{none,aabs,aind,ret,reg,relb,relw};
 
 /* opcode decode table define
    ptn: opcode pattern
@@ -159,126 +131,103 @@
    len: instruction length (<0 next table index)
    jmp: jump operation mode */
 
-#define OPTABLE(ptn,msk,len,jmp) ((ptn)<<24 | (msk) << 16 | (((len) << 8) & 0xff00) | (jmp))
-
-const static unsigned long optable_0[] = {
-    OPTABLE(0x00,0xff, 1,JP_NONE), /* 0x00 */
-    OPTABLE(0x01,0xff,-1,JP_NONE), /* 0x01 */
-    OPTABLE(0x02,0xfe, 1,JP_NONE), /* 0x02-0x03 */
-    OPTABLE(0x04,0xee, 1,JP_NONE), /* 0x04-0x05/0x14-0x15 */
-    OPTABLE(0x06,0xfe, 1,JP_NONE), /* 0x06-0x07 */
-    OPTABLE(0x08,0xea, 1,JP_NONE), /* 0x08-0x09/0x0c-0x0d/0x18-0x19/0x1c-0x1d */
-    OPTABLE(0x0a,0xee, 1,JP_NONE), /* 0x0a-0x0b/0x1a-0x1b */
-    OPTABLE(0x0e,0xee, 1,JP_NONE), /* 0x0e-0x0f/0x1e-0x1f */
-    OPTABLE(0x10,0xfc, 1,JP_NONE), /* 0x10-0x13 */
-    OPTABLE(0x16,0xfe, 1,JP_NONE), /* 0x16-0x17 */
-    OPTABLE(0x20,0xe0, 1,JP_NONE), /* 0x20-0x3f */
-    OPTABLE(0x40,0xf0, 1,JP_REL ), /* 0x40-0x4f */
-    OPTABLE(0x50,0xfc, 1,JP_NONE), /* 0x50-0x53 */
-    OPTABLE(0x54,0xfc, 1,JP_RET ), /* 0x54 */
-    OPTABLE(0x55,0xfc, 1,JP_REL ), /* 0x55 */
-    OPTABLE(0x56,0xfc, 1,JP_RET ), /* 0x56 */
-    OPTABLE(0x57,0xfc, 1,JP_NONE), /* 0x57 */
-    OPTABLE(0x58,0xfb, 2,JP_REL ), /* 0x58/0x5c */
-    OPTABLE(0x59,0xfb, 1,JP_REG ), /* 0x59/0x5b */
-    OPTABLE(0x5a,0xfb, 2,JP_ABS ), /* 0x5a/0x5e */
-    OPTABLE(0x5b,0xfb, 2,JP_IND ), /* 0x5b/0x5f */
-    OPTABLE(0x60,0xe8, 1,JP_NONE), /* 0x60-0x67/0x70-0x77 */
-    OPTABLE(0x68,0xfa, 1,JP_NONE), /* 0x68-0x69/0x6c-0x6d */
-    OPTABLE(0x6a,0xfe,-2,JP_NONE), /* 0x6a-0x6b */
-    OPTABLE(0x6e,0xfe, 2,JP_NONE), /* 0x6e-0x6f */
-    OPTABLE(0x78,0xff, 4,JP_NONE), /* 0x78 */
-    OPTABLE(0x79,0xff, 2,JP_NONE), /* 0x79 */
-    OPTABLE(0x7a,0xff, 3,JP_NONE), /* 0x7a */
-    OPTABLE(0x7b,0xff, 2,JP_NONE), /* 0x7b */
-    OPTABLE(0x7c,0xfc, 2,JP_NONE), /* 0x7c-0x7f */
-    OPTABLE(0x80,0x80, 1,JP_NONE), /* 0x80-0xff */
-    -1
-};
-
-const static unsigned long optable_1[] = {
-    OPTABLE(0x00,0xff,-3,JP_NONE), /* 0x0100 */
-    OPTABLE(0x40,0xf0,-3,JP_NONE), /* 0x0140-0x14f */
-    OPTABLE(0x80,0xf0, 1,JP_NONE), /* 0x0180-0x018f */
-    OPTABLE(0xc0,0xc0, 2,JP_NONE), /* 0x01c0-0x01ff */
-    -1
-};
-
-const static unsigned long optable_2[] = {
-    OPTABLE(0x00,0x20, 2,JP_NONE), /* 0x6a0?/0x6a8?/0x6b0?/0x6b8? */
-    OPTABLE(0x20,0x20, 3,JP_NONE), /* 0x6a2?/0x6aa?/0x6b2?/0x6ba? */
-    -1
-};
-
-const static unsigned long optable_3[] = {
-    OPTABLE(0x69,0xfb, 2,JP_NONE), /* 0x010069/0x01006d/014069/0x01406d */
-    OPTABLE(0x6b,0xff,-4,JP_NONE), /* 0x01006b/0x01406b */
-    OPTABLE(0x6f,0xff, 3,JP_NONE), /* 0x01006f/0x01406f */
-    OPTABLE(0x78,0xff, 5,JP_NONE), /* 0x010078/0x014078 */
-    -1
-};
-
-const static unsigned long optable_4[] = {
-    OPTABLE(0x00,0x78, 3,JP_NONE), /* 0x0100690?/0x01006d0?/0140690/0x01406d0?/0x0100698?/0x01006d8?/0140698?/0x01406d8? */
-    OPTABLE(0x20,0x78, 4,JP_NONE), /* 0x0100692?/0x01006d2?/0140692/0x01406d2?/0x010069a?/0x01006da?/014069a?/0x01406da? */
-    -1
-};
-
-const static unsigned long *optables[] = {
-    optable_0,
-    optable_1,
-    optable_2,
-    optable_3,
-    optable_4,
+struct optable {
+    unsigned char pattern;
+    unsigned char mask;
+    signed   char length;
+    char          type;
+} __attribute__((aligned(1),packed));
+
+#define OPTABLE(ptn,msk,len,jmp) {ptn,msk,len,jmp}
+
+const static struct optable optable_0[] = {
+    OPTABLE(0x00,0xff, 1,none), /* 0x00 */
+    OPTABLE(0x01,0xff,-1,none), /* 0x01 */
+    OPTABLE(0x02,0xfe, 1,none), /* 0x02-0x03 */
+    OPTABLE(0x04,0xee, 1,none), /* 0x04-0x05/0x14-0x15 */
+    OPTABLE(0x06,0xfe, 1,none), /* 0x06-0x07 */
+    OPTABLE(0x08,0xea, 1,none), /* 0x08-0x09/0x0c-0x0d/0x18-0x19/0x1c-0x1d */
+    OPTABLE(0x0a,0xee, 1,none), /* 0x0a-0x0b/0x1a-0x1b */
+    OPTABLE(0x0e,0xee, 1,none), /* 0x0e-0x0f/0x1e-0x1f */
+    OPTABLE(0x10,0xfc, 1,none), /* 0x10-0x13 */
+    OPTABLE(0x16,0xfe, 1,none), /* 0x16-0x17 */
+    OPTABLE(0x20,0xe0, 1,none), /* 0x20-0x3f */
+    OPTABLE(0x40,0xf0, 1,relb), /* 0x40-0x4f */
+    OPTABLE(0x50,0xfc, 1,none), /* 0x50-0x53 */
+    OPTABLE(0x54,0xfd, 1,ret ), /* 0x54/0x56 */
+    OPTABLE(0x55,0xff, 1,relb), /* 0x55 */
+    OPTABLE(0x57,0xff, 1,none), /* 0x57 */
+    OPTABLE(0x58,0xfb, 2,relw), /* 0x58/0x5c */
+    OPTABLE(0x59,0xfb, 1,reg ), /* 0x59/0x5b */
+    OPTABLE(0x5a,0xfb, 2,aabs), /* 0x5a/0x5e */
+    OPTABLE(0x5b,0xfb, 2,aind), /* 0x5b/0x5f */
+    OPTABLE(0x60,0xe8, 1,none), /* 0x60-0x67/0x70-0x77 */
+    OPTABLE(0x68,0xfa, 1,none), /* 0x68-0x69/0x6c-0x6d */
+    OPTABLE(0x6a,0xfe,-2,none), /* 0x6a-0x6b */
+    OPTABLE(0x6e,0xfe, 2,none), /* 0x6e-0x6f */
+    OPTABLE(0x78,0xff, 4,none), /* 0x78 */
+    OPTABLE(0x79,0xff, 2,none), /* 0x79 */
+    OPTABLE(0x7a,0xff, 3,none), /* 0x7a */
+    OPTABLE(0x7b,0xff, 2,none), /* 0x7b */
+    OPTABLE(0x7c,0xfc, 2,none), /* 0x7c-0x7f */
+    OPTABLE(0x80,0x80, 1,none), /* 0x80-0xff */
+};
+
+const static struct optable optable_1[] = {
+    OPTABLE(0x00,0xff,-3,none), /* 0x0100 */
+    OPTABLE(0x40,0xf0,-3,none), /* 0x0140-0x14f */
+    OPTABLE(0x80,0xf0, 1,none), /* 0x0180-0x018f */
+    OPTABLE(0xc0,0xc0, 2,none), /* 0x01c0-0x01ff */
+};
+
+const static struct optable optable_2[] = {
+    OPTABLE(0x00,0x20, 2,none), /* 0x6a0?/0x6a8?/0x6b0?/0x6b8? */
+    OPTABLE(0x20,0x20, 3,none), /* 0x6a2?/0x6aa?/0x6b2?/0x6ba? */
+};
+
+const static struct optable optable_3[] = {
+    OPTABLE(0x69,0xfb, 2,none), /* 0x010069/0x01006d/014069/0x01406d */
+    OPTABLE(0x6b,0xff,-4,none), /* 0x01006b/0x01406b */
+    OPTABLE(0x6f,0xff, 3,none), /* 0x01006f/0x01406f */
+    OPTABLE(0x78,0xff, 5,none), /* 0x010078/0x014078 */
+};
+
+const static struct optable optable_4[] = {
+    OPTABLE(0x00,0x78, 3,none), /* 0x0100690?/0x01006d0?/0140690/0x01406d0?/0x0100698?/0x01006d8?/0140698?/0x01406d8? */
+    OPTABLE(0x20,0x78, 4,none), /* 0x0100692?/0x01006d2?/0140692/0x01406d2?/0x010069a?/0x01006da?/014069a?/0x01406da? */
+};
+
+const static struct {
+    const struct optable *op;
+    int length;
+} optables[] = {
+    {optable_0,sizeof(optable_0)/sizeof(struct optable)},
+    {optable_1,sizeof(optable_1)/sizeof(struct optable)},
+    {optable_2,sizeof(optable_2)/sizeof(struct optable)},
+    {optable_3,sizeof(optable_3)/sizeof(struct optable)},
+    {optable_4,sizeof(optable_4)/sizeof(struct optable)},
 };
 
-static unsigned short *getnextpc(unsigned short *pc)
-{
-    unsigned char *optable_p;
-    unsigned char *fetch_p;
-    unsigned char inst;
-    optable_p = (unsigned char *)optable_0;
-    fetch_p = (unsigned char *)pc;
-    inst = *fetch_p++;
-    while (*(long *)optable_p != -1) {
-	if ((inst & optable_p[1]) == optable_p[0]) {
-	    if ((signed char)optable_p[2] < 0) {
-		optable_p = (unsigned char *)optables[-(signed char)optable_p[2]];
-		inst = *fetch_p++;
-	    } else {
-		if ((optable_p[3] == JP_NONE))
-		    return pc + optable_p[2];
-		else
-		    return getjumpaddr(pc,optable_p[3]);
-	    }
-	} else
-	    optable_p += sizeof(unsigned long);
-    }
-    diag_printf("unknown inst: %04x at %06x\n",*pc,pc);
-    return NULL;
-}
-
-const unsigned char condmask[] = {
+const static unsigned char condmask[] = {
     0x00,0x40,0x01,0x04,0x02,0x08,0x10,0x20
 };
 
-static int isbranch(int reson,int cond)
+static int isbranch(int reson)
 {
+    unsigned char cond = get_register(CCR);
     /* encode complex conditions */
     /* B4: N^V
        B5: Z|(N^V)
        B6: C|Z */
-    __asm__("mov.l %1,er1\n\t"
-	    "bld #3,r1l\n\t"
-	    "bxor #1,r1l\n\t"
-	    "bst #4,r1l\n\t"
-	    "bor #2,r1l\n\t"
-	    "bst #5,r1l\n\t"
-	    "bld #2,r1l\n\t"
-	    "bor #0,r1l\n\t"
-	    "bst #6,r1l\n\t"
-	    "mov.l er1,%0"
-	    :"=r"(cond):"g"(cond):"er1","cc");
+    __asm__("bld #3,%w0\n\t"
+	    "bxor #1,%w0\n\t"
+	    "bst #4,%w0\n\t"
+	    "bor #2,%w0\n\t"
+	    "bst #5,%w0\n\t"
+	    "bld #2,%w0\n\t"
+	    "bor #0,%w0\n\t"
+	    "bst #6,%w0\n\t"
+	    :"=&r"(cond):"g"(cond):"cc");
     cond &= condmask[reson >> 1];
     if (!(reson & 1))
 	return cond == 0;
@@ -286,39 +235,62 @@
 	return cond != 0;
 }
 
-/* check PC relative addressing */
-#define isrelative(inst) ((((inst) & 0xf000) == 0x4000) || \
-                          (((inst) & 0xff00) == 0x5500) || \
-                          (((inst) & 0xfb00) == 0x5800))     
-
-#define offsetlength(inst) (((inst) & 0xfb00) == 0x5800)
-
-/* check jump instruction */
+static unsigned short *getnextpc(unsigned short *pc)
+{
+    const struct optable *op;
+    unsigned char *fetch_p;
+    unsigned char inst;
+    unsigned long addr;
+    unsigned long *sp;
+    int op_len;
+    op = optables[0].op;
+    op_len = optables[0].length;
+    fetch_p = (unsigned char *)pc;
+    inst = *fetch_p++;
+    do {
+	if ((inst & op->mask) == op->pattern) {
+	    if (op->length < 0) {
+		op = optables[-op->length].op;
+		op_len = optables[-op->length].length + 1;
+		inst = *fetch_p++;
+	    } else {
+		switch (op->type) {
+		case none:
+		    return pc + op->length;
+		case aabs:
+		    addr = *(unsigned long *)pc;
+		    return (unsigned short *)(addr & 0x00ffffff);
+		case aind:
+		    addr = *pc & 0xff;
+		    return (unsigned short *)(*(unsigned long *)addr);
+		case ret:
+		    sp = (unsigned long *)get_register(SP);
+		    return (unsigned short *)(*(sp+3) & 0x00ffffff);
+		case reg:
+		    addr = get_register((*pc >> 4) & 0x07);
+		    return (unsigned short *)addr;
+		case relb:
+		    if ((inst = 0x55) || isbranch(inst & 0x0f))
+			(unsigned char *)pc += (signed char)(*fetch_p);
+		    return pc+1; /* skip myself */
+		case relw:
+		    if ((inst = 0x5c) || isbranch((*fetch_p & 0xf0) >> 4))
+			(unsigned char *)pc += (signed short)(*(pc+1));
+		    return pc+2; /* skip myself */
+		}
+	    }
+	} else
+	    op++;
+    } while(--op_len > 0);
+    return NULL;
+}
 
 /* Set breakpoint(s) to simulate a single step from the current PC.  */
 
 void __single_step (void)
 {
-    unsigned short *pc = (unsigned short *)get_register(PC);
     unsigned short *nextpc;
-    unsigned int ccr = get_register(CCR);
-    unsigned short inst;
-    inst = *pc;
-    if (!isrelative(inst))
-	nextpc = getnextpc(pc);
-    else {
-	nextpc = pc + 1;
-	if (!offsetlength(inst)) {
-	    /* Bcc xx:8 */
-	    if (((inst & 0xff00) == 0x5500) || isbranch((inst & 0x0f00) >> 8, ccr))
-		(unsigned char *)nextpc += (signed char)(inst & 0xff);
-	} else {
-	    /* Bcc xx:16 */
-	    if ((inst == 0x5c00) || isbranch((inst & 0x00f0) >> 4, ccr))
-		(unsigned char *)nextpc += (signed short)(*nextpc);
-	    nextpc++;  /* adjust offset */
-	}
-    }
+    nextpc = getnextpc((unsigned short *)get_register(PC));
     InstBuffer.addr = nextpc;
     InstBuffer.inst = *nextpc;
     *nextpc = HAL_BREAKINST;
Index: h8max/current/ChangeLog
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/h8max/current/ChangeLog,v
retrieving revision 1.3
diff -u -r1.3 ChangeLog
--- h8max/current/ChangeLog	24 Feb 2004 13:35:24 -0000	1.3
+++ h8max/current/ChangeLog	18 Mar 2004 16:31:51 -0000
@@ -1,3 +1,13 @@
+2004-03-17  Yoshinori Sato  <ysato@users.sourceforge.jp>
+
+	* src/hal_diag.c
+	fix warning.
+
+2004-03-02  Yoshinori Sato  <ysato@users.sourceforge.jp>
+
+	* include/platform.inc
+	add h8300_save_vectors macro.
+
 2004-02-24  Yoshinori Sato  <ysato@users.sourceforge.jp>
 
 	* cdl/hal_h8300_h8300h_h8max.cdl
Index: h8max/current/src/hal_diag.c
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/h8max/current/src/hal_diag.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- h8max/current/src/hal_diag.c	8 Mar 2003 16:16:46 -0000	1.2
+++ h8max/current/src/hal_diag.c	17 Mar 2004 15:24:51 -0000	1.3
@@ -60,7 +60,7 @@
 
 #define SCI_BASE ((cyg_uint8*)CYGHAL_PLF_SCI_BASE)
 
-const static channel_data_t channel = { (cyg_uint8*)SCI_BASE, 0, 0};
+static channel_data_t channel = { (cyg_uint8*)SCI_BASE, 0, 0};
 
 void
 cyg_hal_plf_comms_init(void)
Index: h8s/current/ChangeLog
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/h8s/current/ChangeLog,v
retrieving revision 1.2
diff -u -r1.2 ChangeLog
--- h8s/current/ChangeLog	8 Mar 2003 16:16:51 -0000	1.2
+++ h8s/current/ChangeLog	18 Mar 2004 16:31:51 -0000
@@ -1,3 +1,19 @@
+2004-03-18  Yoshinori Sato  <ysato@users.sourceforge.jp>
+
+	* include/variant.inc
+	fix exr handling.
+
+2003-12-08  Yoshinori Sato  <ysato@users.sourceforge.jp>
+
+	* src/h8300_h8s.ld
+	fix typo.
+	* src/h8s_stub.c
+	rewrite. use CPU trace support.
+	* include/variant.inc
+	single step exception support.
+	* include/var_arch.h
+	add EXR read/write support.
+
 2003-03-09  Yoshinori Sato  <ysato@users.sourceforge.jp>
 
 	* New package.
Index: h8s/current/include/variant.inc
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/h8s/current/include/variant.inc,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- h8s/current/include/variant.inc	8 Dec 2003 16:55:48 -0000	1.10
+++ h8s/current/include/variant.inc	18 Mar 2004 11:57:18 -0000	1.11
@@ -72,8 +72,8 @@
 # CPU state save and restore macros
 
 	.macro	hal_cpu_save_all
-	subs	#4,sp				; reserve space
-	subs	#2,sp
+	subs	#2,sp				; reserve space
+	subs	#4,sp
 	mov.l	sp,@-sp
 	stm	er0-er3,@-sp
 	stm	er4-er6,@-sp
@@ -88,10 +88,10 @@
 	.endm
 
 	.macro	hal_cpu_load_all
-	mov.w	@(4*8+2:16,sp),r0
-	mov.w	@(4*10:16,sp),r1
-	mov.b	r0l,r1h
-	mov.w	r1,@(4*10:16,sp)		; set ccr
+	mov.w	@(4*8+2:16,sp),r1		; load ccr
+	mov.w	@(4*10:16,sp),r0		; load pc+ccr high word
+	mov.b	r1l,r0h				; replace ccr byte
+	mov.w	r0,@(4*10:16,sp)		; restore pc+ccr high word
 	mov.w	@(4*9+2:16,sp),r0
 	mov.b	r0l,r0h
 	mov.w	r0,@(4*9+2:16,sp)		; extend exr
@@ -101,8 +101,8 @@
 	.endm
 
         .macro hal_cpu_save_context
-        sub.w   r2,r2
         stc     exr,r2l
+	mov.b	r2l,r2h
         mov.w   r2,@-sp
         hal_cpu_save_all
         .endm
Index: sim/current/ChangeLog
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/sim/current/ChangeLog,v
retrieving revision 1.6
diff -u -r1.6 ChangeLog
--- sim/current/ChangeLog	4 Mar 2004 08:57:02 -0000	1.6
+++ sim/current/ChangeLog	18 Mar 2004 16:31:52 -0000
@@ -1,3 +1,8 @@
+2004-03-18  Yoshinori Sato  <ysato@users.sourceforge.jp>
+
+	* src/hal_diag.c
+	fix warning.
+
 2004-02-24  Yoshinori Sato  <ysato@users.sourceforge.jp>
 
 	* cdl/hal_h8300_h8300h_sim.cdl
Index: sim/current/src/hal_diag.c
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/sim/current/src/hal_diag.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- sim/current/src/hal_diag.c	8 Mar 2003 16:17:21 -0000	1.5
+++ sim/current/src/hal_diag.c	17 Mar 2004 15:24:51 -0000	1.6
@@ -58,7 +58,7 @@
 
 #define SCI_BASE ((cyg_uint8*)CYGHAL_PLF_SCI_BASE)
 
-const static channel_data_t channel = { (cyg_uint8*)SCI_BASE, 0, 0};
+static channel_data_t channel = { (cyg_uint8*)SCI_BASE, 0, 0};
 
 void
 cyg_hal_plf_comms_init(void)
Index: sim_s/current/ChangeLog
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/sim_s/current/ChangeLog,v
retrieving revision 1.4
diff -u -r1.4 ChangeLog
--- sim_s/current/ChangeLog	4 Mar 2004 08:57:02 -0000	1.4
+++ sim_s/current/ChangeLog	18 Mar 2004 16:31:52 -0000
@@ -1,3 +1,8 @@
+2004-03-18  Yoshinori Sato  <ysato@users.sourceforge.jp>
+
+	* src/hal_diag.c
+	fix warning.
+
 2004-02-24  Yoshinori Sato  <ysato@users.sourceforge.jp>
 
 	* cdl/hal_h8300_h8s_sim.cdl
Index: sim_s/current/cdl/hal_h8300_h8s_sim.cdl
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/sim_s/current/cdl/hal_h8300_h8s_sim.cdl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- sim_s/current/cdl/hal_h8300_h8s_sim.cdl	24 Feb 2004 13:34:33 -0000	1.3
+++ sim_s/current/cdl/hal_h8300_h8s_sim.cdl	17 Mar 2004 15:22:58 -0000	1.4
@@ -173,7 +173,7 @@
             display "Global linker flags"
             flavor  data
             no_define
-            default_value { "-g -nostdlib -Wl,--gc-sections -Wl,-static -Wl,-relax -ms -mint32" }
+            default_value { "-g -nostdlib -Wl,--gc-sections -Wl,-static -mrelax -ms -mint32" }
             description   "
                 This option controls the global linker flags. Individual
                 packages may define options which override these global flags."
Index: sim_s/current/src/hal_diag.c
===================================================================
RCS file: /cvsroot/ecos-h8/ecos/packages/hal/h8300/sim_s/current/src/hal_diag.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- sim_s/current/src/hal_diag.c	8 Mar 2003 16:17:30 -0000	1.5
+++ sim_s/current/src/hal_diag.c	17 Mar 2004 15:24:51 -0000	1.6
@@ -58,7 +58,7 @@
 
 #define SCI_BASE ((cyg_uint8*)CYGHAL_PLF_SCI_BASE)
 
-const static channel_data_t channel = { (cyg_uint8*)SCI_BASE, 0, 0};
+static channel_data_t channel = { (cyg_uint8*)SCI_BASE, 0, 0};
 
 void
 cyg_hal_plf_comms_init(void)
