;-------------------------------------------------------
; MASM 汇编多模块编译,连接示例
;-------------------------------------------------------
; 模块 1 , 文件 data.asm
;-------------------------------------------------------
extrn msg:byte
extrn funNewLine:far
public newLine
data segment common
newLine db 10,13,'$'
data ends
code segment
assume ds:data,cs:code
main proc far
star: push ds
xor ax,ax
push ax
mov ax,data
mov ds,ax
lea dx,msg
mov ah,09h
int 21h
call far ptr funNewLine
ret
main endp
code ends
end star
; 模块 2, 文件 test.asm
;-------------------------------------------------------
extrn newLine:byte
public funNewLine
public msg
data segment public
msg db 'hello world$'
data ends
code1 segment
assume ds:data,cs:code1
funNewLine proc far
star: mov ax,data
mov ds,ax
lea dx,newLine
mov ah,09h
int 21h
ret
funNewLine endp
code1 ends
end star
;-------------------------------------------------------
编译,连接过程如下
;-------------------------------------------------------
E:\program\masmcode\MASM>masm data.asm
Microsoft (R) Macro Assembler Version 5.00
Copyright (C) Microsoft Corp 1981-1985, 1987. All rights reserved.
Object filename [data.OBJ]:
Source listing [NUL.LST]:
Cross-reference [NUL.CRF]:
50316 + 449956 Bytes symbol space free
0 Warning Errors
0 Severe Errors
E:\program\masmcode\MASM>masm test.asm
Microsoft (R) Macro Assembler Version 5.00
Copyright (C) Microsoft Corp 1981-1985, 1987. All rights reserved.
Object filename [test.OBJ]:
Source listing [NUL.LST]:
Cross-reference [NUL.CRF]:
50356 + 449916 Bytes symbol space free
0 Warning Errors
0 Severe Errors
E:\program\masmcode\MASM>link data test
Microsoft (R) Overlay Linker Version 3.60
Copyright (C) Microsoft Corp 1983-1987. All rights reserved.
Run File [DATA.EXE]:
List File [NUL.MAP]:
Libraries [.LIB]:
LINK : warning L4021: no stack segment
E:\program\masmcode\MASM>data
hello world
E:\program\masmcode\MASM>
评论