I’m trying to call SDL functions from assembly code, and assemble it
with NASM and link it using MinGW under Windows. I’ve gotten it to
assemble and link just fine, but when I run the program it crashes. I
think I’m just missing something. Here’s the assembly code:
--------------------------sdl_test.asm-------------------------------
BITS 32
GLOBAL _main
EXTERN _SDL_Init
EXTERN _SDL_Quit
EXTERN _SDL_SetVideoMode
SDL_INIT_VIDEO EQU 00000020h
SECTION .text
_main
push dword SDL_INIT_VIDEO
call _SDL_Init
add esp, 4
push dword 0
push dword 32
push dword 480
push dword 640
call _SDL_SetVideoMode
add esp, 16
call _SDL_Quit
ret
--------------------------sdl_test.asm-------------------------------
and the Makefile:
----------------------------Makefile---------------------------------
PROGNAME=sdl_test
all: $(PROGNAME).exe
clean:
-rm $(PROGNAME).exe
remake: clean all
%.exe: %.o
D:\MinGW\bin\gcc -o sdl_test sdl_test.o -lmingw32 libSDLmain.a
libSDL.a -mwindows
%.o: %.asm
nasm -f coff -o$ $.o $< -l $.lst
----------------------------Makefile---------------------------------
I’m using the MinGW devel version of the SDL libraries to link against.
In case it helps, the crash seems to occur during the call to SDL_Init.
Thanks,
Shawn Lindberg