From 428f274f4333633963f335805c19ba504275143c Mon Sep 17 00:00:00 2001 From: Radu Rendec Date: Tue, 23 Aug 2011 13:59:57 +0300 Subject: [PATCH] Simulator: fix word write on unaligned address When writing a word to an unaligned address, the least significant bit is simply ignored, causing the real write address to be automatically aligned. Signed-off-by: Radu Rendec --- sim.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sim.c b/sim.c index adf8f09..b775348 100644 --- a/sim.c +++ b/sim.c @@ -47,8 +47,8 @@ struct sim_device { ((dev)->memory[(offset + 1) & 0xffff] << 8)) #define MEM_SETW(dev, offset, value) \ do { \ - (dev)->memory[offset] = (value) & 0xff; \ - (dev)->memory[(offset + 1) & 0xffff] = (value) >> 8; \ + (dev)->memory[offset & ~1] = (value) & 0xff; \ + (dev)->memory[offset | 1] = (value) >> 8; \ } while (0); static int fetch_operand(struct sim_device *dev,