Safe x-platform asm

how are people going about integrating asm into their projects in a cross
platform manner?

i wish to add an optimised asm blitter to a little project i’m working on, and
wish to retain SDL’s cross-platform ability. perhaps nasm is the way to go? has
anyone tried using nasm and visualc++?

Charlie Robson
Sony Computer Entertainment Europe

IMPORTANT NEWS ANNOUNCEMENT FROM SCEE MIS

New scee.net email address will replace playstation.sony.com**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
postmaster at scee.net

This footnote also confirms that this email message has been checked
for all known viruses.


SCEE 1999

“Charlie_Robson” == <Charlie_Robson at scee.net> writes:

Charlie_Robson> i wish to add an optimised asm blitter to a little
Charlie_Robson> project i’m working on, and wish to retain SDL’s
Charlie_Robson> cross-platform ability. perhaps nasm is the way to
Charlie_Robson> go? has anyone tried using nasm and visualc++?

To solve this problem, I did a horrible hack where I cast an array of
bytes to a function pointer and called it. I wrote the code in
assembly language and ran a little tool to dump out the raw bytes.
This trick works on a variety of x86 C compilers, including MSVC and
gcc.

Interestingly it crashes Intel’s C compiler with an internal error,
probably trying to inline the array or something. :slight_smile: But if the
array is in a different file than the caller you should be OK.

One drawback to this technique is there’s no portable way to specify
the alignment of the code, although you can get up to 8 byte alignment
by using a struct or union containing a “double”.

-Mat

Charlie_Robson at scee.net wrote:

how are people going about integrating asm into their projects in a cross
platform manner?

i wish to add an optimised asm blitter to a little project i’m working on, and
wish to retain SDL’s cross-platform ability. perhaps nasm is the way to go? has
anyone tried using nasm and visualc++?

Charlie Robson
Sony Computer Entertainment Europe
http://www.playstation-europe.com

IMPORTANT NEWS ANNOUNCEMENT FROM SCEE MIS

New scee.net email address will replace playstation.sony.com


This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
postmaster at scee.net

This footnote also confirms that this email message has been checked
for all known viruses.


SCEE 1999

Yep they work fine you just have to remember to use -f win32 rather than -f elf as
the output object file format. You can then use VC’s make facilities to
automagically create the object files etc. Anyhow it all works very well together.
I have project which compiles across a number of x86 platforms(NetBSD, FreeBSD,
Linux and Win32) using nasm for the assemnbler in conjunction with SDL.

Willy

Willy wrote:

Charlie_Robson at scee.net wrote:

how are people going about integrating asm into their projects in a cross
platform manner?

i wish to add an optimised asm blitter to a little project i’m working on, and
wish to retain SDL’s cross-platform ability. perhaps nasm is the way to go? has
anyone tried using nasm and visualc++?

Charlie Robson
Sony Computer Entertainment Europe
http://www.playstation-europe.com

IMPORTANT NEWS ANNOUNCEMENT FROM SCEE MIS

New scee.net email address will replace playstation.sony.com


This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
postmaster at scee.net

This footnote also confirms that this email message has been checked
for all known viruses.


SCEE 1999

Yep they work fine you just have to remember to use -f win32 rather than -f elf as
the output object file format. You can then use VC’s make facilities to
automagically create the object files etc. Anyhow it all works very well together.
I have project which compiles across a number of x86 platforms(NetBSD, FreeBSD,
Linux and Win32) using nasm for the assemnbler in conjunction with SDL.

Willy

Doh forgot to add that in order to use elf as well as other the object formats you
must give each function two names one with an underscore ‘_’ for a.out coff and win32
and one without for elf and thus you must correspondingly exoprt the two names for
the function.

Willy

how are people going about integrating asm into their projects in a cross
platform manner?
i wish to add an optimised asm blitter to a little project i’m working on, and
wish to retain SDL’s cross-platform ability. perhaps nasm is the way to go? has
anyone tried using nasm and visualc++?

It is pretty straightforward to get one asm routine working on both
Linux/X and Win32 using NASM. The helper macros that come with nasm 0.98
are very helpful for declaring arguments and passing parameters in ways
that work on both platforms.
I can send you templates for asm files if you like. You can also add
rewrite portions of SDL itself in asm if you feel the need - you just
need to change some of make/linux/rules and make/win32/rules files to
reflect them.–
±---------------------------------------------------------+
Paul Furber, TML Trade Publishing
"I’ll tell you what’s wrong with the scientific power you’re
wielding - it didn’t require any discipline to attain it"
Dr. Malcom, Jurassic Park