Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to break down a NASM application into modules/packages and include them?

Tags:

assembly

nasm

I'm starting to learn the Assembly language. I'm familiar with it in the basic level. I wonder, how big application in the Assembly are organized, that is, how can I split them into modules/packages and include them into other modules? I'm talking about NASM in particular.

like image 841
ako25 Avatar asked Oct 29 '25 19:10

ako25


1 Answers

You can either:

  • Use %include
    To include an external file into the current one.
    This can be further controlled with the -i command line switch.

    You can also force NASM to pre-include a file using the -p switch.

  • Assemble multiple files
    Since NASM is not a linker, you can take advantage of the linkers' ability to... well, link files together.

    Use the GLOBAL directive to make a set of symbols visible to other modules.
    Use the EXTERN directive to import a set of symbols from other modules.

    You can pass all the object files to the linker.
    NASM (as today) can only assemble one file at a time, so a build script is needed.


The two above are not mutually exclusive but you have to basically understand the NASM output file formats to see when the latter is applicable.

like image 64
Margaret Bloom Avatar answered Oct 31 '25 08:10

Margaret Bloom