I use Iczelion´s RGB macro in my program which is defined:

RGB macro red,green,blue
        xor eax,eax
        mov ah,blue
        shl eax,8
        mov ah,green
        mov al,red
endm
In Iczelion´s example, he uses the macro as follows: RGB 200,10,0 I want to use it with a register as one parameter: RGB ecx,10,0 Where ecx contains a valid value. But I get an error "Invalid instruction operands" if I try to compile this. What´s wrong? Thank you
Posted on 2001-06-02 07:38:00 by w116
It's pretty simple: if you pass a 32 bit register into the macro (like you did in RGB ecx,0,0), this would be turned into invalid code when the program is compiled. Look:

RGB macro red,green,blue
        xor eax,eax
        mov ah,blue
        shl eax,8
        mov ah,green
        mov al,red
endm
becomes

        xor eax,eax
        mov ah,0
        shl eax,8
        mov ah,0
        mov al,ecx ; <-- This doesn't work
Try using RGB cl,0,0 instead, that should work. NOTE: Since the macro overwrites eax in the beginning, you can't use al or ah as a parameter!
Posted on 2001-06-02 07:48:00 by Qweerdy
w116, What you are getting is a data SIZE error, an RGB color is made up out of BYTE size items, when you try and use ECX, you are trying to put a DWORD size data into a BYTE which will not work. As Qweerdy suggested, use the LOWBYTE part of the ECX register, CL to pass the parameter you want to the MACRO. Regards, hutch@pbq.com.au
Posted on 2001-06-02 12:00:00 by hutch--