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 <radu.rendec@cloudbit.ro>
This commit is contained in:
Radu Rendec 2011-08-23 13:59:57 +03:00 committed by Daniel Beer
parent 2aed1b90a4
commit 428f274f43
1 changed files with 2 additions and 2 deletions

4
sim.c
View File

@ -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,