Hi Ross,
Anything can be done, it just a matter of how much code is required.
here is a full programme that will run in GP32 simulator.
Code:
org $40num rmb 4 ;4 bytes of storage org $8000start clr num ;clear storage clr num+1 clr num+2 clr num+3 loop lda num+3 sta $FFFF ;reset COP add #$FE ;add 254 sta num+3 bcc loop inc num+2 bne loop inc num+1 bne loop inc num lda num ;test MSByte cmp #6 ;for $06 bne loop ;loop back if not equalend sta $FFFF ;reset COP bra end ;loop here when finished org $FFFE ;reset vector dw start