diff --git a/src/sim65/6502.c b/src/sim65/6502.c index cb4e579eb..48a1d560d 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -737,23 +737,29 @@ static unsigned HaveIRQRequest; /* ROL */ #define ROL(Val) \ - Val <<= 1; \ - if (GET_CF ()) { \ - Val |= 0x01; \ - } \ - TEST_ZF (Val); \ - TEST_SF (Val); \ - TEST_CF (Val) + do { \ + unsigned ShiftOut = (Val & 0x80); \ + Val <<= 1; \ + if (GET_CF ()) { \ + Val |= 0x01; \ + } \ + TEST_ZF (Val); \ + TEST_SF (Val); \ + SET_CF (ShiftOut); \ + } while (0) /* ROR */ #define ROR(Val) \ - if (GET_CF ()) { \ - Val |= 0x100; \ - } \ - SET_CF (Val & 0x01); \ - Val >>= 1; \ - TEST_ZF (Val); \ - TEST_SF (Val) + do { \ + unsigned ShiftOut = (Val & 0x01); \ + Val >>= 1; \ + if (GET_CF ()) { \ + Val |= 0x80; \ + } \ + TEST_ZF (Val); \ + TEST_SF (Val); \ + SET_CF (ShiftOut); \ + } while(0) /* ASL */ #define ASL(Val) \