I’m writing a piece of assembly code designed to get keyboard input using a BIOS interrupt, then print it to the screen with another BIOS interrupt. I am using the NASM compiler for x86 systems. At line 19 of my code (marked with an asterisk (*), I am getting the “invalid combination of opcodes and operands” error. I know this generally represents any number of syntactical errors, but at my skill level, I can’t work down to any specifics, sorry. Here’s my code chunk:
; ---------------------------------------------
; Get input (hangs on input and loops forever)
; ---------------------------------------------
GetInput:
XOR AH, AH ;AH = 0 for interrupt 16.0
INT 0x16 ;Fetch the next key pressed.
MOV SI, keymap ;Set SI to the head pointer of the keymap
ADD SI, AH ;Increase the pointer by the key number.
*MOV AL, [SI] ;Load the returned key for printing.
CALL PrintCharacter ;Print the key
CALL GetInput ;Wait on the next key.
RET
Let me know if you need any more information, thanks!
I believe that that your mistake is one line before.
You can’t mix 16 bit and 8 bit registers in x86 like:
If you want to add AH register to SI than copy (zero extend) AH to AX first, like: