27220 Parallax Inc, 27220 Datasheet - Page 223

BOOK STAMPWORKS

27220

Manufacturer Part Number
27220
Description
BOOK STAMPWORKS
Manufacturer
Parallax Inc
Datasheet

Specifications of 27220

Accessory Type
Booklet
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
StampWorks
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Not applicable / Not applicable
The second declaration consumes no more variable space than the first, but allows
access to all flags with one line of code:
This saves program space and improves execution speed because the PBASIC
interpreter only has to fetch one instruction from the program EEPROM, whereas the
previous declaration would require separate lines of code to set both variables; each
line requires access to the program EEPROM and affects program speed. Yes, this
seems like a very small thing, but remember: a lot of small things in a program add
up to better performance.
Learn to Use the Variable Modifiers
Another common question is, “How can I convert from BCD to decimal, and then
back?”
techniques, the use of PBASIC variable modifiers makes it much simpler. First, let’s
convert a variable from BCD to decimal:
How easy is that? Since BCD uses nibbles for digit storage, this seems to be the
most obvious solution yet many programmers user more complicated code for not
mastering variable modifiers. Going the other direction (decimal to BCD) is equally
easy:
Another useful variable modifier is the LOWBIT() array. This modifier lets us access
any bit inside any variable using a variable index. If, for example, you needed to
count the number of set bits in a Word, you could do it like this:
flags = 0
Count_Bits:
decVal = bcdVal.NIB1 * 10 + bcdVal.NIB0
bcdVal = ((decVal DIG 1) << 4) + (decVal DIG 0)
bitCount = 0
FOR idx = 0 TO 15
NEXT
While these conversions can be done with standard programming
bitCount = bitCount + wordVar.LOWBIT(idx)

Related parts for 27220