Questions about M register

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

Questions about M register

Filipe Canatto
According with the book, the M registers is a fake register, there is no hardware for it.

My questions about this approach:
- Could M register be a true register like A and D?, if yes why not use it?.
- There is a fix memory location for M register inside RAM? if no how the hardware can localize it and then  papulate the M register with the content of Memory[A] ? .

Reply | Threaded
Open this post in threaded view
|

Re: Questions about M register

cadet1620
Administrator
There is no Register part for "M". "M" changes the source and destination for computations done by the ALU.

Look ahead to chapter 5 and the diagram for the Hack computer (figure 5.9) and this should make more sense.

The A Register output is connected to "addressM" which is the address for the computer's RAM.
The ALU output is connected to "outM" which is the data input to the RAM.

"M" in a destination in an instruction causes the "writeM" control signal to be true.
The ALU output will be written to RAM[A Register].

When "M" is used in the computation field, the multiplexor connected to "inM", routes the input data from RAM[A Register], instead of the A Register's output, to the ALU "y" input.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Questions about M register

Filipe Canatto
So the symbol "M" in the Hack ASM is just for instruct the hardware perform read/write operations on RAM[A] ?.

Reply | Threaded
Open this post in threaded view
|

Re: Questions about M register

cadet1620
Administrator
Filipe Canatto wrote
So the symbol "M" in the Hack ASM is just for instruct the hardware perform read/write operations on RAM[A] ?.
Yes, that is correct.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Questions about M register

Filipe Canatto
Thanks, now i got it.
Reply | Threaded
Open this post in threaded view
|

Re: Questions about M register

twitu
In reply to this post by cadet1620
This clarified one of my doubts.
So to put it simply, in case of an M operation, say for example:
@R0
M=M+1
The value of memory location R0 is taken incremented and put back without affecting the D register. This happens by multiplexing the output of the RAM directly into in ALU and storing it back.
Reply | Threaded
Open this post in threaded view
|

Re: Questions about M register

cadet1620
Administrator
twitu wrote
This clarified one of my doubts.
So to put it simply, in case of an M operation, say for example:
@R0
M=M+1
The value of memory location R0 is taken incremented and put back without affecting the D register. This happens by multiplexing the output of the RAM directly into in ALU and storing it back.
Yes, that is correct.

You can explicitly load the result into D at the same time.
    @R0
    MD=M+1

This is the equivalent of C++ "preincrement"
    D = ++R0

With one additional instruction you can do "postincrement"
    @R0     // D = R0++
    MD=M+1
    D=D-1

--Mark