Reputation: 197
In MIPS instructions like LW $1, 2($2) I know that why do we need to extend the offset from 16 bits to 32 bits but my question is that why do we extend the sign it like 11111111111111111111111111111000 for -8 why not simply 00000000000000000000000000001000
Upvotes: 2
Views: 469
Reputation: 1490
In MIPS we use signed 2's complement, check this it will make it all clear:
http://en.wikipedia.org/wiki/Two's_complement
Nevertheless to answer your question, the sign of a number in 2's complement is dictated by its most significant bit, 0 for positive, 1 for negative, if you have a negative number therefore you extend with 1's, if positive with 0's
Hope this helps =)
Upvotes: 1