From owner-freebsd-stable Fri Jul 2 2:22:45 1999 Delivered-To: freebsd-stable@freebsd.org Received: from fleming.cs.strath.ac.uk (fleming.cs.strath.ac.uk [130.159.196.126]) by hub.freebsd.org (Postfix) with ESMTP id E28AB14F42; Fri, 2 Jul 1999 02:22:39 -0700 (PDT) (envelope-from roger@cs.strath.ac.uk) Received: from cs.strath.ac.uk (scary.dmem.strath.ac.uk [130.159.202.5]) by fleming.cs.strath.ac.uk (8.8.8/8.8.8) with ESMTP id KAA03488 Fri, 2 Jul 1999 10:21:27 +0100 (BST) Message-ID: <377C84BF.33E147F2@cs.strath.ac.uk> Date: Fri, 02 Jul 1999 10:22:07 +0100 From: Roger Hardiman Organization: Strathclyde University X-Mailer: Mozilla 4.51 [en] (X11; I; FreeBSD 3.2-STABLE i386) X-Accept-Language: en MIME-Version: 1.0 To: Randall Hopper Cc: Frode Vatvedt Fjeld , "Daniel J. O'Connor" , Geff Hanoian , freebsd-stable@FreeBSD.ORG, multimedia@FreeBSD.ORG Subject: Re: MMX References: <199906300229.TAA06545@kusanagi.boing.com> <2hwvwnqh7g.fsf@dslab7.cs.uit.no> <2hwvwnqh7g.fsf@dslab7.cs.uit.no> <19990701201236.A5532@ipass.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 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-stable" in the body of the message