0

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
Sep Roland
  • 33,889
  • 7
  • 43
  • 76
  • 5
    SI is 16-bit, AH is 8-bit. Where do you want the AH bits to go in SI, and what do you want the rest of the bits filled with? For example, `movsx si, ah` would sign-extend AH into SI. – Peter Cordes Apr 02 '22 at 22:03
  • 1
    Alternatively do `mov al, ah; mov ah, 0; mov si, ax` – Sebastian Apr 03 '22 at 20:58
  • @Sebastian That's fine for unsigned data, but for signed data you can do `CBW AL` followed by `MOV SI,AX` – puppydrum64 Dec 20 '22 at 18:13

1 Answers1

3
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.

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
Niya
  • 243
  • 2
  • 8