当前位置: 代码迷 >> 汇编语言 >> 两个asm模块,调用外部历程
  详细解决方案

两个asm模块,调用外部历程

热度:9734   发布时间:2013-02-26 00:00:00.0
两个asm模块,调用外部过程?
main.asm

INCLUDE \masm32\include\Irvine32.inc
INCLUDELIB \masm32\lib\Irvine32.lib
INCLUDELIB \masm32\lib\kernel32.lib
INCLUDELIB \masm32\lib\user32.lib

EXTERN str_copy1@12:proc

.data
source byte 'rbh4rbjwirhklec',0
target byte lengthof source dup(0)

.code
main PROC
push 6
push offset source
push offset target
call str_copy1@12 
exit 
main ENDP
END main

copy.asm

INCLUDE \masm32\include\Irvine32.inc
INCLUDELIB \masm32\lib\Irvine32.lib
INCLUDELIB \masm32\lib\kernel32.lib
INCLUDELIB \masm32\lib\user32.lib

.code
str_copy1 PROC PUBLIC USES esi edi ecx eax,source:PTR BYTE,target:PTR BYTE,maxnum:DWORD
mov esi,source
mov edi,target
mov eax,0  

@@while:
cmp byte ptr[esi],0
je @@end
inc eax
inc esi
jmp @@while

@@end:
inc eax  
cmp maxnum,eax
jna l1
mov ecx,maxnum
l1:mov ecx,eax
clc
l2:movsb 
inc esi
inc edi
loopd l2
ret
str_copy1 ENDP
END

编译无问题,一link,main.asm就unsolved extern symbol:_str_copy@12
copy.asm就unsolved extern symbol _maincrtstartup

请问怎么解决,谢谢
 

------解决方案--------------------------------------------------------
link 是也要将 copy.obj 加上的:link /subsystem:console main.obj copy.obj
总不能让 link 程序自己去寻找 str_copy 在哪个 obj 文件里吧,无从找起啊!
  相关解决方案