title: Searching a string in a text
body: <p>I have to write a program using x86 assembly that can search for a string in a text. I am trying really hard but I am just a beginner in assembly and just can not make anything that works. This is what I tried to write, it is probably realy messed up but I will be glad for any advices. Is at least anything good in it? </p>
  
  <pre><code>%include 'rw32.inc'     ; library
  
  [segment .data use32]   
  
  sMessage1 db  "Hello World!",0      ;main text
  sMessage2 db  "llo",0               ;searched string
  sMessage3 db  "Searched string was found in main string",0
  sMessage4 db  "Searched string was not found in main string",0 
  
  [segment .code use32]   
  
  prologue                ; macro
  
  
           mov di,sMessage1     
           mov si,sMessage2
           mov al,[si]
  HOP:     cmp di,0
           je ENDOFTEXT
           cmp si,0
           je FINISHED    
           cld
           scasb
           jz HOP
           add si,1
           jmp HOP
  ENDOFTEXT:
           mov si,sMessage3
           call WriteString
           jmp END
  FINISHED:
           mov si,sMessage4
           call WriteString
  END:          
  
  epilogue                ; macro  
  </code></pre>