title: Assembly SDL2 program segfaults?
body: <p>I recently programmed a simple Assembly program, which opened a SDL2 Window.</p>
  <p>Now I'm tying to implement a close function by using the SDL_WaitEvent Function.</p>
  <p>I am using this script to compile:</p>
  <pre><code>clear
  gcc -c pong.S -o pong.o
  gcc pong.o -lSDL2 -nostdlib -e main -o pong -I /usr/local/include -L /usr/local/lib
  ./pong
  </code></pre>
  <p>And this is the Assembly Code:</p>
  <pre><code>    .section    .rodata
  
  windowTitle:    .string &quot;Window&quot;
  window:     .zero   8
  event:      .zero   56
  
  .text
  
  .globl main
  main:
  
  
      #Init SDL
      mov $62001, %edi
      call    SDL_Init@PLT
  
  
      #Create WIndow
      movq    windowTitle(%rip), %rdi
      movl    $4, %r9d
      movl    $600, %r8d
      movl    $800, %ecx
      movl    $100, %edx
      movl    $100, %esi
      movq    %rax, %rdi
      call    SDL_CreateWindow
      movq    %rax, window(%rip)
  
  loop:
  
      leaq    event(%rip), %rdi
      call    SDL_WaitEvent@PLT
      movl    event(%rip), %eax
      cmpl    $256, %eax
      jne loop    
  
  
  end:
      ret 
  </code></pre>
  <p>Can anyone explain to me, why there is coming this Segmentation Fault error?</p>
  <p>I am using 64 bit Mx-Linux an the gcc version 10.2.1.</p>