[SDL] GNU GCC 3.4.x problem with inline assembly on SDL

Alex Volkov avcp-sdlmail at usa.net
Mon Sep 19 15:00:10 PDT 2005

It appears a slightly different version of that patch has already been
applied to CVS a long time ago. For CPUID opcodes, the ebx is saved into edi
and later restored from it. The mixer code has long been changed since that
patch (since rev 1.2; the S8 mixer has another bug, but it's worth its own

I really don't know what the push/pop ebx is supposed to accomplish in the
patch referenced, as ebx is already saved into edi there. It seems to have
been taken from another patch and applied here in vain.

You just have to remember one of the CDECL calling convention rules: ebx,
esi, edi registers are callee-saved, so if they get clobbered in your
function the compiler has to save them and restore on return. I am no gcc
expert, but I recall gcc likes using ebx as base in relative addressing when
in PIC mode. There is probably a bug in your gcc 3.4.x that prevents it from
correctly accounting for ebx in the clobber list. The compatibility rule
seems to be here: "do not touch ebx, or save it yourself".



From: Roberto Prieto
Sent: Monday, September 19, 2005 12:23 PM
To: sdl at libsdl.org
Subject: [SDL] GNU GCC 3.4.x problem with inline assembly on SDL

Hi all,
I have spent a lot of time trying to compile SDL (v1.2.8 and the latest of
CVS) in a new system with GNU GCC 3.4 and I was very close to became
crazy... there werent any compilitation error...but... there are a lot of
problem at runtime (most of them with my own inline assembly code).
After long troubleshooting I compiled with old GCC 3.3 and everything
started to work successfully... so I looked for something on google and I
found this:
When this patch will be integrated with CVS? I think is very important
I think this could be asked on a GNU forum but... maybe here....anyone knows
where I can find more information about that bugs? because I have a lot of
inline assembly and it failed! I imagine that I only have to add a push ebx
and pop ebx... 
Thanks in advance

Roberto Prieto
megastorm at mi.madritel.es

More information about the SDL mailing list