Parallax BASIC Stamp 2e Programming Manual page 56

Table of Contents

Advertisement

BASIC Stamp Architecture – Aliases and Modifiers
Symbol
LOWBYTE
HIGHBYTE
BYTE0
BYTE1
LOWNIB
HIGHNIB
NIB0
NIB1
NIB2
NIB3
LOWBIT
HIGHBIT
BIT0
BIT1
BIT2
BIT3
BIT4 ... BIT7
BIT8 ... Bit15
The commonsense rule for combining modifiers is that they must get
progressively smaller from left to right. It would make no sense to specify,
for instance, the low byte of a nibble, because a nibble is smaller than a
byte! And just because you can stack up modifiers doesn't mean that you
should unless it is the clearest way to express the location of the part you
want get at. The example above might be improved:
Rhino
VAR
WORD
Eye
VAR
Rhino.BIT9
Although we've only discussed variable modifiers in terms of creating
alias variables, you can also use them within program instructions:
Rhino
VAR
WORD
Head
VAR
Rhino.HIGHBYTE
Rhino = 13567
DEBUG ? Head
DEBUG ? Rhino.HIGHBYTE
STOP
Modifiers also work with arrays. For example:
MyBytes
VAR
BYTE(10)
MyBytes(0) = $AB
DEBUG HEX ? MyBytes.LOWNIB(0)
DEBUG HEX ? MyBytes.LOWNIB(1)
Page 54 • BASIC Stamp Programming Manual 2.0b • www.parallaxinc.com
Definition
low byte of a word
high byte of a word
byte 0 (low byte) of a word
byte 1 (high byte) of a word
low nibble of a word or byte
high nibble of a word or byte
nib 0 of a word or byte
nib 1 of a word or byte
nib 2 of a word
nib 3 of a word
low bit of a word, byte, or nibble
high bit of a word, byte, or nibble
bit 0 of a word, byte, or nibble
bit 1 of a word, byte, or nibble
bit 2 of a word, byte, or nibble
bit 3 of a word, byte, or nibble
bits 4 though 7 of a word or byte
bits 8 through 15 of a word
' A 16-bit variable.
' A bit.
' A 16-bit variable.
' Highest 8 bits of rhino.
' Show the value of alias variable Head.
' Rhino.HIGHBYTE works too.
' Define 10-byte array.
' Hex $AB into 0th byte
' Show low nib ($B)
' Show high nib ($A)
Table 4.3: BS2, BS2e, BS2sx and
BS2p Variable Modifiers.
2
2
2
2
e
p
sx

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?

Table of Contents