gianlucag / mos6502

A fast & simple MOS 6502 CPU emulator written in C++
MIT License
286 stars 56 forks source link

use bitwise AND #22

Closed AsaiYusuke closed 9 months ago

AsaiYusuke commented 11 months ago

I've replaced the modulo operator (%) with a bitwise AND operation in the relevant sections of the code. Upon reviewing the source code, it appears that using AND provides a more consistent and unified approach compared to calculating the remainder. It's worth noting that there are articles suggesting that, in terms of performance, there might not be a significant difference between the two notations when using recent compilers, although I'm not entirely certain about this.

gianlucag commented 9 months ago

Agreed. %256 and (no pun intended) &0xFF get assembled the same. However, &0xFF is even more clear, at least in this context.