Multiply Without MUL Instruction
Multiply two 8-bit numbers on a core with no hardware multiplier using shift-and-add, taking at most 8 iterations.
Constraints
- Operands in r16 and r17, 16-bit result in r18:r19.
- Use only shifts, adds and branches.
- Must terminate early when the multiplier reaches zero.
- Handle a zero operand correctly.
- AVR assembly syntax.
- Do not use the MUL instruction even if the core has one.
1; AVR: multiply r16 by r17 into r18:r192mul8:3 ; TODO4 ret