Specifications
BASIC Stamp II
Page 242 • BASIC Stamp Programming Manual 1.8 • Parallax, Inc.
w1 = $FDE8
w2 = w1 ** w1 ' Multiply $FDE8 by itself
debug hex ? w2 ' Return high 16 bits.
*/
Multiplies variables and/or constants, returning the middle 16 bits of
the 32-bit result. This has the effect of multiplying a value by a whole
number and a fraction. The whole number is the upper byte of the
multiplier (0 to 255 whole units) and the fraction is the lower byte of
the multiplier (0 to 255 units of 1/256 each). The */ (star-slash) instruc-
tion gives you an excellent workaround for the BS2’s integer-only math.
Suppose you want to multiply a value by 1.5. The whole number, and
therefore the upper byte of the multiplier, would be 1, and the lower
byte (fractional part) would be 128, since 128/256 = 0.5. It may be clearer
to express the */ multiplier in hex—as $0180—since hex keeps the con-
tents of the upper and lower bytes separate. An example:
w1 = 100
w1 = w1 */ $0180 ' Multiply by 1.5 [1 + (128/256)]
debug ? w1 ' Show result (150).
To calculate constants for use with the */ instruction, put the whole
number portion in the upper byte, then multiply the fractional part by
256 and put that in the lower byte. For instance, take Pi (π, 3.14159).
The upper byte would be $03 (the whole number), and the lower would
be 0.14159 * 256 = 36 ($24). So the constant Pi for use with */ would be
$0324. This isn’t a perfect match for Pi, but the error is only about 0.1%.
MIN
Limits a value to a specified 16-bit positive minimum. The syntax of
MIN is:
value MIN limit
Where:
• value is value to perform the MIN function upon.
• limit is the minimum value that value is allowed to be.










