[FT32] sim: correct simulation of MEMCPY and MEMSET

Message ID CA9BBF0458F83C4F9051448B941B57D11A267D50@glaexch1
State Committed
Headers

Commit Message

James Bowman Sept. 29, 2015, 11:47 p.m. UTC
  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.
  

Comments

Mike Frysinger Sept. 30, 2015, 3:39 a.m. UTC | #1
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
  

Patch

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;