MUL - Multiply the Accumulator by X Command

Multiplies the value held in the accumulator by the value held in the X register.
The main use of this is for making a jump table where you multiply by 4 to offset the target to branch to.

Syntax

MUL
Notice that there is no value or location attached to this command. It simply multiplies the value in the accumulator by the X register.
This produces a 16-bit result.
The high byte is stored to the X register and the low byte is stored to the accumulator.
The Carry flag and Minus flags are cleared.
If the result is zero e.g. 10 multiplied by 0, then the Zero flag is set.
No obvious use for this Mnemonic but you may come across it somewhere.

Examples

Example 1

{
LDA #100    //Put the fixed decimal value 100 into the accumulator
LDX #5      //Puts the fixed decimal value 5 into the X register
MUL         //100x5=500 in decimal or 00000001 11110100 in binary
            //The accumulator now contains the value 0xf4 and the X register contains the value 0x01
}

Example 2

Using the MUL command to offset the index of 4 in a jump table.

{
Name="Linear Preset Jump Table"
Start(0x1c,10,x,0x65,x,x,x) //Start on an area 10 linear preset message
Copy @0,~0,7                //Copy the message to user ram
LDA ~2          //Load the preset number into the accumulator
MUL 4           //Multiply the value by 4. This creates an offset of 4.
TAX             //Transfer the value in the accumulator to the x register
BRA PJumper,x   //Jump to the label plus the value in the x register
Null
PJumper:        //This is the jump table. The task will jump to the specified row.
    BRA P1
    BRA P2
    BRA P3
    BRA P4
    BRA P5
Null
      P1:
      //Do something for Preset 1
      Null
      ...
}