Ret Failure with SDL using FASM on Win32

Posted by Jon Purdy on Stack Overflow See other posts from Stack Overflow or by Jon Purdy
Published on 2010-03-31T12:01:12Z Indexed on 2010/05/12 3:34 UTC
Read the original article Hit count: 295

Filed under:
|
|
|
|

I'm using SDL with FASM, and have code that's minimally like the following:

format ELF

extrn _SDL_Init
extrn _SDL_SetVideoMode
extrn _SDL_Quit
extrn _exit
SDL_INIT_VIDEO equ 0x00000020

section '.text'
public _SDL_main
_SDL_main:

    ccall   _SDL_Init, SDL_INIT_VIDEO
    ccall   _SDL_SetVideoMode, 640, 480, 32, 0
    ccall   _SDL_Quit
    ccall   _exit, 0 ; Success, or
    ret              ; failure.

With the following quick-and-dirty makefile:

SOURCES = main.asm
OBJECTS = main.o
TARGET = SDLASM.exe
FASM = C:\fasm\fasm.exe

release : $(OBJECTS)
    ld $(OBJECTS) -LC:/SDL/lib/ -lSDLmain -lSDL -LC:/MinGW/lib/ -lmingw32 -lcrtdll -o $(TARGET) --subsystem windows

cleanrelease :
    del $(OBJECTS)

%.o : %.asm
    $(FASM) $< $@

Using exit() (or Windows' ExitProcess()) seems to be the only way to get this program to exit cleanly, even though I feel like I should be able to use retn/retf. When I just ret without calling exit(), the application does not terminate and needs to be killed. Could anyone shed some light on this? It only happens when I make the call to SDL_SetVideoMode().

© Stack Overflow or respective owner

Related posts about sdl

Related posts about fasm