Date: Fri, 02 Jul 1999 10:22:07 +0100 From: Roger Hardiman <roger@cs.strath.ac.uk> To: Randall Hopper <aa8vb@ipass.net> Cc: Frode Vatvedt Fjeld <frodef@acm.org>, "Daniel J. O'Connor" <darius@dons.net.au>, Geff Hanoian <boing@kusanagi.boing.com>, freebsd-stable@FreeBSD.ORG, multimedia@FreeBSD.ORG Subject: Re: MMX Message-ID: <377C84BF.33E147F2@cs.strath.ac.uk> References: <XFMail.990630103147.darius@dons.net.au> <199906300229.TAA06545@kusanagi.boing.com> <2hwvwnqh7g.fsf@dslab7.cs.uit.no> <XFMail.990630103147.darius@dons.net.au> <2hwvwnqh7g.fsf@dslab7.cs.uit.no> <19990701201236.A5532@ipass.net>
next in thread | previous in thread | raw e-mail | index | archive | help
> Frode Vatvedt Fjeld:
> |What is the preferred way for my application to determine if the CPU
> |is MMX-capable?
>
> In leiu of that, I believe I recall reading that the SIGILL approach works
> on FreeBSD. Seems like Roger Hardiman uses/used MMX on FreeBSD for some of
> his signal processing work. You might chat with him.
Indeed, I do write MMX code.
The proper way, if you want your code to be portable to other OSs
(like NetBSD/OpenBSD/Linux/ etc), is to ask the CPU what it can do.
Here is the almost proper way to determine if a CPU has MMX support.
I say _alomost_ because it uses the CPU-ID instruction.
This instruction is not on 386 machines or some early 486 machines.
There is another test you should do first to determine if there was a
CPU-ID
instruction. I'll dig that up shortly.
// mmx.c
// Detect MMX Instruction set
// Roger Hardiman
// University of Strathclyde
// August 1997
// Test for the Presence of an MMX Instruction Set
// Returns TRUE if MMX CPU, FALSE if plain CPU.
int test_mmx() {
int result;
__asm __volatile(
"movl $1,%%eax\n"
"cpuid\n"
"andl $0x800000,%%edx\n"
"shrl $23,%%edx\n"
: "=d" (result) :: "ax", "dx");
if (result) printf("MMX detected\n");
else printf("No MMX.\n");
return result;
}
My program is then full of
if (mmx_detected) {
MMX code
else
old C code
Bye
Roger
--
Roger Hardiman
Strathclyde Uni Telepresence Research Group, Glasgow, Scotland.
http://telepresence.dmem.strath.ac.uk 0141 548 2897
roger@cs.strath.ac.uk
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-multimedia" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?377C84BF.33E147F2>
