汇编语言问题
大家帮个忙!谢了!
我编了一个汇编程序,程序的思想是用子程序 COMPUTE 计算数组X和Y,然后将每次计算结果
保存至数组R的响应位子,X,Y,R都是字数组,子程序COMPUTE和主程序不在同一程序模块,
我是将主程序和子程序所在的俩个模块的数据段定义为同名,都被置为COMMON,程序如下,
可是在连接位.EXE文件时,汇编器提示我说:error L2029:'compute':Unresolved extrnal
请问错那里了?
;This is a program for compute sum from x,y
;**********************************************************
; source module 1
extrn compute:far
data segment common ;define data as common to cnnect with another same segment
x dw 1,2,3,4,5
y dw 1,2,3,4,5
r dw 5 dup(?)
data ends
code1 segment ;define a code segment
main proc far
assume cs:code1,ds:data
start:
mov ax,data ;initial ds
mov ds,ax
call far ptr compute ;call compute program
mov dx,r[2] ;display result
add dx,30h
mov ah,2
int 21h
mov ah,4ch
int 21h
main endp
code1 ends
end start
;**********************************************************
; source module 2
public compute ;make the program can be called
data segment common ;define data as common to cnnect with another same segment
x dw 1,2,3,4,5
y dw 1,2,3,4,5
r dw 5 dup(?)
data ends
code2 segment
compute proc far
assume cs:code2,ds:data
mov ax,data ;initial ds
mov ds,ax
push ax ;save all the register used
push si
push bx
push cx
push di
mov cx,5 ;the times of loop
lea si,x ;initial si
lea di,y
lea bx,r
xor ax,ax ;clear ax
loop1:
mov ax,[si] ;get a element of x
add ax,[di] ;cmopute x and y
mov [bx],ax ;save the result
add si,2
add di,2
add bx,2
loop loop1
pop di
pop cx
pop bx
pop si
pop ax
ret
compute endp
code2 ends
end
;**********************************************************