Satır içi derlemede c işlevlerini çağırma
Microsoft özel
Bir __asm blok c Kitaplığı yordamları da dahil olmak üzere, c işlevleri çağırabilir.Aşağıdaki örnek çağrı printf kitaplık yordamı:
// InlineAssembler_Calling_C_Functions_in_Inline_Assembly.cpp
// processor: x86
#include <stdio.h>
char format[] = "%s %s\n";
char hello[] = "Hello";
char world[] = "world";
int main( void )
{
__asm
{
mov eax, offset world
push eax
mov eax, offset hello
push eax
mov eax, offset format
push eax
call printf
//clean up the stack so that main can exit cleanly
//use the unused register ebx to do the cleanup
pop ebx
pop ebx
pop ebx
}
}
Yığında işlev bağımsız değişkenleri geçirdiğinden gerekli bağımsız değişkenleri yalnızca itme — dize işaretçisi, önceki örnekteki — işlevi çağırmadan önce.Bağımsız değişkenler, istenen sırada yığından gelmesi ters sırada itilir.c ifadesi öykünmek için
printf( format, hello, world );
Bu örnek için işaretçiler iter world, hello, ve format, o sırada ve ardından çağrı printf.
SON Microsoft özel