BLOB wrote
1) I wrote this code...
@i
M = 2 // it gave me an error at this point saying expression expected
There was no error when I changed it to
M = 1
Why is this happening?
The only valid constants in hack assembly are 0, 1 and -1 and these are within the scope of C instructions. All other values must use an A instruction. If you want to use the value 2, you must first @2.
BLOB wrote
When I use the code @5, a binary equivalent of 5 (in 16 bits) which is equal to 0000000000000101 is loaded right? This is stored in the A register right?
Right and right.
BLOB wrote
so, what will the M register contain when A register points to no address (but has a value instead) ?
The instruction set does not inherently distinguish whether the value in the A register is meant to be used as some constant value or an address. As such, when A contains the value 5, then M references memory address 5.
Try to re-read the chapter on Hack assembly, it's worth it.