简体   繁体   中英

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

I want to compile multiple assembly files in 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 ? Or is this an illegal command ?

I want to compile multiple assembly files in fasm.

So you have multiple .ASM source files.

  • 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.
  • Assemble. No linker required, FASM does it all.

Example with 3 source files

; 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 'includes.inc'

The includes.inc will then, itself, have all the relevant inclusions listed for a "project style" structure.

This is an alternative approach to what Fifoernik states (which is correct).

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). Something else to ponder on a side note.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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