This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

pending/982: PATCH: SH Simulator - MAC.L implementation and MAC.W correction


>Number:         982
>Category:       pending
>Synopsis:       PATCH: SH Simulator - MAC.L implementation and MAC.W correction
>Confidential:   yes
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   unknown
>Arrival-Date:   Fri Jan 31 05:08:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        
>Organization:
>Environment:
>Description:
 Hi,
 At present in SH simulator of GDB there are two problems.
 
 1. The GDB crashes during simulation of MAC.W instruction.=20
 2. Simulation of MAC.L is not present in GDB simulator.
 
 Following patch corrects the MAC.W crash problem and implements the =
 MAC.L instruction.
 
 The simulation algorithm for MAC.L is taken from Hitachi SH1/2 =
 programming manual=20
 page no. 177 available at =
 http://www.hitachi-eu.com/hel/ecg/products/micro/pdf/sh1_2p.pdf
 
 Regards,
 Shrinivas
 
 Changelog:
 
 2002-11-26  Shrinivas Atre  <shrinivasa@kpit.com>=09
 	* sim/sh/gencode.c : Addition of MAC.L handler and correction for MAC.W =
 handler
 	* sim/sh/interp.c  : Implementation of MAC.L handler.
 =09
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D
 --- sim/sh/gencode.cvs.c	Thu Nov 21 14:42:16 2002
 +++ sim/sh/gencode.c	Fri Nov 22 09:58:54 2002
 @@ -577,12 +577,12 @@ op tab[] =3D
    },
 =20
    { "", "nm", "mac.l @<REG_M>+,@<REG_N>+", "0000nnnnmmmm1111",
 -    "trap (255, R0, PC, memory, maskl, maskw, endianw);",
 +    "macl(&R0,memory,n,m);",
      "/* FIXME: mac.l support */",
    },
 =20
    { "", "nm", "mac.w @<REG_M>+,@<REG_N>+", "0100nnnnmmmm1111",
 -    "macw(R0,memory,n,m,endianw);",
 +    "macw(&R0,memory,n,m,endianw);",
    },
 =20
    { "n", "", "mov #<imm>,<REG_N>", "1110nnnni8*1....",
 
 
 --- sim/sh/interp.cvs.c	Thu Nov 21 14:42:16 2002
 +++ sim/sh/interp.c	Thu Nov 21 14:55:34 2002
 @@ -169,6 +169,7 @@ static char **prog_argv;
 =20
  #if 1
  static int maskw =3D 0;
 +static int maskl =3D 0;
  #endif
 =20
  static SIM_OPEN_KIND sim_kind;
 @@ -651,6 +652,7 @@ rbat_fast (memory, x, maskb)
 =20
  #define RUWAT(x)  (RWAT(x) & 0xffff)
  #define RSWAT(x)  ((short)(RWAT(x)))
 +#define RSLAT(x)  ((long)(RLAT(x)))
  #define RSBAT(x)  (SEXT(RBAT(x)))
 =20
  #define RDAT(x, n) (do_rdat (memory, (x), (n), (maskl)))
 @@ -1347,6 +1349,96 @@ macw (regs, memory, n, m, endianw)
      }
    MACL =3D sum;
  }
 +
 +static void
 +macl (regs, memory, n, m)
 +     int *regs;
 +     unsigned char *memory;
 +     int m, n;
 +{
 +	unsigned long RnL,RnH,RmL,RmH,Res0,Res1,Res2;
 +	unsigned long temp0,temp1,temp2,temp3;
 +	long tempm,tempn,fnLmL;
 +
 +	tempm=3DRSLAT(regs[m]);
 +	regs[m]+=3D4;
 +
 +	tempn=3DRSLAT(regs[n]);
 +	regs[n]+=3D4;
 +
 +	if ((long)(tempn^tempm) < 0)
 +		fnLmL =3D -1;
 +	else
 +		fnLmL =3D 0;
 +
 +	if (tempn < 0)
 +		tempn =3D 0 - tempn;
 +	if (tempm < 0)
 +		tempm =3D 0 - tempm;
 +
 +	temp1 =3D (unsigned long)tempn;
 +	temp2 =3D (unsigned long)tempm;
 +
 +	RnL =3D temp1 & 0x0000FFFF;
 +
 +	RnH =3D (temp1>>16) & 0x0000FFFF;
 +	RmL =3D temp2 & 0x0000FFFF;
 +	RmH =3D (temp2 >> 16) & 0x0000FFFF;
 +	temp0 =3D RmL * RnL;
 +	temp1 =3D RmH * RnL;
 +	temp2 =3D RmL * RnH;
 +	temp3 =3D RmH * RnH;
 +	Res2  =3D 0;
 +	Res1  =3D temp1 + temp2;
 +
 +	if ( Res1 < temp1)
 +		Res2+=3D0x00010000;
 +
 +	temp1 =3D (Res1 << 16) & 0xFFFF0000;
 +	Res0  =3D  temp0 + temp1;
 +
 +	if ( Res0 < temp0 )
 +		Res2++;
 +	Res2 =3D Res2 + (( Res1 >> 16 ) & 0x0000FFFF) + temp3;
 +	if(fnLmL < 0)
 +	{
 +		Res2 =3D ~Res2;
 +		if (Res0 =3D=3D 0)
 +			Res2++;
 +		else
 +			Res0 =3D (~Res0) + 1;
 +	}
 +	if(S=3D=3D1)
 +	{
 +		Res0 =3D MACL + Res0;
 +		if ( MACL > Res0 )
 +			Res2++;
 +		Res2 +=3D ( MACH & 0x0000FFFF );
 +		if(((long)Res2 < 0) && ( Res2 < 0xFFFF8000))
 +		{
 +			Res2 =3D 0x00008000;
 +			Res0 =3D 0x00000000;
 +		}
 +		if(((long)Res2 > 0) && (Res2 > 0x00007FFF))
 +		{
 +			Res2 =3D 0x00007FFF;
 +			Res0 =3D 0xFFFFFFFF;
 +		};
 +
 +		MACH =3D Res2;
 +		MACL =3D Res0;
 +	}
 +	else
 +	{
 +		Res0 =3D MACL + Res0;
 +		if( MACL > Res0)
 +			Res2++;
 +		Res2 +=3D MACH;
 +		MACH =3D Res2;
 +		MACL =3D Res0;
 +	}
 +}
 +
 =20
  static struct loop_bounds
  get_loop_bounds (rs, re, memory, mem_end, maskw, endianw)
 
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D
 
 -------------------------------------------------------------------------=
 ----
 Free download of GNUSH and GNUH8 tool chains for Hitachi's SH and H8 =
 Series.
 The following site also offers free support to European customers.
 Read more at http://www.kpit.com/products/support.htm
 Latest versions of GNUSH and GNUH8 are released on October 1, 2002.
 -------------------------------------------------------------------------=
 ----
 
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]