### local/remote address test in one instruction

Posted:

**Fri Sep 19, 2014 1:36 am**The basic test is that the top 12 bits are zero or non-zero:

This takes at least 3 instructions and a scratch register. load 0, load $fff0 << 16, and the and.

But the following does the same in one instruction and one scratch register:

i.e. lsr #20.

- Code: Select all
`if (((unsigned) ptr) & 0xfff00000) {`

/* is global/remote */

}

This takes at least 3 instructions and a scratch register. load 0, load $fff0 << 16, and the and.

But the following does the same in one instruction and one scratch register:

- Code: Select all
`if ((unsigned int)ptr) >> 20) {`

}

i.e. lsr #20.