How to link two nasm source files

前端 未结 1 1138
一整个雨季
一整个雨季 2021-01-12 13:49

I\'ve got a file that defines very basic IO functions and I want to create another file that uses this file.

Is there a way to link these two files up?

print

相关标签:
1条回答
  • 2021-01-12 13:58

    Sure - you just need to use the linker. Assemble each of your files:

    nasm -o prints.o prints.asm
    nasm -o usingPrintTest.o usingPrintTest.asm
    

    You can then pass the output objects to your linker. Something like:

    gcc -o myProgramName prints.o usingPrintTest.o
    

    Using gcc as the linker driver can solve some funny business with linking the OS libraries you need for your program to run. You might need to make some declarations in usingprintTest.asm to let it know that print_Achar and os_return are going to be defined elsewhere - in nasm, you'll use the extern assembler directive:

    extern print_Achar
    extern os_return
    
    0 讨论(0)
提交回复
热议问题