Assembly MIPS - Shift of an address

0


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.

assembly
bit-manipulation
mips
mips32
machine-code
asked on Stack Overflow Jul 17, 2016 by tatoalo • edited Jul 18, 2016 by Peter Cordes

1 Answer

0

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

answered on Stack Overflow Jul 23, 2016 by Robert

User contributions licensed under CC BY-SA 3.0