0
votes


I'm making some exercises on assembly MIPS(32 bit) and I don't really understand how the left shift by 2 works. I'll add a couple of examples just to explain it better.

  • Instruction is 0x91050014
    I have to take the last 16 bits and then extend them to 32 bits.
    So I take 0014 and since the MSB is a zero it means that it's a positive number so I extend it to 32 bits like follows: 0x00000014
    After that I have to apply a shift to the left by 2, so ( I use [] for deleting and {} for adding):
    [00]00 0000 0000 0000 0000 0000 0001 0100{00}
    Which I can conclude is 0x00000050

I've got problems once the last 16 bytes aren't positive, like in this example:

  • Instruction is 0x10A6FFEC
    I take FFEC and since the MSB is an F it means that it's a negative number so I extend it to 32 bits like follows: 0xFFFFFFEC
    Now I find myself with this: 1111 1111 1111 1111 1111 1111 1110 1100
    And I don't understand how to apply the shift.

Thanks in advance.

1
Exactly the same way. By the way they're 16 bits, not bytes.harold
@harold Corrected, sorry. So I just delete the first couple of 11 and add 00 as LSB and I should get 0xFFFFFFB0, correct?tatoalo
@harold Perfect. If it's not too much to ask I'd have one last thing, as the very last step I have to calculate the sum with PC, it's 0x0000080C + 0xFFFFFFB0. The result should be 0x1000007BC but since I have to stick with 32 bits is it correct to say just 0x000007BC ?tatoalo
Yes, and you see it works out with the interpretation of 0xFFFFFFB0 being negativeharold
@harold Thank you very much!tatoalo

1 Answers

0
votes

the same way

1111 1111 1111 1111 1111 1111 1110 1100

will be

[11]11 1111 1111 1111 1111 1111 1110 1100{00}

so it's

1111 1111 1111 1111 1111 1111 1011 0000

0xffffffb0