Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Khusus Microsoft
Blok __asm dapat memanggil fungsi C, termasuk rutinitas pustaka C. Contoh berikut memanggil printf rutinitas pustaka:
// 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
}
}
Karena argumen fungsi diteruskan pada tumpukan, Anda cukup mendorong argumen yang diperlukan — penunjuk string, dalam contoh sebelumnya — sebelum memanggil fungsi. Argumen didorong dalam urutan terbalik, sehingga keluar dari tumpukan dalam urutan yang diinginkan. Untuk meniru pernyataan C
printf( format, hello, world );
contoh mendorong pointer ke world, , dan hello, dalam urutan tersebut, lalu memanggil formatprintf.
END Khusus Microsoft