My lecturer told me that when I use an arithmetic I-Type command (ADDI,SUBI etc.
ID: 653007 • Letter: M
Question
My lecturer told me that when I use an arithmetic I-Type command (ADDI,SUBI etc.) , the IMM field gets sign extended, and when I use a logic I-Type command (ORI,ANDI etc.) , the IMM field is just bits.
He also said that if the IMM field contains a negative number, it is represented in 2's complement.
Let's say I have a command, and two binary numbers X Y, so that X's 2's complement representation looks exactly like Y in regular representation.
Note: X is negative and not the same as Y.
Given a question in which I should say what is the value in the IMM field in an arithmetic I-Type command, how do I know if it's X or Y?
Explanation / Answer
In an arithmetic I-type command, the IMM-field is treated as a signed number. So if the first bit is 1, the number will be treated as negative (X in your terms.) The number Y is simply too large to be used as argument of an arithmetic I-type command.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.