Does MASM assembling multiple source files and linking them together?

泪湿孤枕 提交于 2019-12-25 07:13:24

问题


I was trying to see if asm language support function based linked like "C" language. E.g. I have got "m.asm":

assume cs:code
code segment
start:
  mov ax,20h
  call s
  mov ah,4ch
  int 21h
code ends
end start

In which "s" is a symbol not existing in the source code, then I've got n.asm file to define a symbol (a label in fact)

code segment
s:
  mov bx,4h
  div bx
code ends

In fact m.asm fails to compile, telling me that "s" is a symbol not defined. How can I resolve this problem and meet my request?


回答1:


You need to declare function s as visible to other modules that wish to access it (e.g. via call) in n.asm using the public directive and you need to declare s as an external reference using the extern directive in m.asm.

This is fine for a small number of declarations but if your modules grow to any substantial size you may want to use an include header files to manage that.



来源:https://stackoverflow.com/questions/38218712/does-masm-assembling-multiple-source-files-and-linking-them-together

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!