How can I move an 8-bit address into a 16-bit register in x86 assembly?

后端 未结 2 901
悲哀的现实
悲哀的现实 2020-12-21 23:38

Here, I\'m trying to move the variable X (which is an 8-bit variable) into the register bx (which is a 16-bit register). How can I move the value of X into the register bx i

相关标签:
2条回答
  • 2020-12-22 00:10

    In addition to Rahul's answer, if you also need to zero out bh and are working on anything 80386 or newer (as indicated by the .686p) is:

    movzx bx, X
    

    Of if you are using X as a signed value and needs to sign-extend bx:

    movsx bx, X
    
    0 讨论(0)
  • 2020-12-22 00:13

    The low 8-bits of BX are addressable as BL.

    So, all you need to do is: mov bl, X

    0 讨论(0)
提交回复
热议问题