4: BASIC Stamp Architecture – Aliases and Modifiers
2
2
e
T
M
M
HE
EMORY
AP
2
2
If you looked closely at that example, you probably thought it was a
p
sx
misprint. Shouldn't MyBytes.LOWNIB(1) give you the low nibble of byte 1
of the array rather than the high nibble of byte 0? Well, it doesn't. The
modifier changes the meaning of the index value to match its own size. In
the example above, when MyBytes() is addressed as a byte array, it has 10
byte-sized cells numbered 0 through 9. When it is addressed as a nibble
array, using MyBytes.LOWNIB(), it has 20 nibble-sized cells numbered 0
through 19. You could also address it as individual bits using
MyBytes.LOWBIT(), in which case it would have 80 bit-sized cells
numbered 0 through 79.
What if you use something other than a "low" modifier, say
MyBytes.HIGHNIB()? That will work, but its effect will be to start the
nibble array with the high nibble of MyBytes(0). The nibbles you address
with this nib array will all be contiguous, one right after the other, as in the
previous example.
MyBytes
VAR
MyBytes(0) = $AB
MyBytes(1) = $CD
DEBUG HEX ? MyBytes.highnib(0)
DEBUG HEX ? MyBytes.highnib(1)
This property of modified arrays makes the names a little confusing. If you
prefer, you can use the less-descriptive versions of the modifier names;
BIT0 instead of LOWBIT, NIB0 instead of LOWNIB, and BYTE0 instead of
LOWBYTE. These have exactly the same effect, but may be less likely to be
misconstrued.
You may also use modifiers with the 0th cell of an array by referring to
just the array name without the index value in parentheses. It's fair game
for aliases and modifiers, both in VAR directives and in instructions.
On the BS2, BS2e, BS2sx and BS2p, if you're working on a program and
wondering how much variable space you have left, you can use the
memory map feature of the editor (ALT-M in the DOS editor and CTRL-M
in the Windows editor). See the "Memory Map" section of the "Using the
BASIC Stamp Editor" chapter for more information.
BYTE(10)
BASIC Stamp Programming Manual 2.0c • www.parallaxinc.com • Page 55
' Define 10-byte array.
' Hex $AB into 0th byte
' Hex $CD into next byte
' Show high nib of cell 0 ($A)
' Show next nib ($D)
Need help?
Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?