From c901f282bbebeb5d91ed7168616938efdc231955 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Mon, 27 Aug 2018 12:17:22 -0230 Subject: [PATCH] A few micro-optimizations in the 6502 emulation (found by cppcheck). --- src/emucore/M6502.ins | 24 ++++++++++++------------ src/emucore/M6502.m4 | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/emucore/M6502.ins b/src/emucore/M6502.ins index c9e99e456..58cd8d53e 100644 --- a/src/emucore/M6502.ins +++ b/src/emucore/M6502.ins @@ -616,10 +616,10 @@ case 0x4b: // Set carry flag according to the right-most bit C = A & 0x01; - A = (A >> 1) & 0x7f; + A >>= 1; notZ = A; - N = A & 0x80; + N = 0; } break; @@ -2671,10 +2671,10 @@ case 0x4a: // Set carry flag according to the right-most bit C = A & 0x01; - A = (A >> 1) & 0x7f; + A >>= 1; notZ = A; - N = A & 0x80; + N = 0; } break; @@ -2689,11 +2689,11 @@ case 0x46: // Set carry flag according to the right-most bit in value C = operand & 0x01; - operand = (operand >> 1) & 0x7f; + operand >>= 1; poke(operandAddress, operand, DISASM_WRITE); notZ = operand; - N = operand & 0x80; + N = 0; } break; @@ -2709,11 +2709,11 @@ case 0x56: // Set carry flag according to the right-most bit in value C = operand & 0x01; - operand = (operand >> 1) & 0x7f; + operand >>= 1; poke(operandAddress, operand, DISASM_WRITE); notZ = operand; - N = operand & 0x80; + N = 0; } break; @@ -2728,11 +2728,11 @@ case 0x4e: // Set carry flag according to the right-most bit in value C = operand & 0x01; - operand = (operand >> 1) & 0x7f; + operand >>= 1; poke(operandAddress, operand, DISASM_WRITE); notZ = operand; - N = operand & 0x80; + N = 0; } break; @@ -2749,11 +2749,11 @@ case 0x5e: // Set carry flag according to the right-most bit in value C = operand & 0x01; - operand = (operand >> 1) & 0x7f; + operand >>= 1; poke(operandAddress, operand, DISASM_WRITE); notZ = operand; - N = operand & 0x80; + N = 0; } break; diff --git a/src/emucore/M6502.m4 b/src/emucore/M6502.m4 index 8b6f7d98a..dd1ce577e 100644 --- a/src/emucore/M6502.m4 +++ b/src/emucore/M6502.m4 @@ -482,10 +482,10 @@ define(M6502_ASR, `{ // Set carry flag according to the right-most bit C = A & 0x01; - A = (A >> 1) & 0x7f; + A >>= 1; notZ = A; - N = A & 0x80; + N = 0; }') define(M6502_BIT, `{ @@ -691,21 +691,21 @@ define(M6502_LSR, `{ // Set carry flag according to the right-most bit in value C = operand & 0x01; - operand = (operand >> 1) & 0x7f; + operand >>= 1; poke(operandAddress, operand, DISASM_WRITE); notZ = operand; - N = operand & 0x80; + N = 0; }') define(M6502_LSRA, `{ // Set carry flag according to the right-most bit C = A & 0x01; - A = (A >> 1) & 0x7f; + A >>= 1; notZ = A; - N = A & 0x80; + N = 0; }') define(M6502_LXA, `{