assemblyx86-16instruction-setoperands

Assembly `mov si, ah` produces "invalid combination of opcode and operands"


So I'm trying to print a character to the screen when I press a key.
I get this error:

src/kernel/main.asm:20: error: invalid combination of opcode and operands

mov ah, 00h
int 16h

mov si, ah ;where the error is

Solution

  • mov si, ah
    

    The above is mixing an 8 bit operand (ah) with a 16 bit operand (si). You cannot do that with MOV. When using MOV instruction, operands must be of the same size.

    As Peter suggested, you will need to use an instruction like MOVSX or MOVZX if you want to mix operand sizes like that.