Aries
New Member
I won't try to explain how I ended up here, but code something like this gives unexpected results when actually run on a 20X2:
The simulator does this:
But the 20X2 itself does this:
I had expected (a) both simulator and chip to give the same results and (b) ptr to overflow automatically at 128 (or a multiple thereof), going back to zero. In fact, the 20X2 goes back to the number it first thought of (256 in this case). There are clearly some other subtleties (for example, starting at 389 actually starts at 261), but it certainly does not work consistently or - I suspect - as intended.
Code:
#picaxe 20x2
for w12 = 0 to 2
w10 = 128 * w12
w11 = 2
gosub PrintPTR
next w12
end
PrintPTR:
ptr = w10
sertxd(13,10,"Print PTR")
do
sertxd(13,10,#ptr," ",#@ptrinc)
loop until ptr = w11
sertxd(13,10,"End PTR")
return
Code:
Print PTR
0 0
1 0
End PTR
Print PTR
0 0
1 0
End PTR
Print PTR
0 0
1 0
End PTR
Code:
Print PTR
0 0
1 0
End PTR
Print PTR
0 0
1 0
End PTR
Print PTR
256 0
257 0
258 0
259 0
260 0
... etc