What does movslq do?

It’s movsxdhttps://www.felixcloutier.com/x86/MOVSX:MOVSXD.html.

You could figure this out yourself by assembling it with an AT&T assembler and disassembling with an Intel-syntax disassembler. (e.g. objdumpd -d -Mintel foo.o)


And yes, it does 32->64-bit 2’s complement sign extension, extending by copying the sign-bit of the source to all the new upper bits. (i.e. dst[63:32] = src[31], and dst[31:0] = src[31:0].)

Fun fact: it’s possible to use it without a REX.W prefix as just a 32-bit copy that’s architecturally equivalent to mov, but there’s zero advantage to ever doing that. Or even with an operand-size prefix as a 16-bit copy, but again that’s totally pointless, use mov.


Related: What does cltq do in assembly? has an equivalence table for AT&T vs. Intel mnemonics for all x86 sign-extension instructions, along with description. ([ER]AX to DX:AX, within-[ER]AX, and movsx/movzx to arbitrary registers.)

assembly cltq and movslq difference has more history on how AMD64 repurposed the ARPL opcode from from 16/32-bit mode to get a 1-byte opcode for movsxd.

Leave a Comment