title: Compile an asm bootloader with external c code
body: <p>I write a boot loader in asm and want to add some compiled C code in my project.</p>
  
  <p>I created a test function here:</p>
  
  <p><strong>test.c</strong></p>
  
  <pre><code>__asm__(".code16\n");
  
  void print_str() {
      __asm__ __volatile__("mov $'A' , %al\n");
      __asm__ __volatile__("mov $0x0e, %ah\n");
      __asm__ __volatile__("int $0x10\n");
  }
  </code></pre>
  
  <p>And here is the asm code (the boot loader):</p>
  
  <p><strong>hw.asm</strong></p>
  
  <pre><code>[org 0x7C00]
  [BITS 16]
  [extern print_str] ;nasm tip
  
  start:
  mov ax, 0
  mov ds, ax
  mov es, ax
  mov ss, ax
  mov sp, 0x7C00
  
  
  mov si, name
  call print_string
  
  mov al, ' '
  int 10h
  
  mov si, version
  call print_string
  
  mov si, line_return
  call print_string
  
  call print_str ;call function
  
  mov si, welcome
  call print_string
  
  jmp mainloop
  
  mainloop:
  mov si, prompt
  call print_string
  
  mov di, buffer
  call get_str
  
  mov si, buffer
  cmp byte [si], 0
  je mainloop
  
  mov si, buffer
  ;call print_string
  mov di, cmd_version
  call strcmp
  jc .version
  
  jmp mainloop
  
  .version:
  mov si, name
  call print_string
  
  mov al, ' '
  int 10h
  
  mov si, version
  call print_string
  
  mov si, line_return
  call print_string
  jmp mainloop
  
  name db 'MOS', 0
  version db 'v0.1', 0
  welcome db 'Developped by Marius Van Nieuwenhuyse', 0x0D, 0x0A, 0
  prompt db '&gt;', 0
  line_return db 0x0D, 0x0A, 0
  buffer times 64 db 0
  
  cmd_version db 'version', 0
  
  %include "functions/print.asm"
  %include "functions/getstr.asm"
  %include "functions/strcmp.asm"
  
  times 510 - ($-$$) db 0
  dw 0xaa55
  </code></pre>
  
  <p>I need to call the c function like a simple asm function
  Without the extern and the call <code>print_str</code>, the asm script boot in VMWare.</p>
  
  <p>I tried to compile with:</p>
  
  <pre><code>nasm -f elf32 
  </code></pre>
  
  <p><strong><em>But i can't call org 0x7C00</em></strong></p>