What does the a-bit in a C-instruction mean?

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

What does the a-bit in a C-instruction mean?

riverfish
From the book it says:

In the case of a C-instruction, the single a-bit determines whether the ALU will operate on the A register input or on the M input, and the six c-bits determine which function the ALU will compute.

I'm looking at the computer nemonic table fig 4.3 and you have one column, a=0, with computations such as D-A , D+A. And another column on the right, a=1, with computations such as D+M, D&M.

This has me a little confused because I would've though that if a=1, then the ALU will operate on the A register. But judging from the mnemonic table, it seems like the ALU operates on the A register if a=0.

Am I correct in my thinking?
Reply | Threaded
Open this post in threaded view
|

Re: What does the a-bit in a C-instruction mean?

xedover
'a' doesn't mean 'A'

they could have just as easily used 'x' (or any other variable label), as in:

x=0 -> use the A register
x=1 -> use the M register

so yes, when that 4th bit is 0, you'll use the A register, and when its 1, you'll use the M register.
edit: technically, its bit[12]
Reply | Threaded
Open this post in threaded view
|

Re: What does the a-bit in a C-instruction mean?

cadet1620
Administrator
In reply to this post by riverfish
Look at the CPU diagram. The ALU 'x' input (first argument) is D and the 'y' input (second argument) is the output of a Mux that selects between A and M. That Mux is what the 'a' bit in C-instructions controls.
CPU diagram
Reply | Threaded
Open this post in threaded view
|

Re: What does the a-bit in a C-instruction mean?

riverfish
Thanks for the clarification guys.

Since you posted the diagram Cadet, I got another unrelated question about the A-register.

From what I understand, the A-register either reads the current value in the A register or writes the output of the MUX of Instruction and ALU output into the A register.

If that's the case, what would the control bit for the A register represent then? Would it also be the a-bit (i.e. instruction[12])? Because if a=0, then it means that you want to utilise the A register?
Reply | Threaded
Open this post in threaded view
|

Re: What does the a-bit in a C-instruction mean?

cadet1620
Administrator
The 'a' bit only has meaning in c-instructions that read from M. It has noting to do with writing to M or writing to the A Register.

Remember the Register you wrote in project 3. It has 2 inputs: 'in' and 'load'.  As you wrote, the multiplexor output is connected to the A Register input, so the control signal must be the A Register's 'load'.

The D Register's 'load' signal is simple, it needs to be true only during c-instructions that have the "D" dest bit set.

The A Register is trickier. Its 'load' needs to be true during c-instructions that have the "A" dest bit set, but 'load' also needs to be true during a-instructions so that the data in the instruction will be loaded into the A Register.
Reply | Threaded
Open this post in threaded view
|

Re: What does the a-bit in a C-instruction mean?

riverfish
So the A register's load bit needs to true when a c-instruction has the "A" dest bit set, i.e. instruction[5] and when the instruction is an A-instruction as well, i.e. instruction[15]?

That has me a little confused because I had the Mux before the A register having the control bit as instruction[5] too.
Reply | Threaded
Open this post in threaded view
|

Re: What does the a-bit in a C-instruction mean?

cadet1620
Administrator
The muxes are like switches that control how data flows through the CPU for various instructions.

Here's a quick drawing data paths for some instructions.

Reply | Threaded
Open this post in threaded view
|

Re: What does the a-bit in a C-instruction mean?

riverfish
I'm not catching your drift here, sorry Cadet. Still confused
Reply | Threaded
Open this post in threaded view
|

Re: What does the a-bit in a C-instruction mean?

riverfish
In reply to this post by cadet1620
I found this reply from another thread:

To store a value in the A register, you must use an A instruction, or a C instruction where A is the dest. For example:

@42 // stores 42 in the A register
A=1 // stores 1 in the A register
So the control bit for the A register is an OR between the "A" dest of a C-instruction and the opcode of an A-instruction?

As for the Mux that feeds into the A register what would the control bit be?

Reply | Threaded
Open this post in threaded view
|

Re: What does the a-bit in a C-instruction mean?

cadet1620
Administrator
The "@1234" instruction needs to route the 1234 from 'instruction' through the left mux to the A Register input. C-instructions with "A=" need to route the ALU output through the left mux to the A Register input.

It does not hurt for the ALU output to go to the A Register input during c-instructions that don't write to A Register, so that simplifies to routing the ALU output to A Register during c-instructions.

The control signal (sel) for the left mux is just instruction[15], with instruction and ALUout connected appropriately to the mux's a and b inputs.

[It's past 2300 here and I need to be up around 0530, so I'm going to disappear for awhile...zzzz]
Reply | Threaded
Open this post in threaded view
|

Re: What does the a-bit in a C-instruction mean?

riverfish
Makes sense now. Thanks Cadet, you're a godsend to this forum. You deserve some sleep!