title: Using the return value of strstr() in NASM?
body: <p>I am trying to use the strstr C function in a NASM assembly program but cannot seem to get it to print out correctly.  I have tried multiple variations of this, but I think I may be misinterpreting how NASM returns the pointer value from C as I either get a blank line returned in the printf or a '(null)'.  Could some help fill me in as why I cannot get the correct return value to be printed?</p>
  
  <pre><code>section .data
  
      str1 db "Here is some text with a word",0x0A,0x00
      str2 db "text",0x0A, 0x00
      strFmt db "%s",0x0A,0x00
  
      global _start
      extern printf
      extern strstr
  
  section .text
  
  _start:
  
      push ebp
      mov ebp, esi
  
      push str2
      push str1
      call strstr
      add esp, 8
  
      mov dword [myString], eax
  
      push dword [myString]
      push strFmt
      call printf
      add esp, 8
  
  _exit:
      mov ebx, 0
      mov eax, 1
      int 0x80
  </code></pre>