Firstly you cannot have a single 32 bit variable defined in PICBasic so we define two 16 bit variables...

xlow var word ' as the lower bits 15-0
xhigh var word ' as the upper bits 31-16

together xhigh and xlow make up your 32 bits...

Now consider this...

xlow=xlow+i
if xlow < i then xhigh=xhigh+1

here we assume that variable i is also a word...

If the addition of variable i to xlow (the lower 16 bits of our 32 bit word) causes an overflow within xlow, the resultant will be less than variable i itself. If this occurs then simply carry 1 to the upper 16 bits residing in xhigh.

Melanie