• Advertisement

Archived

This topic is now archived and is closed to further replies.

DirectX, Home made Bltters, Assembly

This topic is 6566 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey.. I''m trying to implement some special blts for my project and have realized that it should be done in assembly. I don''t have much experience with it, and was wondering if anyone could point me to a good tutorial on pentium-era assembly coding. I''m using Visual C++ 6.0, and have, of course, access to the inline assembly using __asm {}. I''ve done some tests with it an the blitting speed isn''t too slow, except I am having some problems. My function is like this: ERROR_Type BLT_BltTestOne(Sprite *sprite) { __asm { MOV EAX, sprite->data } } I get errors, no double because the assembler can''t understand the -> pointer. How do I use pointers in inline assembly? Also, what are the speed advantages to calling out to a pure assembly OBJ instead of an inline call? Any help or samples would be appreciated. I would rather keep to directX blitters, but I need to do some specialized transparencies and such..

Share this post


Link to post
Share on other sites
Advertisement
You should stick the indirection into a temporary variable, and reference the variable from the inline assembly. Otherwise you have to dereference your sprite in assembly. yeech.

Compiling into a asm obj files has the hit of needing to cross the function call boundary. i.e. you need to do the stack stuff, not to mention a propable cache miss for non-local code jump. inline for that reason is faster if used properly.

Share this post


Link to post
Share on other sites
Ok. Lets say your Sprite struct looks like this:

typedef struct
{
DWORD Sprite_Width,Sprite_Height;
DWORD Xpos,Ypos;
DWORD *Data;
} Sprite;

Now, in this example, I''m assuming your sprite data is
32-bits.

Then in inline-asm:

========================================== SNIP ============

ERROR_Type BLT_BltTestOne(Sprite *sprite)
{
__asm
{
// point esi to your sprite
MOV esi,sprite

// to get the xpos, you add 8 to the ESI pointer
// because each member of the struct is a DWORD which
// is 4 bytes.
MOV eax,[esi+8]

// to access the sprite data, you would do this
MOV edi,[esi+32]
}
}

=== SNIP ===================================================

That should do it and VC will not complain.




~-------------------------------------------------------~
Fred Di Sano
System Programmer - Artech Studios (Ottawa.CA)
~-------------------------------------------------------~

Share this post


Link to post
Share on other sites

  • Advertisement