Positron Compiler Documentation

Multiply High '**'

Positron16 · Revision 1.1.3.5 · PDF page 79

Assignment Variable = Variable ** Variable

Multiplies 8 or 16-bit unsigned variables and/or constants, returning the high 16 bits of the result. For compatibility with the old BASIC Stamp modules.

Variables may be constants, variables or expressions. Assignment Variable can be any valid variable type.

When multiplying two 16-bit values, the result can be as large as 32 bits. Since the largest variable supported by the compiler is 16-bits, the highest 16 bits of a 32-bit multiplication result are normally lost. The ** (double-star) operand produces these upper 16 bits.

For example, suppose 65000 ($FDE8) is multiplied by itself. The result is 4,225,000,000 or $FBD46240. The * (star, or normal multiplication) instruction would return the lower 16 bits, $6240. The ** instruction returns $FBD4.

Device = 24FJ64GA002           ' Select the device to compile for
Declare Xtal = 16      ' Tell the compiler the device will be operating at 16MHz

Declare Hserial1_Baud = 9600
Declare Hrsout1_Pin = PORTB.14

Dim MyWord1 as Word
Dim MyWord2 as Word

PPS_Output(cOut_Pin_RP14, cOut_Fn_U1TX)  ' Make Pin RB14 U1TX

MyWord1 = $FDE8
MyWord2 = MyWord1 ** MyWord1   ' Multiply $FDE8 by itself
HrsoutLn Hex MyWord2            ' Return high 16 bits.

This operator enables compatibility with BASIC Stamp code, and melab's compiler code, but is rather obsolete considering the 32-bit capabilities of the Positron16 compiler.

View original PDF page 79Open page in PDFOriginal PDF page 79