Hello, I already posted this in coursera week 2 forums, but there seems to have less interaction and week 2 ends tomorrow so I copied here to get more insights.
I understand how 2's complement works but still I have some doubs about how we use the representation in the ALU. Considering the same ALU we have built but with 4 bits instead of 16. If we use 2's complement representation as the system for the whole ALU and eventually CPU:
0100 - 1001 = 4 - (-9) = 13 = 0111
0100 + 1001 = 4 + (-9) = -5 = 1011
To do x-y I thought you would change it to x+(-y) and then for -y get the 2's complement representation of the abs value of y but the ALU does not perform any of this logic internally. That would also mean that the input Y is not represented already in 2's complement. Thus, my question:
Does the ALU perform any 2's complement representation conversions or we have to assume that all binary numbers in the ALU (inputs/outputs) and eventually CPU are already in 2's complement and the ALU operates and calculates its operations in that representation?
An interesting thing that I've learned over the years is how often simply asking a question can get you out of a mental rut. Something about reorganizing one's thoughts to communicate them helps to clarify them.