I’m trying to create some inline assembly in VC++ 2010 to unpack a RGB buffer of byte into a RGBA buffer of bytes, here’s what I’ve come up with:
But I get the error
1>c:\users\tom\documents\visual studio 2010\projects\source\engine\image_load.c(28): error C2414: illegal number of operands
1>c:\users\tom\documents\visual studio 2010\projects\source\engine\image_load.c(28): error C2400: inline assembler syntax error in 'first operand'; found ':'
1>c:\users\tom\documents\visual studio 2010\projects\source\engine\image_load.c(29): error C2400: inline assembler syntax error in 'opcode'; found ':'
1>c:\users\tom\documents\visual studio 2010\projects\source\engine\image_load.c(29): warning C4405: 'MOV' : identifier is reserved word
1>c:\users\tom\documents\visual studio 2010\projects\source\engine\image_load.c(30): error C2415: improper operand type
1>c:\users\tom\documents\visual studio 2010\projects\source\engine\image_load.c(31): error C2415: improper operand type
1>c:\users\tom\documents\visual studio 2010\projects\source\engine\image_load.c(37): warning C4405: 'loop' : identifier is reserved word
1>c:\users\tom\documents\visual studio 2010\projects\source\engine\image_load.c(71): warning C4018: '<' : signed/unsigned mismatch
I’m not really sure what’s wrong with it, this is my code:
void RGBtoRGBA (byte *rgba, const byte *rgb, int pixelCount) {
__asm {
MOV EDX, pixelCount
MOV EBX, rgba
MOV ECX, rgb
loop:
MOV [EBX], ECX
MOV [EBX+1], [ECX+1]
MOV [EBX+2], [ECX+2]
MOV [EBX+3], 255
ADD EBX, 4
ADD ECX, 3
DEC EDX
JNZ loop
}
}
Forgive me, I’m new to assembly 🙁
No general-purpose instruction supports 2 memory operands like you wrote:
General-purpose instructions typically can only have these 2 operand combinations:
You’ll have to rewrite your code to use valid operand combinations. Start reading the CPU manual about the details of instructions.
Also,
loopis an instruction name. You shouldn’t use it for label names.