How to put lowbyte of a Word to a Byte variable?
BS2 code:
rawValue VAR Word
ledValue VAR Byte
ledValue = rawValue.lowbyte·
How do I do the line
ledValue = rawValue.lowbyte
in SX/B?
That is, all I want is the lowbyte of a Word variable and store it into a Byte (so I can display it to 8 LEDs).
Thanks.
rawValue VAR Word
ledValue VAR Byte
ledValue = rawValue.lowbyte·
How do I do the line
ledValue = rawValue.lowbyte
in SX/B?
That is, all I want is the lowbyte of a Word variable and store it into a Byte (so I can display it to 8 LEDs).
Thanks.
Comments
rawVal· VAR tmpW1
ledVal· VAR tmpB1
ledVal = rawVal_lsb
Radio Shack Jim
Excerpt from my code:
LEDs PIN RC OUTPUT
tmpW1 VAR Word
tmpB1 VAR Byte
rawValue VAR tmpW1
ledValue VAR tmpB1
IF rawValue > 255 THEN
··· ledValue = 255
· ELSE
··· ledValue = rawValue_lsb
· ENDIF
·
· LEDs = ledValue
Where did you find out about the _lsb operator?· I've searched the Help Index, but don't find it there.·
And what others are there?· e.g.
Which of these would be allowed:
rawValue_msb
rawValue_lownib(0)
rawValue_lownib(1)
rawValue_lownib(2) etc.
·
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"A government big enough to give you everything you want, is big enough to take away everything you·have."·· Thomas Jefferson
"It is our choices, Harry, that show what we truly are, far more than our abilities."·Dumbledore from Harry Potter
www.iElectronicDesigns.com
·
I wonder where Radio Shack Jim found about the _lsb operator?
I don't see any mention of it anywhere.
I'll make sure that the creation of _LSB and _MSB aliases makes it into the help file as well.
You can learn a great deal about SX/B by looking through a list file of a compiled program; you can do it in the editor by pressing Ctrl-L; this will show you all the internal variables, constants, and how your variables are organized (including automatic aliases) and how you code compiles. SX/B takes a bit more work than the BS2, and there's not as much material yet for spoon feeding, but the effort is worth it with the power you gain from using the SX.
Post Edited (JonnyMac) : 8/29/2008 8:03:47 PM GMT