简体   繁体   English

如何将多个带有fasm的.asm文件编译为一个输出?

[英]How do I compile more than one .asm file with fasm into one output?

I want to compile multiple assembly files in fasm. 我想以fasm方式编译多个程序集文件。 I have some instructions in the one file and other instructions in the other file. 我在一个文件中有一些说明,而在另一个文件中有其他说明。 How do I link these files to a binary output ? 如何将这些文件链接到二进制输出?

And may I use extern in this case ? 在这种情况下可以使用extern吗? Or is this an illegal command ? 还是这是非法命令?

I want to compile multiple assembly files in fasm. 我想以fasm方式编译多个程序集文件。

So you have multiple .ASM source files. 因此,您有多个.ASM源文件。

  • Select one of your source files as the main source file. 选择一个源文件作为主源文件。
  • Insert in it an include preprocessor directive for every additional source file that you want in your single binary output file. 在其中为每个二进制输出文件中所需的每个其他源文件插入一个include preprocessor指令。
  • Assemble. 组装。 No linker required, FASM does it all. 不需要链接器,FASM可以完成所有工作。

Example with 3 source files 具有3个源文件的示例

; Main source is 'source1.asm'
include 'source2.asm'
include 'source3.asm'
...

I generally create an includes file (much like a header for my application) and simply include that file which lists all files to be "included". 我通常创建一个include文件(非常类似于我的应用程序的标头),然后简单地包含该文件,其中列出了所有要“包含”的文件。

include 'includes.inc'

The includes.inc will then, itself, have all the relevant inclusions listed for a "project style" structure. 然后, includes.inc本身将列出“项目样式”结构的所有相关包含物。

This is an alternative approach to what Fifoernik states (which is correct). 这是Fifoernik陈述的替代方法(正确)。

I also like to externalize data segments as well (especially when developing for Windows) into vars.inc (read & write permissions, no execution) and const.inc (read only with no write or execution permissions). 我还希望将数据段(尤其是在Windows下开发时)外部化为vars.inc (具有读取和写入权限,没有执行权限)和const.inc (仅具有无写入或执行权限的只读权限)。 Something else to ponder on a side note. 在旁注中需要考虑的其他事项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM