Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH, FT32] sim: correct simulation of MEMCPY and MEMSET
@ 2015-09-29 23:48 James Bowman
  2015-09-30  3:40 ` Mike Frysinger
  0 siblings, 1 reply; 2+ messages in thread
From: James Bowman @ 2015-09-29 23:48 UTC (permalink / raw)
  To: gdb-patches

The MEMCPY and MEMSET instructions should only examine the low 15 bits of
their length arguments.

OK to apply?

[sim/ft32]

2015-09-28  James Bowman  <james.bowman@ftdichip.com>

	* interp.c (step_once): correct length for MEMSET and MEMCPY
	instructions.

diff --git a/sim/ft32/interp.c b/sim/ft32/interp.c
index a20907c..ed50b0e 100644
--- a/sim/ft32/interp.c
+++ b/sim/ft32/interp.c
@@ -598,7 +598,7 @@ step_once (SIM_DESC sd)
 	    uint32_t src = r_1v;
 	    uint32_t dst = cpu->state.regs[r_d];
 	    uint32_t i;
-	    for (i = 0; i < rimmv; i++)
+	    for (i = 0; i < (rimmv & 0x7fff); i++)
 	      PUT_BYTE (dst + i, GET_BYTE (src + i));
 	  }
 	  break;
@@ -617,7 +617,7 @@ step_once (SIM_DESC sd)
 	    /* memset instruction.  */
 	    uint32_t dst = cpu->state.regs[r_d];
 	    uint32_t i;
-	    for (i = 0; i < rimmv; i++)
+	    for (i = 0; i < (rimmv & 0x7fff); i++)
 	      PUT_BYTE (dst + i, r_1v);
 	  }
 	  break;


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

* Re: [PATCH, FT32] sim: correct simulation of MEMCPY and MEMSET
  2015-09-29 23:48 [PATCH, FT32] sim: correct simulation of MEMCPY and MEMSET James Bowman
@ 2015-09-30  3:40 ` Mike Frysinger
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger @ 2015-09-30  3:40 UTC (permalink / raw)
  To: James Bowman; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 232 bytes --]

On 29 Sep 2015 23:47, James Bowman wrote:
> The MEMCPY and MEMSET instructions should only examine the low 15 bits of
> their length arguments.

pushed, thanks !

btw you should really be adding test cases for these fixes ...
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2015-09-30  3:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-29 23:48 [PATCH, FT32] sim: correct simulation of MEMCPY and MEMSET James Bowman
2015-09-30  3:40 ` Mike Frysinger

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