Ephemera
Ephemera

Reputation: 9010

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

Upvotes: 0

Views: 720

Answers (2)

Jester
Jester

Reputation: 58822

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

Upvotes: 1

Michael
Michael

Reputation: 58507

movsxb : Sign-extend a byte into the second operand
movsxw : Sign-extend a word (16 bits) into the second operand
movsxl : Sign-extend a long (32 bits) into the second operand

movsxw assembles just fine for me in 64-bit mode using gcc/as (4.8.1/2.24). I don't have clang for x86 installed on this machine, but you could try specifying the size of the second operand (i.e. change movsxw to movsxwl, which would be "sign-extend word into long").

Upvotes: 1

Related Questions