> 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
[EMAIL PROTECTED]
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-stable" in the body of the message