Mul (multiply) – Echelon Neuron User Manual
Page 100

MUL (Multiply)
The MUL instruction performs integer multiplication. The MUL instruction
uses the implicit addressing mode. The instruction multiplies the unsigned
integer multiplicand value in NEXT with the unsigned integer multiplier value
in TOS. The 16-bit product result is placed in NEXT and TOS. Because the data
stack grows towards higher addresses, NEXT holds the most-significant byte
(MSB) and TOS holds the least-significant byte (LSB) of the 16-bit value. Thus,
this instruction implements the following equation:
)
:
(
*
TOS
NEXT
TOS
NEXT
⇒
where NEXT:TOS represents a 16-bit product.
Recommendation: Use the _mul16 or _mul16s system functions to multiply
unsigned or signed 16-bit numbers. See _mul16 (Multiply, 16 Bit); and _mul16s
(Multiply Signed, 16 Bit).
The MUL instruction applies to Series 5000 and 6000 devices.
Syntax:
The MUL instruction requires no operands:
MUL
Table 33 describes the attributes of the MUL instruction.
Table 33. MUL Instruction
Instruction
Hexadecimal
Opcode
Instruction
Size (Bytes)
CPU Cycles
Required
Affect on
Carry Flag
MUL
EC
1
14
None
Example:
The following example performs the multiplication 18*68 (h’12 * h’44). Before
the MUL instruction executes, TOS contains 18 (h’12) and NEXT contains 68
(h’44). After the MUL instruction executes, TOS contains 200 (h’C8), which are
the low 8 bits of the product, and NEXT contains 4 (h’04), which are the high 8
bits of the product. Together, NEXT:TOS contain the 16-bit product, 1224
(h’04C8).
pushs #@LB(68) ; (h’44, -, -)
pushs #@LB(18) ; (h’12, h’44, -)
mul ; (h’C8, h’04, -)
90
Neuron Assembly Language Instruction Statements