gianlucag / mos6502

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

use bitwise AND #22

Closed AsaiYusuke closed 1 year ago

AsaiYusuke commented 1 year 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 1 year ago

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