Why can I do M=0 and M=1, but can't do M=2?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Why can I do M=0 and M=1, but can't do M=2?

hacker
It looks like I've missed something, but I don't understand why I can use C-intruction like M=0, but assembler don't allow me to set memory value to more than 1 value.
Reply | Threaded
Open this post in threaded view
|

Re: Why can I do M=0 and M=1, but can't do M=2?

hacker

And here is the answer. One of the possible computations is 0 and 1, not 2 and more.
Reply | Threaded
Open this post in threaded view
|

Re: Why can I do M=0 and M=1, but can't do M=2?

WBahn
Administrator
In reply to this post by hacker
hacker wrote
It looks like I've missed something, but I don't understand why I can use C-intruction like M=0, but assembler don't allow me to set memory value to more than 1 value.
The key to remember is that "M=0" is not an arithmetic expression, it is a "mnemonic" which is just a string of text that serves as a memory aid to us humans regarding what a particular opcode does. All the assembler does is replace that string of text with the pattern of 1s and 0s that it represents.

If you wanted to, you could make YOUR assembler support instructions like M=42 or even M=-42 by having your assembler examine the instruction and then spit out the sequence of binary instructions that are needed to implement it.