EasyManua.ls Logo

Parallax BASIC Stamp 2e - Page 57

Default Icon
353 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
4: BASIC Stamp Architecture Aliases and Modifiers
BASIC Stamp Programming Manual 2.0c www.parallaxinc.com Page 55
If you looked closely at that example, you probably thought it was a
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 BYTE(10) ' Define 10-byte array.
MyBytes(0) = $AB ' Hex $AB into 0th byte
MyBytes(1) = $CD ' Hex $CD into next byte
DEBUG HEX ? MyBytes.highnib(0) ' Show high nib of cell 0 ($A)
DEBUG HEX ? MyBytes.highnib(1) ' Show next nib ($D)
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.
2
e
2
sx
2
p
2
THE MEMORY MAP

Table of Contents

Related product manuals