title: Compare two strings in x86 assembly
body: <p>I want to compare two strings in x86 assembly. One of them is read from a file and the other one is read from keyboard and both are saved in a variable. </p>
  
  <p>I have no idea how to compare these two variables. I'll be so excited if someone would give me an example or something that can help me.</p>
  
  <pre><code>.386
  .model flat, stdcall
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  includelib msvcrt.lib
  include Macro.asm
  
  extern exit: proc
  extern printf:proc
  extern scanf:proc
  extern strlen:proc
  extern fscanf:proc
  extern fopen:proc
  extern fprintf:proc
  extern fclose:proc
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  public start
  
  
  .data
  format_sir db "%s", 0
  format_afisare  db "%s", 0
  format_zecimal db "&amp;d", 0
  mod_citire db "r",0
  mod_scriere db "w",0
  pointer_fisier_sursa dd 0
  pointer_fisier_destinatie dd 0
  nume_fisier db 20 dup(0)
  fpass db 20 dup(0)
  fuser db 20 dup(0)
  user db 20 dup(0)
  pass db 20 dup(0)
  
  
  .code
  start:
  
  
      ;read file name
      citire_fisier:
      push offset nume_fisier
      push offset format_sir
      call scanf
      add esp,8
  
  
      ;open the file in read mode
      deschide_fisier_citire nume_fisier, mod_citire, pointer_fisier_sursa
  
      cmp pointer_fisier_sursa,0   
      jne citire_user_parola   
      jmp citire_fisier 
  
  
  
      citire_user_parola:
      ;read from file
      Push offset fuser 
      Push offset format_sir 
      Push pointer_fisier_sursa
      Call fscanf
      Add esp,12
  
      push offset fpass 
      push offset format_sir
      push pointer_fisier_sursa
      call fscanf
      add esp,12
  
      ;read from keyboard
      push offset user
      push offset format_sir
      call scanf
      add esp,8
  
      push offset pass
      push offset format_sir
      call scanf
      add esp,8
  </code></pre>
  
  <p>Macro.asm :</p>
  
  <pre><code> deschide_fisier_citire macro nume_fisier, mod_deschidere, pointer_fisier_sursa
  
      push offset mod_deschidere
      push offset nume_fisier
      call fopen
      mov pointer_fisier_sursa ,eax
      add esp,8
  endm
  
  
  inchidere_fisier macro pointer_fisier_sursa
  
      push pointer_fisier_sursa
      call fclose
      add esp,4
  endm 
  </code></pre>