title: NASM - Section .data is not working as expected
body: <p>I am learning about the bootloaders, and I used this code from here <a href="https://wiki.osdev.org/Babystep2" rel="nofollow noreferrer">https://wiki.osdev.org/Babystep2</a> to create 'Hello,World!' bootloader.</p>
  <pre><code>; boot.asm
     mov ax, 0x07c0
     mov ds, ax
   
     mov si, msg
     cld
  ch_loop:lodsb
     or al, al ; zero=end or str
     jz hang   ; get out
     mov ah, 0x0E
     mov bh, 0
     int 0x10
     jmp ch_loop
   
  hang:
     jmp hang
   
  msg   db 'Hello World', 13, 10, 0
     times 510-($-$$) db 0
     db 0x55
     db 0xAA
  </code></pre>
  <p>The above code works perfectly fine. But when I tried to modify it to use the standard NASM syntax as below, it prints nothing and there are no error messages!</p>
  <pre><code>section .data
      msg:    db 'Hello, World!', 13, 10, 0
  
  section .text
      global _start
  _start:
      mov ax, 0x07c0
      mov ds, ax
      mov si, msg
      cld
      
  _ch_loop:
      lodsb
      or al, al
      jz _hang
      mov ah, 0x0E
      mov bh, 0
      int 0x10
      jmp _ch_loop
  
  _hang:
      jmp _hang
      times 510-($-$$) db 0
      db 0x55
      db 0xAA
  </code></pre>
  <p>The above code doesn't print anything and there is no error message. However when I run the below code it works!</p>
  <pre><code>section .text
      global _start
  _start:
      msg:    db 'Hello, World!', 13, 10, 0
      mov ax, 0x07c0
      mov ds, ax
      mov si, msg
      cld
      
  _ch_loop:
      lodsb
      or al, al
      jz _hang
      mov ah, 0x0E
      mov bh, 0x00
      int 0x10
      jmp _ch_loop
  
  _hang:
      jmp _hang
      times 510-($-$$) db 0
      db 0x55
      db 0xAA
  </code></pre>
  <p>What is going wrong here. Why <code>section .data</code> is not working as expected?</p>