问题
This might be a really strange question, but I have been doing some work on the little man computer and it mildly annoys me that not only is there no operation code number 4, but there is absolutely no information on the internet as to why.
The opcodes go 0-9 but skip 4. Are there never any three digit codes that start with 4? What happens if there is?
Is there anyone out there that would be able to help answer this question? I just find it so strange. Thank you!
回答1:
The Little Man Computer (LMC) was initially not presented as a complete specification. It is more a model, a paradigm. There are several things left undefined, like for instance what should happen when the unused opcode 4 is encountered. The aim of LMC was to introduce students to the concepts of machine code and instruction sets and demonstrate that the power of a computer does not come from complexity. The aim was not so much to explain all the details of what happens with badly designed code.
It is not defined what should happen. In concrete implementations, choices are made: either it will lead to abnormal program termination (like stated here), or it will be executed as a no-operation instruction, or it will still do something else (very unlikely). The main message is that programs should not rely on a certain implementation choice, and should never run into such an opcode. If you really want to know what would happen, then this is a specification that should be found in the documentation that comes with a specific implementation (emulator).
There is no particular reason why 4 is unused. The initial LCM (in 1965) had a slightly different set, where it seems that opcode 4 was used. The more popular set was introduced later, and is also presented in "The Architecture of Computer Hardware and System Software" (Irv Englander). Several other implementations of LCM describe extensions (like here) where opcode 4 gets a use.
回答2:
https://web.archive.org/web/20131211112403/http://www.acs.ilstu.edu/faculty/javila/lmc/
This lists a totally different instruction set (e.g. input/output is 500/600).
来源:https://stackoverflow.com/questions/42579740/what-happens-to-instructions-given-to-the-little-man-in-the-lmc-that-begin-with