This code appears in the following versions (click to see it in the source code):
Code variations between these versions are shown below.
.MU11 DEX \ Set T = X - 1 STX T \ \ We subtract 1 as the C flag will be set when we want \ to do an addition in the loop below LDA #0 \ Set A = 0 so we can start building the answer in AName: MU11 Type: Subroutine Category: Maths (Arithmetic) Summary: Calculate (A P) = P * X Deep dive: Shift-and-add multiplication
Do the following multiplication of two unsigned 8-bit numbers: (A P) = P * X This uses the same shift-and-add approach as MULT1, but it's simpler as we are dealing with unsigned numbers in P and X.
The loop in the MU11 routine in the advanced versions is unrolled to speed it up.
Tap on a block to expand it, and tap it again to revert.
RTS \ Return from the subroutine