Previous part. If you missed the introductory post, head here: Part 0.

Welcome back to our little endeavour to build a CPU. Last time we finished our adder/subtractor, and it's all fun and cool, but we'd like our CPU to do more than add and subtract. Today we will finish the ALU so we can finally move on to the overall architecture of the CPU.

Let's wrap the arithmetic part of the ALU first. How about multiplication and division? Well, as it turns out it's a bit more convoluted to create multipliers and dividers. And I was thinking for a long time if I even want to cover them. Here's the deal, we can totally emulate multiplication and division with addition and subtraction. Since we're trying to create a simple CPU, not necessarily fast and efficient I think we can leave both multiplication and division to software, not hardware. In fact that's what early CPUs like Intel 4004 did. They didn't have dedicated circuitry for multiplication or division, instead you would have a programmer write code to add in a loop to multiply. This approach is slower, but takes less space ...