我在borland c++ 3.1下做的一个作业,要求用c调用汇编。c程序是use-swap.c,汇编程序是swap.asm,分别
如下。
汇编程序swap.asm
.model small
.code
public _swap_values
_swap_values proc
push bp
mov bp,sp
sub sp,2
push si
push di
mov si,word ptr[bp+4]
mov di,word ptr[bp+6]
mov ax,word ptr[si]
mov word ptr[bp-2],ax
mov ax,word ptr[di]
mov word ptr[si],ax
mov ax,word ptr[bp-2]
mov word ptr[di],ax
pop di
pop si
mov sp,bp
pop bp
quit: ret
_swap_values endp
end
c程序use-swap.c
#include<stdio.h>
extern swap_values(int *a,int *b);
void main()
{
int a=1,b=2;
printf("Original values of a %d b %d \n",a,b);
swap_values(&a,&b);
printf("Swaped valued of a %d b %d\n",a,b);
}
二者都能编译通过,但放到一个工程sw里时出现错误:
Linking SW.EXE:
Linker Warning: No module definition file specified: using defaults
Linker Error: Undefined symbol swap_values(int near*,int near*) in module SWAPM.CPP
请问各位高手是怎么回事,如何解决?我将不胜感谢!