# Microinstructions: Why is H = H – MDR illegal if H and MDR use two different buses?

The book here (on page 14) states this:

Similarly, H = H – MDR is illegal too, because the only possible source of a subtrahend (the value being subtracted) is the H register.

From my understanding the above statement is saying that the subtrahend (value in MDR) is in the H register? However if you look at this MIC-1 microarchitecture on page 7, the H register connects directly to the ALU and the MDR uses the B bus, so why is it illegal?

• The sentence you quoted tells you! The subtractor ONLY implements <dest> = <source> - H. – Brian Drummond Jan 15 '16 at 15:02
• @BrianDrummond - Why does the MDR become the H if it can be loaded on the B bus? – Josh Jan 15 '16 at 15:16

The issue is not having two different buses. The restriction, which causes 'H = H - R' to be illegal, comes from the set of operations the ALU implements.

According to page 14:

There are many seemingly reasonable statements that are illegal operations. For example, MDR = SP + MDR, looks reasonable, but there is no way to execute it on the data path of Mic-1 in one cycle.

This is because there is only one bus, the B bus, that can supply values from the SP register and the MDR register to the ALU. So only one of those two registers can be connected.

It goes on to say:

Similarly, H = H – MDR is illegal too, because the only possible source of a subtrahend (the value being subtracted) is the H register.

It is saying the design of the ALU must have the subtrahend from the H register port. That ALU does not have an operation which uses the value from the B bus port as the subtrahend; the subtrahend can not be supplied over the B bus to that ALU.

So the ALU only implements X = <B-bus-register-port> - <H-register-port>
The ALU does not implement X = <H-register-port> - <B-bus-register-port>

That was a decision made by the designers of the architecture. They could have defined the ALU in a different way, so that it could take the subtrahend from the B-bus. But they didn't.

Further, the question 'Why does the MDR become the H if it can be loaded on the B bus?' doesn't make sense. For an operation the 'MDR' does not 'become the H'. It would take previous operations to move MDR into H, and H into another register, to have the effect of 'H = H - MDR'

Edit in response to OP's comment:

However, is there any reason the ALU can't use the subtrahend? I don't see how if the value of the MDR can be passed into the H register through the ALU, it can't be used in the above, illegal operation.

The instructions being described, executed by the architecture, are not the ISA's machine instructions available to the operating system or user applications.

The instructions being described are the internal 'Microinstructions' which directly control each cycle of the internal operation of the CPU; (page 1):

For our example micro-architecture, it is controlled by the microinstructions, each of which controls the data path for one cycle.

This is the crucial, core, concept. If something is not a Microinstruction, then it can not be done in one cycle. It can only be doe using multiple Microinstructions.

That manual (page 5, 'Microinstructions' section):

To control the data path of Fig. 1, we need 29 signals.

then, on the next point:

The values of these 29 control signals specify the operations for one cycle of the data path. A cycle consists of gating values out of registers and onto the B bus, propagating the signals through the ALU and shifter, driving them onto the C bus, and finally writing the results in the appropriate register or registers.

That is the definition of a single machine cycle, internal to the CPU. The machines behaviour is 'programmed' using the available Microinstructions, which contain those 29 signals. That is all there is to work with.

If a Microinstruction can't achieve what you might like, then the only way to achieve that effect is to use multiple Microinstructions.

As we've already seen, the manual explains on page 14:

Similarly, H = H – MDR is illegal too, because the only possible source of a subtrahend (the value being subtracted) is the H register.

That is how the ALU is designed. So that is the reason the ALU can't take the subtrahend from the B bus. It is not designed to do that. That was a design trade-off the designers made. Presumably, they have a rationale based on (at least) the target ISA they want to implement, cost, complexity, and performance.

So, taking the comment a piece at a time:

... if the value of the MDR can be passed into the H register through the ALU ...

Put MDR onto bus B, through the ALU without an operation, and store into H appears to be a valid Microinstruction.

However, AFAICT, there is no Microinstruction which can both move MDR into the H register and do an ALU operation in a single cycle.

That overall effect can be achieved in several Microinstructions. That is common for a Microprogrammed machine.

However 'H = H - MDR' can not be done in one Microinstruction by design.

Maybe the concepts you are struggling with are: Microinstructions, Microprogramming, many single-cycle Microinstructions implementing one ISA instruction, and the idea that the designers of the Microprogrammed machine chose not to support every possible operation (to balance cost, complexity and performance).

Perhaps if you work through the implementation of the ISA instructions 'ISUB' and 'IFLT' (which are the ones which appear to need subtraction) as Microprograms, it might become clearer why they made the decision to not implement X = <H-register-port> - <B-bus-register-port>

• Thanks for the answer, I think I partially understand. I admittedly did word my other comment quite poorly as I understand it's the value that is being moved. However, is there any reason the ALU can't use the subtrahend? I don't see how if the value of the MDR can be passed into the H register through the ALU, it can't be used in the above, illegal operation. – Josh Jan 15 '16 at 23:47