Search code examples
assemblyx86additionreal-mode

Fix "NASM error: Invalid combination of opcode and operands" for add on Real Mode


I want to increase the DS Register by 200h on Real Mode but it gives me the "invalid combination of opcode" error when doing it like:

add ds,200h

I tried with ax and there was no problem. I guess that it happens because the ds register itself but I have no explanation for this.

It's not like I MUST do it that way, I fixed it by doing this instead:

mov  ax,200h
mov  ds,ax 

But I would like to know the exact reason for this. Thanks for your time.


Solution

  • The add operation cannot be used on the segment registers including DS. The difference is that AX is a general purpose register and thus a different set of instructions, including add is available for that register.