title: Why am I getting this result from 32 bit NASM assembly code?
body: <p>My NASM assembly code (in Linux) is as follows:</p>
  
  <pre><code>   %macro write_string 2
      push %1
      call printf
      pop eax
      add esp, %2
      %endmacro
  section .text
     global main            ;must be declared for using gcc
     extern printf
  main:
     push ebp
     mov ebp, esp
     write_string msg1, len1
     write_string msg2, len2
     write_string msg3, len3
     mov esp, ebp
     pop ebp
  
   mov eax,1                ;system call number (sys_exit)
    int 0x80                 ;call kernel
  
  section .data
  msg1  db 'Hello, programmers!',0xA,0xD
  len1  equ $ - msg1
  msg2  db 'Welcome to the world of,', 0xA,0xD
  len2  equ $- msg2
  msg3  db 'Linux assembly programming! '
  len3  equ $- msg3
  </code></pre>
  
  <p>When this is executed (after nasm -f elf -o writeStrings.o writeStrings.asm &amp;&amp; gcc -o writeStrings writeStrings.o), I get the following output:</p>
  
  <blockquote>
  <pre><code>Hello, programmers! Welcome to the world of, Linux assembly
  programming! Welcome to the world of,
  </code></pre>
  </blockquote>
  
  <p>Can anyone tell me why the "Welcome to the world of," is getting duplicated?</p>
  
  <p>Any help would be appreciated!</p>
  
  <p><strong>Update:</strong>
  After adding the 0x00 after each msg, now the output is:
  Hello, programmers!
  Welcome to the world of,</p>
  
  <p>The third print is not outputting now.  </p>
  
  <p><strong>Update:</strong>
  I was able to get it working.  Thanks so much for your help!</p>