在汇编程序中调用C函数

 

/*
*funcc.c
*/
#include
<stdio.h>
void func(int *x)
{
*x += 1;
printf(
"%d\n", *x);
}

 

 

#funcs.s
.section .data
x:
.
int 1
.section .text
.globl _start
_start:
pushl $x
call func

movl $
1, %eax
movl $
0, %ebx
int $0x80

 

 

/*
* 编译命令:
* as -o funcs.o funcs.s
* gcc -c -o funcc.o funcc.c
* ld -dynamic-linker /lib/ld-linux.so.2 -lc -o func funcc.o funcs.o
* /

 

posted @ 2010-06-29 13:22  penink  阅读(217)  评论(0)    收藏  举报