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


here, i'm trying move variable x (which 8-bit variable) register bx (which 16-bit register). how can move value of x register bx in case?

.686p .model flat,stdcall .stack 2048  .data x byte 5 exitprocess proto, exitcode:dword .code  start: invoke  exitprocess, 0  mov bx, x; 1>p4.asm(13): error a2022: instruction operands must same size  end start ;what end statement do? 

in addition rahul's answer, if need 0 out bh , working on 80386 or newer (as indicated .686p) is:

movzx bx, x 

of if using x signed value , needs sign-extend bx:

movsx bx, x 

Comments