Search code examples
assemblyreverse-engineeringmsp430

What does sxt instruction in MSP430 really do?


I understand that sxt is sign extend instruction. But I don't understand how does this really work. For example if my r15 register stores byte 0045, then what sxt r15 would do to it?


Solution

  • The sxt instruction sign extends a byte into a 16 bit word, i.e. it copies bit 7 into bits 8 to 15 and then updates the flags appropriately.

    For your example, sxt would have no effect as the byte 0045 does not have its most significant bit set, so the high byte of r15 stays at zero.