PBASIC bit manipulation!!
thegrim
Posts: 5
can somebody tell me qhere can i find a good resource to learn how to manipulate bits with the pbasic language.
Comments
· myVal = myVal | 128··· ' force bit 7 high
... whereas in PBASIC 2.x you can do this:
· myVal.BIT7 = 1
Your question is very wide open.· What kinds of things are you looking to do?· If it's just curiosity, read through section four of the manual and scan our books and code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
i wasnt clear at all, i want to learn how to manipulate bits in the way of make shifts(left and right) , rotate and all those things that can be done in other high level languages but like an introductoin in pbasic language.
myValue··· VAR·· Byte
carry······VAR·· Bit
Main:
· myValue = %11000000
· ' rotate left
· carry = myValue.BIT7
· myValue = myValue << 1
··myValue.BIT0 = carry
· ' display -- should be %10000001
· DEBUG BIN8 myValue
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Now, I must tell you I worked and worked, looked and looked, for nearly 2 hours... and finally, trimphuantly discovered.... the exact same code as you just casually posted... LOL... I had to work for it, so now I guess I'll remember it better, eh?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Until our bytes cross again, may your chips never smoke, your bits never fall off, your parts bin never be empty and your jumpers never fall off.
KK
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Here are a few links to get you going:
http://www.parallax.com/dl/docs/prod/stamps/web-BSM-v2.2.pdf
http://www.parallax.com/html_pages/edu/curriculum/sic_curriculum.asp
http://www.parallax.com/dl/docs/books/sw/Web-sw-v2.0.pdf
Have fun!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax