I am having difficulty determining whether or not two addresses are on the same page. First let me define a page.
A page is an area in memory that is 255 bytes. The first page (or called zero page) is in this range:
0x0000-0x00FF
The second page would be in this range:
0x0100-0x01FF
and so on...
NOTE: addresses will range from 0x0000-0xFFFF
I need to write a quick algorithm to determine whether two addresses, lets say 0x0148 and 0x0192 are in the same page (which in this example they are).
I could do something easy like comparing the upper and lower bounds of both addresses to a page to determine if they are all equal to 1 (hence four operations, two for each address.. four if statements but way too much code) but I need something very fast because this piece of code will be executed the most. Any one have any ideas on this? Thanks.