Wierd byte alignment gotcha
Erik Friesen
Posts: 1,071
here is the code
If I use test4 everything is great. If I comment it out, loopcommand,loopgo, and test3 are a mirror into data[noparse][[/noparse]0-3]. Or more correctly said, data[noparse][[/noparse]0] equals loopcommand, data[noparse][[/noparse] 1] equals loopgo and data[noparse][[/noparse] 2] equals test3 when set from within spin as shown above.
note- once again the automatic forum deleter strikes again with the brackets shown above( why can't this be fixed?)
Post Edited (Erik Friesen) : 1/2/2009 12:10:14 AM GMT
VAR long flag,position,shiftdn,shiftrt,height,contrast,off word characterposition byte chartoprint,sizecolor,loopcommand,loopgo,test3',test4 byte data[noparse][[/noparse]totalsize+1] byte cols,col,rows,row,size,color,move PUB Start |q'no backlight waitcnt(5_000_000+cnt)'Wait for screen to stabilize contrast:=%100000 long[noparse][[/noparse]@data]:=@SL 'send address pointers long[noparse][[/noparse]@data+4]:=@Bl 'to assembly long[noparse][[/noparse]@data+8]:=@characterposition long[noparse][[/noparse]@data+12]:=@chartoprint cognew(@entry,@data) waitcnt(5_000_000+cnt) out($d) 'initialize with small size ) out(1) out(0) loopcommand:=1 loopgo:=1 str(string($d,1,"Hello how are you today I am fine thanks and you and what will I do if this doesn't work now?")) test3:=$FF 'test4:=$aa loopcommand:=$FF loopgo:=$aa 'repeat q from 0 to totalsize-1 'data[noparse][[/noparse]q]:=$AA repeat waitcnt(10000+cnt) return @data
If I use test4 everything is great. If I comment it out, loopcommand,loopgo, and test3 are a mirror into data[noparse][[/noparse]0-3]. Or more correctly said, data[noparse][[/noparse]0] equals loopcommand, data[noparse][[/noparse] 1] equals loopgo and data[noparse][[/noparse] 2] equals test3 when set from within spin as shown above.
note- once again the automatic forum deleter strikes again with the brackets shown above( why can't this be fixed?)
Post Edited (Erik Friesen) : 1/2/2009 12:10:14 AM GMT
Comments
if you insert a space right after the opening square-bracket it will be shown as written
best regards
Stefan
You can also use www.phipi.com/format to eliminate the square bracket problem.
-Phil
Still don't understand the mirror thing though.
long[noparse][[/noparse]@data]:=@SL 'send address pointers
The way you have your vars declared, you have a word, six bytes (if you include test4), and data. That puts data on a long boundary, so saying long[noparse][[/noparse]@data] works, but only by chance. Once you comment out test4, data is no longer long-aligned.