主程序和子程序不在同一模块-出错了!
extrn proadd:far
DATAS SEGMENT common
array dw 1,2,3,4,5
account dw ($-array)/2
sum dw ?
DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码
STACKS ENDS
CODES SEGMENT
main proc far
ASSUME CS:CODES,DS:DATAS,SS:STACKS
MOV AX,DATAS
MOV DS,AX
call far ptr proadd
MOV AH,4CH
INT 21H
main endp
CODES ENDS
END main
public proadd
DATAS SEGMENT common
array dw 1,2,3,4,5
count dw ($-array)/2
sum dw ?
DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码
STACKS ENDS
CODES SEGMENT
pradd proc far
ASSUME CS:CODES,DS:DATAS,SS:STACKS
MOV AX,DATAS
MOV DS,AX
push ax
push cx
push si
lea si,array
mov cx,count
xor ax,ax
next:
add ax,[si]
add si,2
loop next
mov sum,ax
pop si
pop cx
pop ax
ret
proadd endp
CODES ENDS
end