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

后端 未结 2 906
悲哀的现实
悲哀的现实 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
    

提交回复
热议问题