I have a variable called char that is supposed to change his value to a keyboard key when I press that key. I visited How to change the value of a variable in assembly and it said for I to use mov char, key_value
. The problem is that I got terminal.asm:126: error: invalid combination of opcode and operands
. Searching for the solution online I saw that is necessary to put brackets [ ]. I tried that and the same error occurred.
Here it is a part of my file:
printChar:
mov edx, char;
loop5_terminal:
mov al, [edx];
mov byte [edi], al;
inc edi;
inc edi;
inc edx;
inc ebx
call cursor_terminal
cmp byte[edx],0;
jne loop5_terminal;
jne l2_terminal
l2_terminal:
cmp al , 0x03 ; Checks for key 2 input
mov char, [two]
je printChar
Thanks.
CodePudding user response:
The error you get is most likely due to the line
mov char, [two]
which contains two memory operands, namely char
and two
. This is not possible, because the x86 architecture does not support two memory operands in one instruction.
You'd have to split that "instruction" into two separate (valid) instructions like
mov al, BYTE [two]
mov BYTE [char], al
if you'd use a BYTE sized instruction.