Archived

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

VC++ inline assembly

This topic is 5575 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

Are there any GOOD, tutorials out there on the web about using inline assembly in C++ code using VC++? I''ve done a billion Google and Yahoo searches and come up with scraps. Thanks.

Share this post


Link to post
Share on other sites
Basically, anything except interrupts. All you need is an assembly reference/book/guide and you''re set. So anything you know how to do in assembly, you can pretty much do in the inline assembler, sin a few things, like the interrupts mentioned above. If the code crashes, then you can''t use it Hehe that''s not a good motto but it''s good to start out with

Share this post


Link to post
Share on other sites
Also, be careful which registers you modify. Some are documented to be scratch registers by the VC++ compiler, but they really aren''t, so, like Zipster said, if it crashes, you weren''t supposed to do whatever it was you just did

Share this post


Link to post
Share on other sites
_asm:

and then push everything:
registers (push eax,push ebx...)
flags (pushf)

do what you want in asm

and then pop everything (popf pop eax...) remember about quote!

always work.

ps.
dont push eip

Share this post


Link to post
Share on other sites
If you already know assembly, the VC++ documentation pretty much tells you everything you need to know to get started using it.

just do something like (note that this probably won't compile - but you get the idea):


int Add( int x, int y )
{

__asm
{
mov eax, x
mov ebx, y
add eax, ebx ; return addition in eax
}
}



If you don't know assembly then try:

Iczelion's Win32 Assembly Homepage
Art of Assembly Language Programming and HLA by Randall Hyde
Dolphinz ASM Page..



Also - if anyone is interested, i've posted an article proposal in the relavent forum regarding (inline) assembly....


[edited by - Jx on September 10, 2002 7:19:47 AM]

Share this post


Link to post
Share on other sites