title: NASM Segmentation Fault ( strchrnul )
body: <p>Need help in a nasm code. Have to find if intgr1 mod intgr2==0, but cant use DIV. 
  I am getting a segmentation fault. From gdb I found:</p>
  
  <p>Program received signal SIGSEGV, Segmentation fault.</p>
  
  <p>0x00007ffff7aacd2a in strchrnul () from /lib/x86_64-linux-gnu/libc.so.6</p>
  
  <p>My program:</p>
  
  <pre><code>;nasm -f elf64 main.nasm
  ;gcc -o main main.o -lc
  
  
  section .text
      global main
      extern scanf 
      extern printf
  
  section .data
      request1: db "Dividendo: ", 0
      request2: db "Divisor: ", 0
      message1: db "Eh divisivel", 0
      message2: db "Nao eh divisivel", 0
      formatin: db "%d", 0
      intgr1: times 4 db 0 ; 32-bits integer = 4 bytes
      intgr2: times 4 db 0 ;
  
  main:
      push request1   ;imprime pedido dividendo
      call printf
      add esp, 4
  
      push intgr1 ;scanf do dividendo
      push formatin
      call scanf
      add esp, 8
  
      push request2   ;imprime pedido divisor
      call printf
      add esp, 4
  
      push intgr2 ;scanf do divisor
      push formatin
      call scanf
      add esp, 8
  
      mov eax, [intgr1]   
      mov ebx, [intgr2]
      jmp L1
  
  L1: cmp eax, ebx    ;compara dividendo divisor
      jb L2       ;se &lt; entao vai pra l2
      sub eax,ebx ;dividendo:=dividendo-divisor
      jmp L1      ;vai pra L1
  
  L2: cmp eax, 0  ;compara dividendo e 0
      je L3       ;se igual vai para l3
      jmp L4      ;se nao vai para l4
  
  L3: push message1   ;imprime que eh divisivel
      call printf
      add esp, 4
  
  L4:push message2    ;imprime que nao eh
      call printf
      add esp, 4
  
      MOV AL, 1   ;termina o programa
      MOV EBX, 0 
      INT 80h
  </code></pre>
  
  <p>Anyone have an idea of what is wrong?</p>
  
  <p>Thanks.</p>