I am writing a program in 16 bit Turbo C++ version 3.0 based on partial Assembly and C code. I have to use the local variables of C code in assembly block. I have debug the following code in Borland C++ 5 and MS VC++ 6. It works fine but these compilers are 32 bit therefore I have to do this in Turbo C. In Turbo C++ it displays an Error: “Invalid combination of opcode and oprends” the code is:
void AssignPixel (int X,int Y,int R,int G, int B )
{
_asm {
mov dx, 0x3c8
mov al, 4
out dx, al
inc dx
mov al, R // ERROR
out dx, al
mov al, G // ERROR
out dx, al
mov al, B // ERROR
out dx, al
mov ah , 0x0c
mov al , 4
mov cx , X // ERROR
mov dx , Y // ERROR
int 0x10
}
Is there any way to use Variables with assembly code. Code Sample will be appreciated.
You can’t do these most likely because the sizes of the registers and variables don’t match (8-bit vs 16-bit):
And here the assembler probably expects different syntax:
Try these instead: