I was reading about the SAP computers(as I do), and examined the SAP-2 chapter of Paul Malvino's Digital Computer Electronics, hoping to learn about how a microprocessor without a multiply instruction would go about multiplying numbers. It required 3 registers, which i will denote A, B, and C, and the instructions to sucessfully multiply 2 binary numbers went like this according to the book:
Line 1:Load A with 0
Line 2:Load B with the first number you are multiplying
Line 3:Load C with the second number you are multiplying
Line 4:Add A and B and store sum in A
Line 5: Decrement C
Line 6: If the byte stored in C is not zero, jump to line 4
Line 7: Stop the program. The product will be in A.
The first problem here is the decrement instruction. Earlier in the book, it said that to execute a decrement instruction, you must load the value you want to decrement in A, subtract 1, and then load it back into the designated register. But that means that the product value in A will be overwritten by the decrement instruction, so that won't work. The second problem is the flags, which only apply to A, which means to untrigger the jump instruction, you have to overwrite A. And if that doesn't work, how do microprocessors multiply without a "Multiply" instruction? Or is there something I misunderstood in the program or how the "decrement" instruction works?