title: Including header file in assembly file
body: <p>I am trying to include a header file containing a macro into my main assembly file, but the compilation fails.</p>
  
  <p>Below is my <code>main.S</code> file</p>
  
   
  
  <pre class="lang-none prettyprint-override"><code>#include "common.h"
  BEGIN
      mov $0x0E40, %ax
      int $0x10
      hlt
  </code></pre>
  
  <p>Below is my <code>common.h</code> file :</p>
  
  <pre class="lang-none prettyprint-override"><code>.macro BEGIN
      LOCAL after_locals
      .code16
      cli
      ljmp $0, $1f
      1:
      xor %ax, %ax
      /* We must zero %ds for any data access. */
      mov %ax, %ds
      mov %ax, %es
      mov %ax, %fs
      mov %ax, %gs
      mov %ax, %bp
      /* Automatically disables interrupts until the end of the next instruction. */
      mov %ax, %ss
      /* We should set SP because BIOS calls may depend on that. TODO confirm. */
      mov %bp, %sp
      /* Store the initial dl to load stage 2 later on. */
      mov %dl, initial_dl
      jmp after_locals
      initial_dl: .byte 0
  after_locals:
  .endm
  </code></pre>
  
  <p>Both files are in same directory. When I do the compilation :</p>
  
  <pre class="lang-none prettyprint-override"><code>$ as --32 -o main.o main.S
  main.S: Assembler messages:
  main.S:2: Error: no such instruction: `begin'
  </code></pre>
  
  <p>What am I missing? I did a little research and got <a href="https://stackoverflow.com/questions/39457263/include-assembly-file-in-another-assembly-file">this answer</a> in SO, but its not helpful. Please help.</p>