'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 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sep Roland