正文

汇编多模块编译,连接2007-11-06 12:55:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/lingdlz/30795.html

分享到:

;-------------------------------------------------------
; 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>

阅读(6095) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册