Casting and pointer quirk
mirror
Posts: 322
It seems that if you have the following program:·
I thought that the final option was OK - but it's not. I can't figure out where it gets its value from. I thought I'd post this for anyone not quite understanding the behaviour of some code they've written.
·
VAR long val byte v[noparse][[/noparse]2] PUB Start v[noparse][[/noparse]0] := $10 v[noparse][[/noparse]1] := $01 val := v[noparse][[/noparse]0] + (v[noparse][[/noparse]1] << 8) 'val == $0110 val := word[noparse][[/noparse]@v[noparse][[/noparse]0]][noparse][[/noparse]0] 'val == $0110 val := word[noparse][[/noparse]@v][noparse][[/noparse]0] 'val == $0110 val := word[noparse][[/noparse]v][noparse][[/noparse]0] 'val gets some random value
I thought that the final option was OK - but it's not. I can't figure out where it gets its value from. I thought I'd post this for anyone not quite understanding the behaviour of some code they've written.
·
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.