Assembly functions, MMX detection

Hi all,

I’ve got a quick question about using assembly functions in general and
MMX routines in SDL in particular.

I’d like to make use of assembly functions that are compiled using the
NASM compiler. SDL does that already for the blitting with parts from
the hermes library.

Does someone have a simple asm example to start with - I find the
NASM documentation a bit fuzzy on this topic. What I’d like is some
hints and tips for an asm routine that uses few variables/pointers as
input and returns an integer and gets called from the main C code as in:

… C-code …
result=funkyAsmRoutine(&pixels, width,height);

… asm code …
GLOBAL _funkyAsmRoutine
SECTION .text
_funkyAsmRoutine:
???

I do have working MMX asm code already, but it uses static global
variables for parameter passing and I’d like to recode this as
functions.

Are there any things required in the asm-code when cross-compiling for
Linux (nasm -f elf) and Windows (nasm -f win32) using mingw32?

Also I’d like to make use of MMX code … is MMX detection implemented
in SDL already?

Ciao
Andreas–
| Andreas Schiffler aschiffler at home.com |
| Senior Systems Engineer - Deskplayer Inc., Buffalo |
| 4707 Eastwood Cres., Niagara Falls, Ont L2E 1B4, Canada |
| +1-905-371-3652 (private) - +1-905-371-8834 (work/fax) |

Check the DWORDs at esp (I usually copy esp to ebp and use ebp for the
look-ups) for the parameters. Usually I think you’ll find the first
parameter at [0] and the last at [(numparams-1)*4]

That is assuming all parameters are DWORDS (32-bit). I’m not sure what
happens when a parameter isn’t 32-bit. (if it uses 32 bits anyway or not)

The return value is usually taken to be what’s in EAX/AX/AL, depending on
the type.

I have no clue what happens on a non-32-bit machine, though…–

Olivier A. Dagenais - Software Architect and Developer

“Andreas Schiffler” wrote in message
news:3AA80F3E.51AF23BD at home.com

Hi all,

I’ve got a quick question about using assembly functions in general and
MMX routines in SDL in particular.

I’d like to make use of assembly functions that are compiled using the
NASM compiler. SDL does that already for the blitting with parts from
the hermes library.

Does someone have a simple asm example to start with - I find the
NASM documentation a bit fuzzy on this topic. What I’d like is some
hints and tips for an asm routine that uses few variables/pointers as
input and returns an integer and gets called from the main C code as in:

… C-code …
result=funkyAsmRoutine(&pixels, width,height);

… asm code …
GLOBAL _funkyAsmRoutine
SECTION .text
_funkyAsmRoutine:
???

I do have working MMX asm code already, but it uses static global
variables for parameter passing and I’d like to recode this as
functions.

Are there any things required in the asm-code when cross-compiling for
Linux (nasm -f elf) and Windows (nasm -f win32) using mingw32?

Also I’d like to make use of MMX code … is MMX detection implemented
in SDL already?

Ciao
Andreas


| Andreas Schiffler aschiffler at home.com |
| Senior Systems Engineer - Deskplayer Inc., Buffalo |
| 4707 Eastwood Cres., Niagara Falls, Ont L2E 1B4, Canada |
| +1-905-371-3652 (private) - +1-905-371-8834 (work/fax) |

Also I’d like to make use of MMX code … is MMX detection implemented
in SDL already?

yes but it isn’t exported. there are plans to change how this works for 1.3
anyway, to make a common arch feature detection and asm interface for all
platforms

Also I’d like to make use of MMX code … is MMX detection implemented
in SDL already?

yes but it isn’t exported. there are plans to change how this works for 1.3
anyway, to make a common arch feature detection and asm interface for all
platforms

Really? :wink:

-Sam Lantinga, Lead Programmer, Loki Entertainment Software

Really? :wink:

really