This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
pending/1116: UPDATED PATCH: SH Simulator - MAC.L implementation and MAC.W correction
- From: "Shrinivas Atre" <ShrinivasA at kpit dot com>
- To: gdb-gnats at sources dot redhat dot com
- Date: Tue, 4 Mar 2003 19:17:57 +0530
- Subject: pending/1116: UPDATED PATCH: SH Simulator - MAC.L implementation and MAC.W correction
>Number: 1116
>Category: pending
>Synopsis: UPDATED 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: Tue Mar 04 16:28: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.
Regards,
Shrinivas
Changelog:
2003-03-04 Shrinivas Atre <shrinivasa at kpit dot com>=09
* sim/sh/gencode.c ( tab[] ): Addition of MAC.L handler and correction =
for MAC.W handler
* sim/sh/interp.c ( macl ): New Function. 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.orig.c Tue Mar 4 17:36:04 2003
+++ sim/sh/gencode.c Tue Mar 4 17:35:57 2003
@@ -577,12 +577,11 @@ op tab[] =3D
},
=20
{ "", "nm", "mac.l @<REG_M>+,@<REG_N>+", "0000nnnnmmmm1111",
- "trap (255,R0,memory,maskl,maskw, endianw);",
- "/* FIXME: mac.l support */",
+ "macl(&R0,memory,n,m);",
},
=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.orig.c Mon Mar 3 11:37:56 2003
+++ sim/sh/interp.c Tue Mar 4 17:30:01 2003
@@ -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)))
@@ -1335,6 +1337,57 @@ macw (regs, memory, n, m, endianw)
MACH =3D (mach & 0x1ff) | -(mach & 0x200);
}
MACL =3D sum;
+}
+
+static void
+macl (regs, memory, n, m)
+ int *regs;
+ unsigned char *memory;
+ int m, n;
+{
+ long tempm, tempn;
+ long prod, macl, mach, sum;
+ long long ans,ansl,ansh,t;
+ unsigned long long high,low,combine;
+ union mac64
+ {
+ long m[2]; /* mach and macl*/
+ long long m64; /* 64 bit MAC */
+ }mac64;
+
+ tempm =3D RSLAT(regs[m]);
+ regs[m] +=3D 4;
+
+ tempn =3D RSLAT(regs[n]);
+ regs[n] +=3D 4;
+
+
+ mach =3D MACH;
+ macl =3D MACL;
+
+ mac64.m[0] =3D macl;
+ mac64.m[1] =3D mach;
+
+ ans =3D (long long)tempm * (long long)tempn; /* Multiply 32bit * 32bit =
*/
+
+ mac64.m64 +=3D ans; /* Accumulate 64bit + 64 bit */
+
+ macl =3D mac64.m[0];
+ mach =3D mac64.m[1];
+
+ if (S) /* Store only 48 bits of the result */
+ {
+ if(mach < 0) /* Result is negative */
+ {
+ mach =3D mach & 0x0000ffff; /* Mask higher 16 bits */
+ mach |=3D 0xffff8000; /* Sign extend higher 16 bits */
+ }
+ else
+ mach =3D mach & 0x00007fff; /* Postive Result */
+ }
+
+ MACL =3D macl;
+ MACH =3D mach;
}
=20
static struct loop_bounds
=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.gnush.com and http://www.gnuh8.com
Latest versions of GNUSH and GNUH8 are released on January 31, 2003.
-------------------------------------------------------------------------=
----=20
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: