I recently programmed a simple Assembly program, which opened a SDL2 Window.
Now I'm tying to implement a close function by using the SDL_WaitEvent Function.
I am using this script to compile:
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
And this is the Assembly Code:
.section .rodata
windowTitle: .string "Window"
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
Can anyone explain to me, why there is coming this Segmentation Fault error?
I am using 64 bit Mx-Linux an the gcc version 10.2.1.