O
T
PL
I
S
G
E
H
H
T
A
T
O
G
N
M
N
I
T
B
T
A
T
S
U
I
P
C
P
S
S
A
T
A
P
M
P
P
P
R
L
O
I
J
E
C
C
T
S
,
A
H
T
I
I
N
T
S
O
&
T
N
I
P
S
S
■ BY JON WILLIAMS
SX/B TURNS SWEET 16
THERE ARE THOSE — THE PESSIMISTS AMONG US — that will insist that you
can’t get anything worthwhile for nothing; everything has a price. Not so with
SX/B. While it may not compete with big, “professional” compilers, in the right
hands (i.e., yours) and with a few tricks, SX/B is quite capable and costs
absolutely zero dollars. And with the cost of the SX-Key programming tool and
SX Proto Boards so low these days, it’s really hard to ignore the SX micro as a
viable solution to many design problems.
Truth be told, it’s easy for me to be a fan of SX/B because
I was part of the team that developed it. Still, those of
you who know me understand that I’m a very practical guy;
I don’t have a lot of time to fool around and when I need
something, I need it, and I need it to work. Since leaving
Parallax for new adventures, I have, in fact, continued to use
SX/B — I recently designed a camera controller using an
SX28 that was programmed entirely in SX/B 1.5x (no
assembly language required). My point is that SX/B wasn’t
developed simply for the sake of doing it; SX/B was developed to provide a practical, no-cost tool for SX developers.
■ FIGURE 1. DC motor with L293D.
12
September 2006
If you’ve never tried the SX, perhaps this article will
encourage you to do so. It really is hard to beat the cost
of entry: the SX-Key (ICP programming tool with full debugging capability) is only $79, the SX-Blitz (programming only,
great for students) is an incredible bargain at only $29, and
the fully-populated (power supply, SX chip, connectors)
SX48 Proto Board is only $10! Yes, ten bucks. Using the
Blitz, the SX48 Proto Board, a serial cable and a 12 VDC
power supply, you could get into SX programming for about
$50 — that’s really not a bad deal for all the horsepower
delivered by the SX.
SX/B 1.5X
The big news with version 1.5x is, of course, the
addition of Word (16-bit) variables. This is especially good
news for BS2 users wanting to port prototype projects to
the SX for high-volume production. As in PBASIC, we
declare a 16-bit variable in SX/B as type Word:
tmpW1
VAR
Word
When we look “under the hood” of SX/B (use Ctrl+L to
compile and view the listing), we’ll see that the definition
above is actually composed of two bytes:
tmpW1
tmpW1_LSB
tmpW1_MSB
EQU
EQU
EQU
0x0D
tmpW1
tmpW1+1
Note that the value is stored “Little Endian” (low byte first)
and that in addition to the name we declare, the compiler
creates definitions with the suffixes _LSB and _MSB; these
byte variables can be used just as we would use the
tmp W1.LOWBT YE and tmp W1.HIGHBYTE notation in PBASIC.
Word variables can be used exactly as we’d expect —
and even in a few ways that we might not consider at the