Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH-H8300] TRAPA instruction handling
@ 2004-04-14 10:06 Asgari J. Jinia
  2004-04-15 20:45 ` Michael Snyder
  0 siblings, 1 reply; 2+ messages in thread
From: Asgari J. Jinia @ 2004-04-14 10:06 UTC (permalink / raw)
  To: gdb-patches

Hi,

In h8300 simulator, stack handling of TRAPA instruction is not
as per hardware manual. Presently it takes 12 bytes to store
CCR,PC and EXR registers on stack but it should do it with 6
bytes. Also simulation of @aa:8 addressing is broken as SBR
register is initialized to zero after initialized with 0xFFFFFF00.

Following patch does proper stack and @aa:8 handling.

Regards,
Asgari Jinia

---------------------------------------------------------------------

ChangeLog
sim/h8300

2004-04-13  Asgari Jinia  <asgarij@kpitcummins.com>

	* compile.c (sim_resume): updated stack for TRAPA as per
	hardware manual.
	(init_pointers): Initialization of h8_get_reg_buf removed as it
	corrupts SBR_REGNUM register, initialized in sim_state_initialize 
	function.



--- sim/h8300/compile.old.c	2004-01-06 06:28:48.000000000 +0530
+++ sim/h8300/compile.c	2004-04-13 14:31:43.000000000 +0530
@@ -1808,7 +1808,6 @@ init_pointers (SIM_DESC sd)
 
       h8_set_mask (sd, memory_size - 1);
 
-      memset (h8_get_reg_buf (sd), 0, sizeof (((STATE_CPU (sd, 0))->regs)));
 
       for (i = 0; i < 8; i++)
 	{
@@ -3584,14 +3583,13 @@ sim_resume (SIM_DESC sd, int step, int s
 
 	  if (h8300smode)			/* pop exr */
 	    {
-	      h8_set_exr (sd, GET_MEMORY_L (tmp));
-	      tmp += 4;
+	      h8_set_exr (sd, GET_MEMORY_W (tmp));
+	      tmp += 2;
 	    }
 	  if (h8300hmode && !h8300_normal_mode)
 	    {
-	      h8_set_ccr (sd, GET_MEMORY_L (tmp));
-	      tmp += 4;
-	      pc = GET_MEMORY_L (tmp);
+	      h8_set_ccr (sd, (GET_MEMORY_L (tmp) >> 24));
+	      pc = GET_MEMORY_L (tmp) & 0x00FFFFFF;
 	      tmp += 4;
 	    }
 	  else
@@ -3671,17 +3669,16 @@ sim_resume (SIM_DESC sd, int step, int s
    	  else
    	    {
    	      tmp -= 4;
-   	      SET_MEMORY_L (tmp, code->next_pc);
-   	      tmp -= 4;
-   	      SET_MEMORY_L (tmp, h8_get_ccr (sd));
+   	      SET_MEMORY_L (tmp, (code->next_pc & 0x00FFFFFF)+
+   	                    ((tmp, h8_get_ccr (sd))<<24));
    	    }
    	  intMaskBit = 1;
    	  BUILDSR (sd);
  
 	  if (h8300smode)
 	    {
-	      tmp -= 4;
-	      SET_MEMORY_L (tmp, h8_get_exr (sd));
+	      tmp -= 2;
+	      SET_MEMORY_W (tmp, h8_get_exr (sd));
 	    }
 
 	  h8_set_reg (sd, SP_REGNUM, tmp);


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH-H8300] TRAPA instruction handling
  2004-04-14 10:06 [PATCH-H8300] TRAPA instruction handling Asgari J. Jinia
@ 2004-04-15 20:45 ` Michael Snyder
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Snyder @ 2004-04-15 20:45 UTC (permalink / raw)
  To: Asgari J. Jinia; +Cc: gdb-patches, kazu, dvenkat

Asgari J. Jinia wrote:
> Hi,
> 
> In h8300 simulator, stack handling of TRAPA instruction is not
> as per hardware manual. Presently it takes 12 bytes to store
> CCR,PC and EXR registers on stack but it should do it with 6
> bytes. Also simulation of @aa:8 addressing is broken as SBR
> register is initialized to zero after initialized with 0xFFFFFF00.
> 
> Following patch does proper stack and @aa:8 handling.
> 
> Regards,
> Asgari Jinia

The implementation's good, but I can't comment on the technical 
correctness.  Adding Kazu and Venkat to Cc: in case they can.

Michael


> ---------------------------------------------------------------------
> 
> ChangeLog
> sim/h8300
> 
> 2004-04-13  Asgari Jinia  <asgarij@kpitcummins.com>
> 
> 	* compile.c (sim_resume): updated stack for TRAPA as per
> 	hardware manual.
> 	(init_pointers): Initialization of h8_get_reg_buf removed as it
> 	corrupts SBR_REGNUM register, initialized in sim_state_initialize 
> 	function.
> 
> 
> 
> --- sim/h8300/compile.old.c	2004-01-06 06:28:48.000000000 +0530
> +++ sim/h8300/compile.c	2004-04-13 14:31:43.000000000 +0530
> @@ -1808,7 +1808,6 @@ init_pointers (SIM_DESC sd)
>  
>        h8_set_mask (sd, memory_size - 1);
>  
> -      memset (h8_get_reg_buf (sd), 0, sizeof (((STATE_CPU (sd, 0))->regs)));
>  
>        for (i = 0; i < 8; i++)
>  	{
> @@ -3584,14 +3583,13 @@ sim_resume (SIM_DESC sd, int step, int s
>  
>  	  if (h8300smode)			/* pop exr */
>  	    {
> -	      h8_set_exr (sd, GET_MEMORY_L (tmp));
> -	      tmp += 4;
> +	      h8_set_exr (sd, GET_MEMORY_W (tmp));
> +	      tmp += 2;
>  	    }
>  	  if (h8300hmode && !h8300_normal_mode)
>  	    {
> -	      h8_set_ccr (sd, GET_MEMORY_L (tmp));
> -	      tmp += 4;
> -	      pc = GET_MEMORY_L (tmp);
> +	      h8_set_ccr (sd, (GET_MEMORY_L (tmp) >> 24));
> +	      pc = GET_MEMORY_L (tmp) & 0x00FFFFFF;
>  	      tmp += 4;
>  	    }
>  	  else
> @@ -3671,17 +3669,16 @@ sim_resume (SIM_DESC sd, int step, int s
>     	  else
>     	    {
>     	      tmp -= 4;
> -   	      SET_MEMORY_L (tmp, code->next_pc);
> -   	      tmp -= 4;
> -   	      SET_MEMORY_L (tmp, h8_get_ccr (sd));
> +   	      SET_MEMORY_L (tmp, (code->next_pc & 0x00FFFFFF)+
> +   	                    ((tmp, h8_get_ccr (sd))<<24));
>     	    }
>     	  intMaskBit = 1;
>     	  BUILDSR (sd);
>   
>  	  if (h8300smode)
>  	    {
> -	      tmp -= 4;
> -	      SET_MEMORY_L (tmp, h8_get_exr (sd));
> +	      tmp -= 2;
> +	      SET_MEMORY_W (tmp, h8_get_exr (sd));
>  	    }
>  
>  	  h8_set_reg (sd, SP_REGNUM, tmp);
> 



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-04-15 20:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-14 10:06 [PATCH-H8300] TRAPA instruction handling Asgari J. Jinia
2004-04-15 20:45 ` Michael Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox