Display variable in binary using LEDs

Source Code: lesson5.spin
I have been going over the lessons for the quickstart board again and just to see what would happen, in the repeat line I substituted 255 for 256, expecting a compile error or some sort of error due to the LED variable being declared as only a byte but it compiled and ran ok and I noticed it had created an endless loop instead of stopping as before.
This seems a quick and easy way to get an endless loop but the question is will this "bad practice" cause problems in future programming? or is it an acceptable way of forcing a program not to stop? Am i heading for trouble doing it this way?
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 VAR byte LED PUB LedCounter ' Method declaration dira[16..23] := %1111_1111 ' Set P16 thru P23 to output repeat LED from 0 to 255 ' Repeat 256 times, counting forward(substituting 255 for 256 here causes an endless loop) outa[16..23] := LED ' Set display number in binary on LEDs waitcnt(clkfreq/8 + cnt) ' Wait a moment
I have been going over the lessons for the quickstart board again and just to see what would happen, in the repeat line I substituted 255 for 256, expecting a compile error or some sort of error due to the LED variable being declared as only a byte but it compiled and ran ok and I noticed it had created an endless loop instead of stopping as before.
This seems a quick and easy way to get an endless loop but the question is will this "bad practice" cause problems in future programming? or is it an acceptable way of forcing a program not to stop? Am i heading for trouble doing it this way?
Comments
This is simply a bug, we don' know if byte variable overflow doesn't cause any side effects, and this kind of programming should be avoided. Better add another loop. This is clean, simple and understandable.
The "1" in the dira mask need to be a binary number.
111111 is decimal.
Preface the 111111 with % in your code and all should be well.
Holy Cow! It did.
It also ate a couple of 1's off of the dira mask.
Thanks for pointing that out.
(I ain't saying it!)
One problem is that the post new thread button sends you to the advanced editor but the reply to post button doesn't I ended up having to switch off the advanced editor in settings! I will ask if anything can be done about it in the support section.