BS2 Nibbles for SX/B ?? How can it be done.
I have a BS2 program I am trying to convert over to SX/B. However, it uses nibbles. I thought there was a _LSB and _MSB command variable that can be used but I think that may only work on WORDs (down to bytes - not nibbles).
'BS2 code
secs············ VAR···· Byte··················· ' seconds
secs01········· VAR···· secs.LOWNIB
secs10········· VAR···· secs.HIGHNIB
I tried in SX/B the following - errors (as expected):
secs············ VAR···· Byte··················· ' seconds
secs01········· VAR···· secs_LSB
secs10········· VAR···· secs_MSB
What is the equivalent in SX/B?
'BS2 code
secs············ VAR···· Byte··················· ' seconds
secs01········· VAR···· secs.LOWNIB
secs10········· VAR···· secs.HIGHNIB
I tried in SX/B the following - errors (as expected):
secs············ VAR···· Byte··················· ' seconds
secs01········· VAR···· secs_LSB
secs10········· VAR···· secs_MSB
What is the equivalent in SX/B?
Comments
secs0001 = secs.0
secs0010 = secs.1
secs0100 = secs.2
secs1000 = secs.3
Checkout the "SX/B Defintions" chapter in the SX/B online help.
The nibble is not a standard variable type, I believe it was used on the BS2 to save RAM.
You'll have to seperate the values in the code:
GetSecs
Secs01 = Secs AND $0F
Secs10 = Secs >> 4
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Educate your children to self-control, to the habit of holding passion and prejudice and evil tendencies subject to an upright and reasoning will, and you have done much to abolish misery from their future and crimes from society"
Benjamin Franklin
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
Is GetSecs a label or something (e.g. GetSecs: )?
Should it be like this?
Secs············ VAR···· Byte··················· ' Seconds
Secs01········· VAR···· Secs
Secs10··········VAR·····Secs
GetSecs:
Secs01 = Secs AND $0F······················ ' Secs01 = %xxxx1111
Secs10 = Secs >> 4··························· ' Secs10 = %1111xxxx
Post Edited (T&E Engineer) : 3/24/2007 12:34:23 PM GMT
will always return 0 (because the preceding line stripped off the upper nibble). Unfortunately, the ease-of-use of the BASIC Stamp and its great language features have made many of us lazy and that shows up when we switch to a core processor like the SX. The great thing about SX/B, however, is that it's easy to extend the language via subroutines and functions. I do this:
... and then code those functions like this (both accept and return one byte):
Note on DEC2BCD: You have to be careful about using __REMAINDER; this code works because the SWAP instruction does not modify __PARAM1 (an alias of __REMAINDER) -- you will usually use __REMAINDER immediately after the division. I've tested these routines with values 0..99 and $0..$99 -- they work.
Post Edited (JonnyMac) : 3/24/2007 3:57:19 PM GMT