Spin questions
John Abshier
Posts: 1,116
I don't understand part of sign-extend.· Given the following code fragement:
CON
· _clkmode = xtal1 + pll16x
· _xinfreq = 5_000_000
var
· word·· x, z
· long·· y
PUB Start
· x := -300
· y := ~~x + 50
I understand the part of sign extending to make y equal -250.· I don't understand the sing-extend being an assignment operator.· x is declared a 16 bit variable.· Where is the 32 bit sign-extended result stored? Is x a long after execution of the last line?
What does "Param|RValue|LocalValue must be globally unique, but other methods may also use the same symbol name." mean?· Does it mean that the symbol cannot be the same as a global variable, but the names can be reused from method to method?
CON
· _clkmode = xtal1 + pll16x
· _xinfreq = 5_000_000
var
· word·· x, z
· long·· y
PUB Start
· x := -300
· y := ~~x + 50
I understand the part of sign extending to make y equal -250.· I don't understand the sing-extend being an assignment operator.· x is declared a 16 bit variable.· Where is the 32 bit sign-extended result stored? Is x a long after execution of the last line?
What does "Param|RValue|LocalValue must be globally unique, but other methods may also use the same symbol name." mean?· Does it mean that the symbol cannot be the same as a global variable, but the names can be reused from method to method?
Comments
Edit: Wrong, wrong wrong! (see Chip's post) Only when the ~~ operator is used on a line by itself is it an assignment operator. So in your example, the value of x isn't changed. The 32-bit sign-extended result is stored in a temporary location during the evaluation of the expression.
I'm not sure what the answer is to the second half of your message. It does sound self-contradictory. But that's something the compiler should catch for you, so you can probably figure it out by experimenting a little.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
links:
My band's website
Our album on the iTunes Music Store
Post Edited (SSteve) : 7/6/2006 3:04:00 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chip Gracey
Parallax, Inc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
links:
My band's website
Our album on the iTunes Music Store
Post Edited (SSteve) : 7/6/2006 3:05:33 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
links:
My band's website
Our album on the iTunes Music Store