Why can't I move directly a byte to a 64 bit register?

后端 未结 2 1383
生来不讨喜
生来不讨喜 2020-12-11 05:29

Why can\'t I directly move a byte from memory to a 64-bit register in Intel x86-64 assembly?

For instance, this code:

extern printf

global main

seg         


        
2条回答
  •  囚心锁ツ
    2020-12-11 05:41

    Use move with zero or sign extension as appropriate.

    For example: movzx eax, byte [rbp - 1] to zero-extend into RAX.

    movsx rax, byte [rbp - 1] to sign-extend into RAX.

提交回复
热议问题