# Little Man Computer – Multiplication

Doing multiplication using Little Man Computer instructions can be quite a challenge for newcomers. Once you can do it, you will be well on your way to the level of mastery required for exams such as Computer Science A Level.

One big area of difficulty in writing the instructions is understanding exactly how the process of multiplication works. Many people get as far as understanding that we need to use repeated addition, but are still confused by the details.

The key here is to understand or remember that in multiplication, each operand has a different role. So even though 5 * 4 = 4 * 5 for example, the roles of the 4 and 5 are different in each case.

Let’s look at the second version: 4 * 5. By convention, the 4 here is called the multiplier, and the 5 is called the multiplicand. The multiplicand is “the thing to be multiplied”, so 4 * 5 now unambiguously represents 5 + 5 + 5 + 5 + 5.

In pseudocode, we have:

``````Read input into R0 and R1
Set RESULT to 0
While R1 > 0
{
Subtract 1 from R1
Add R0 to RESULT
}
Output RESULT
``````

Here, `R0` and `R1` (think “register 0” and “register 1”) play completely different roles. `R0` is the multiplicand and `R1` is the multiplier. With this clarity, the implementation becomes much easier to understand. You should try to do it yourself before looking at the solution below. You will learn much more if you actually try out the instructions as runnable code in a LMC simulator such as this excellent one by Peter Higginson. Good luck!

## Little Man Computer Programming Teaching Pack for Computer Science GCSE and A Level

You can check out a great resource for teaching or learning about Little Man Computer Programming by clicking here or on the image below. Sharing is caring!