2015 Moed A - Implemeting PCL (new instruction)

Hi,

Regarding the exam mentioned in the subject - link.

Can somebody explain why is the suggested solution is correct?
I assume that the immidiate’s 16 bits are extended to 32 bit, so the AND operation with the MDR would be bitwise and each bit will have its pair.

Let PC be “00000000000000010000000000000000”, only the 16th bit is set. This number is 2^16-1 hence it’s greater than 2^15-1 and according to the desired functionality of the new instruction, C needs to be 0.

But the in the suggested solution:
MDR = 00000000000000010000000000000000 (16th bit set)
imm = 00000000000000001000000000000000 (15th bit set)

MDR & imm = 00000000000000000000000000000000

hence C = 1, so the desired functionality does not hold.

I guess that the suggested is valid and correct.
Which of my assumptions is wrong? What am I missing?

Thank you in advance,
Liav

I went over the solution to this question in the tigbur on Thursday, so you can look for the full explanation there.
Your mistake here is in the extension of imm. The extension assumes that imm is given in 2’s complement, so it’s not just padded with 0’s, but rather padded with 16 copies of the MSB. In this case, the sign extension of the imm field would result in 1^17 concatenated with 0^15.