Calculated timeout from repeat loop
I'm a bit lost on the best way to handle a timeout from a repeat loop. Basically, I'd like to repeat until a condition is true, or a timeout period has elapsed. My trouble is handling a clock wraparound.
Example :
This will work perfectly fine, as long as cnt + _syncTimeout is less than $7FFF_FFFF. If not, it causes tout to be evaluated improperly. I've been thinking about the best way to do this and still drawing a blank. Any help would be greatly appreciated as always!
Example :
PRI GetMark | tout
tout := _syncTimeout
tout += cnt
repeat
RX(@d)
until GetPacketType == _mark or (cnt > tout)
This will work perfectly fine, as long as cnt + _syncTimeout is less than $7FFF_FFFF. If not, it causes tout to be evaluated improperly. I've been thinking about the best way to do this and still drawing a blank. Any help would be greatly appreciated as always!

Comments
PRI GetMark | tout tout := cnt repeat RX(@d) until GetPacketType == _mark or ((cnt - tout) > _syncTimeout)t0 := -cnt repeat ' do something elapsed := t0 + cnt if (elapsed => TIME_OUT) return TO_CODE