aboutsummaryrefslogtreecommitdiff
path: root/sim/msp430
diff options
context:
space:
mode:
authorJozef Lawrynowicz <jozef.l@mittosystems.com>2020-01-22 21:44:54 +0000
committerJozef Lawrynowicz <jozef.l@mittosystems.com>2020-01-22 21:52:29 +0000
commitb7dcc42dfde12c3a1ccb7149b3cf8ef2f0992ea3 (patch)
treec2a177ad023f97f05bedfaa9271e035e371d6a09 /sim/msp430
parentbe4c5e58bdc839898739e0332aee84abf6e5299a (diff)
downloadgdb-b7dcc42dfde12c3a1ccb7149b3cf8ef2f0992ea3.zip
gdb-b7dcc42dfde12c3a1ccb7149b3cf8ef2f0992ea3.tar.gz
gdb-b7dcc42dfde12c3a1ccb7149b3cf8ef2f0992ea3.tar.bz2
MSP430: Fix simulator execution of RRUX instruction
The MSP430X RRUX instruction (unsigned right shift) is synthesized as the RRC (rotate right through carry) instruction, but with the ZC (zero carry) bit of the opcode extention word set. Ensure the carry flag is ignored when the ZC bit is set. sim/msp430/ChangeLog: 2020-01-22 Jozef Lawrynowicz <jozef.l@mittosystems.com> * msp430-sim.c (msp430_step_once): Ignore the carry flag when executing an RRC instruction, if the ZC bit of the extension word is set. sim/testsuite/sim/msp430/ChangeLog: 2020-01-22 Jozef Lawrynowicz <jozef.l@mittosystems.com> * rrux.s: New test.
Diffstat (limited to 'sim/msp430')
-rw-r--r--sim/msp430/ChangeLog5
-rw-r--r--sim/msp430/msp430-sim.c6
2 files changed, 9 insertions, 2 deletions
diff --git a/sim/msp430/ChangeLog b/sim/msp430/ChangeLog
index 324a6fc..0f27982 100644
--- a/sim/msp430/ChangeLog
+++ b/sim/msp430/ChangeLog
@@ -1,3 +1,8 @@
+2020-01-22 Jozef Lawrynowicz <jozef.l@mittosystems.com>
+
+ * msp430-sim.c (msp430_step_once): Ignore the carry flag when executing
+ an RRC instruction, if the ZC bit of the extension word is set.
+
2017-09-06 John Baldwin <jhb@FreeBSD.org>
* configure: Regenerate.
diff --git a/sim/msp430/msp430-sim.c b/sim/msp430/msp430-sim.c
index cdb8eab..e21c8cf 100644
--- a/sim/msp430/msp430-sim.c
+++ b/sim/msp430/msp430-sim.c
@@ -1292,8 +1292,10 @@ msp430_step_once (SIM_DESC sd)
u1 = SRC;
carry_to_use = u1 & 1;
uresult = u1 >> 1;
- if (SR & MSP430_FLAG_C)
- uresult |= (1 << (opcode->size - 1));
+ /* If the ZC bit of the opcode is set, it means we are synthesizing
+ RRUX, so the carry bit must be ignored. */
+ if (opcode->zc == 0 && (SR & MSP430_FLAG_C))
+ uresult |= (1 << (opcode->size - 1));
TRACE_ALU (MSP430_CPU (sd), "RRC: %#x >>= %#x",
u1, uresult);
DEST (uresult);