Search code examples
macosassemblyclangx86-64att

i386 movsxw instruction in x86_64


I am trying to compile Apple's Libm (version 2026, tarball here). The only file that is failing to compile properly is Source/Intel/frexp.s because

/<path>/Libm-2026/Source/Intel/frexp.s:239:5:
error: invalid instruction mnemonic 'movsxw'
    movsxw 8+(8 + (32 - 8))(%rsp), %eax
    ^~~~~~
/<path>/Libm-2026/Source/Intel/frexp.s:291:5:
error: invalid instruction mnemonic 'movsxw'
    movsxw 8(%rsp), %eax
    ^~~~~~

Looking around on the Internet I can only find very scanty details of the movsxw instruction but it does appear to exist for i386 architectures. I am running OS X 10.9.3 with a Core i5 processor. The macro __x86_64__ is predefined, however it seems the __i386__ macro is NOT *.

I was under the impression that the x86_64 instruction set was fully compatible with the i386 set. Is this incorrect? I can only assume that the movsxw instruction does not exist in the x86_64 instruction set, thus my question is: what does it do, and what can I replace it with from the x86_64 instruction set?

*Checked with: clang -dM -E -x c /dev/null


Solution

  • The canonical at&t syntax for movsxw is movswl although at least some assembler versions seem to accept the former too.