;-------------------------------------------------------; MASM 汇编多模块编译,连接示例;------------------------------------------------------- ; 模块 1 , 文件 data.asm ;------------------------------------------------------- extrn msg:byteextrn funNewLine:farpublic newLine data segment common newLine db 10,13,'$'data ends code segment assume ds:data,cs:codemain proc farstar: 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 retmain endpcode ends end star ; 模块 2, 文件 test.asm;------------------------------------------------------- extrn newLine:bytepublic funNewLinepublic msg data segment public msg db 'hello world$'data ends code1 segment assume ds:data,cs:code1funNewLine proc farstar: mov ax,data mov ds,ax lea dx,newLine mov ah,09h int 21h retfunNewLine endpcode1 ends end star ;------------------------------------------------------- 编译,连接过程如下;-------------------------------------------------------E:\program\masmcode\MASM>masm data.asmMicrosoft (R) Macro Assembler Version 5.00Copyright (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 ErrorsE:\program\masmcode\MASM>masm test.asmMicrosoft (R) Macro Assembler Version 5.00Copyright (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 ErrorsE:\program\masmcode\MASM>link data test Microsoft (R) Overlay Linker Version 3.60Copyright (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>datahello world E:\program\masmcode\MASM>

评论