If you are using Dev-C++ you're gonna have a hard time trying to use inline assembly. Here is a little example I found (I haven't tested it myself).
Dev-C++ uses AT&T syntax, although there is a way to make it use intel: add -masm=intel to the compiler options (I think it sometimes causes linker errors though)
When I tried to use assembly before, however, I had to use a weird syntax for declaring variables. I dug this up:
Code:
static USHORT* video_buffer __asm__("asm_buf") = (USHORT *)ddsd.lpSurface;
// draw the gradient
for (int index_y=0; index_y < SCREEN_HEIGHT; index_y++)
{
// build color word up
static DWORD color __asm__("asmcolor") = _RGB16BIT565(0,(index_y >> 3),0);
// replicate color in upper and lower 16 bits of 32-bit word
color = (color) | (color << 16);
// now color has two pixel in it in 16.16 or RGB.RGB format, use a DWORD
// or 32-bit copy to move the bytes into the next video line, we'll need
// inline assembly though...
// draw next line, use a little inline asm baby!
__asm__
(
"cld;"
"les edi, [asm_buf];"
"mov eax, [asmcolor];"
"mov ecx, 640;"
"shr ecx, 1;"
"rep stosd;"
);
// now advance video_buffer to next line
video_buffer += (ddsd.lPitch >> 1);
} // end for index_y
With the intel syntax option, and I think that one compiled for me. Anyways if you aren't using Dev-C++ then I just wasted my time...darn...