I would like to move my return from htons call 00005c11 and have have moved to the top if eax and have the result of 5c110000.

Nasm won't let me mov eax, ax due to size constraints. Is there a defined way to do this or a potential hack?

  • 4
    movzx eax, ax should work and is arguably easier to understand than the rotate-left solution, because it more clearly communicates intent.
    – newgre
    Apr 18 '16 at 13:01
  • +1 IMHO, movzx eax, ax is more natural. Apr 18 '16 at 14:12

The answer is to use rol:

rol eax, 10

Not the answer you're looking for? Browse other questions tagged or ask your own question.