Hello I am currently using Little Man Computer for a school project and I understand that LMC has an ADD and a SUB function. However I understand that there is no Multiply or Divide function in LMC and I would like to know why that is.
-
That's because Both Multiplication and division can be done via ADD and SUB methods. e.g. Multiplication is also addition. 8*2 = 8+8. Also [This link](http://mathforum.org/library/drmath/view/54338.html) will help you understand how do computers perform such operations – NSNoob Dec 28 '15 at 14:19
-
1@NSNoob You have to note that real computers have special hardware circuits to perform multiplication and division because if you explicitly perform those operations by coding the longhand operations we learnt in primary school (as opposed to using loop of ADDs), you would wait until the cows come home for any result. I won't go into exponentiation (which is of course a loop over a loop of ADDs at the base). Idle thought: It would be instructive to discuss MULT and ADD as implemented on the mechanical [Difference Engine](http://www.computerhistory.org/babbage/howitworks/)... – David Tonhofer Dec 28 '15 at 14:36
-
See also [binary multiplier](https://en.wikipedia.org/wiki/Binary_multiplier) – David Tonhofer Dec 28 '15 at 14:42
-
Some actual CPUs don't have multiply and divide instructions. For example, the Zilog Z80 doesn't and although it's somewhat old (invented in the late 1970's) it's still in widespread use today. – Paul Hankin Apr 20 '16 at 02:38
2 Answers
The LMC serves educational purposes, and is not intended to excel in efficiency.
"The Architecture of Computer Hardware and System Software" (4th ed. 2009), chapter 6 is one of the main references for the LMC. That chapter starts with this phrase:
The power of a computer does not arise from complexity.
That is one of the key messages that the LMC aims to bring.
And in section 6.4 Irv Englander writes:
The nine instructions that make up the instruction set that we have presented are sufficient to perform the steps of any computer program, although not necessarily in the most efficient way [...]
The real computer differs mostly in the variations to these instructions that are provided, and with the addition of a few instructions that provide programming convenience, particularly multiplication and division instructions, and also instructions that shift the data in a word left or right.
I would imagine that you could use some shifting operators to achieve this, but I don't know for certain if that route is optimal or the only way. Here is a link that I found discussing LMC multiplication: http://www.experts-exchange.com/questions/24104347/Little-Man-Computer-How-to-multiply.html
That link discusses the use of both Add and Sub methods, which can be used to achieve multiplication and division.
As for division it should be noted that computers can't actually do division; they use an inverse of multiplication to do the same thing.

- 4,184
- 5
- 26
- 67
-
Of course division is an inverse of multiplication ... that's what it is by definition. But how do [ALUs](https://en.wikipedia.org/wiki/Arithmetic_logic_unit) implement it? The same we did in school. See [here](http://www.cs.utah.edu/~rajeev/cs3810/slides/3810-08.pdf) – David Tonhofer Dec 28 '15 at 14:41