How to include other sources in FASM
<p>I'm trying to split up my sources into more organized files, but I'm running into some problems including these sources.</p>

<p>How do I include these sources?
My main programs are of the PE64 format, but when I set my sub sources' format fasm doesn't want to compile it.
When I remove it, fasm says something about ending includes (like kernel64.inc) and already existing symbols.</p>

<p>This is how I'm trying to include in the main file <code>include printInt.asm</code>.
I'm exporting with :</p>

<pre><code>export 'printLib.dll',\
    printInt, 'printInt'
</code></pre>

<p>This is the sub source:</p>

<pre><code>;format PE64

include 'win64a.inc'

;entry start

section '.code' code readable executable
start:
    mov rcx, 1234567
    call printInt
    call newline
    mov rcx, -54321
    call printInt

;    invoke ExitProcess, 0

printInt:
    push r10
    push r11
    push r12
    push r13
    push r14
    sub rsp, 32

    mov r12, rcx
    mov r13, 10
    xor r14, r14

    test r12, r12
    jns .e1
        neg r12
        mov rcx, 45
        call [putchar]    
    .e1:

    .l1:
        mov rax, r12
        mov rdx, 0
        div r13

        mov rcx, rdx
        add rcx, 0x30
        mov r12, rax
        push rcx
        inc r14
        test r12, r12
        jnz .l1

    mov r12, r14    
    .l2:
        pop rcx
        sub rsp, 32
        call [putchar]
        add rsp, 32
        dec r14
        jnz .l2

    add rsp, 32
    pop r14
    pop r13
    pop r12
    pop r11
    pop r10
ret

newline:
   sub rsp, 32
   mov rcx, 0xa
   call [putchar]
   mov rcx, 0xd
   call [putchar]
   add rsp, 32
ret

rdtsc64x:
   rdtsc
   shl rdx, 32
   add rax, rdx
   mov rdx, 0
ret

;section '.rdata' data readable writeable
;   print1 db 'printInt downwards: ', 0
;   print2 db 'printInt upwards: ', 0

section '.idata' import data readable writeable

library kernel, 'kernel32.dll',\
    msvcrt, 'msvcrt.dll'

;import kernel, ExitProcess, 'ExitProcess'
import msvcrt, printf, 'printf',\
    putchar, 'putchar'
</code></pre>

<p>What I did find about this is: <a href="https://stackoverflow.com/questions/24480871/fasm-passing-parameters-to-an-external-procedure">FASM- passing parameters to an external procedure</a></p>

<p>But this does not work for me, and also is about a different format.</p>

<p>How can I include my own sources in PE64 format?</p>