do - loop is thist a bug?

elektriker

New Member
Code:
symbol x = w5
pause 500

for x = 0 to 65438 step 777
     sertxd(#w5, cr, lf)
next x

sertxd("E N D", cr, lf)
This loop repeats 3 times !
 
Last edited by a moderator:

geoff07

Senior Member
When I use the PE5 simulator it works as expected. Some more info regarding your test conditions would help.
 

hippy

Ex-Staff (retired)
Seems to work as expected for me in PE5 (5.5.6) and PE6.

I do note your post is entitled "do - loop is this a bug?" yet there is no do-loop in the code.
 

elektriker

New Member
hippy you are right, the title shot be "for-next is this a Bug?".

With Simulator PE 5.5.6 and PE6 it works right (0-84) ,
but when I prog. the Chip 08M2+ or 14M2 the Loop repeats 3 times * 84 (0-252) see the Txtfile.

Please have a look to the files and prog a real Chip.


Thanks
Werner
 

Attachments

hippy

Ex-Staff (retired)
Thanks for clarifying.

It does seem there is a difference between how simulation and a real chip handles wrap-round overflow in a FOR-NEXT.
 

srnet

Senior Member
Is it the case that the simulator exits the for\next loop when the 'to' limit is exceeded, rather than overflowing and exiting when x actually does equal 65438 ?
 

techElder

Well-known member
For one thing, in case you are reading your output to make a determination of a problem, your code is printing out "#w5" instead of "x".
 

Technical

Technical Support
Staff member
for x = 0 to 65438 step 777
It is the chip that is correct:

Code:
 N=  81       62937
 N=  82       63714
 N=  83       64491
 N=  84       65268     <<<<<< 1      
 N=  85       509
 N=  86       1286
None of these numbers, due to the overflow, are bigger than 65438, hence another 'loop' starts.

The PE6 simulator issue is that it is allowing (65268 + 777) > 65438 to return true, thanks for letting us know, we will correct this bug in the next software update.
It should be using ( (65268 + 777) AND 65535) > 65438
 
Top