From eacf4b8be41e2117215ab4a64291fa2aa0b78157 Mon Sep 17 00:00:00 2001 From: Daniel Beer Date: Tue, 26 Mar 2013 09:25:33 +1300 Subject: [PATCH] sim: fix PC-relative operand fetch. Index should be relative to the value of PC after fetching the index word. --- drivers/sim.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/sim.c b/drivers/sim.c index b1f0d41..ed7ce4d 100644 --- a/drivers/sim.c +++ b/drivers/sim.c @@ -100,10 +100,10 @@ static int fetch_operand(struct sim_device *dev, } addr = MEM_GETW(dev, dev->regs[MSP430_REG_PC]); + dev->regs[MSP430_REG_PC] += 2; + if (reg != MSP430_REG_SR) addr += dev->regs[reg]; - - dev->regs[MSP430_REG_PC] += 2; break; case MSP430_AMODE_INDIRECT: