Subject: detecting FPU
To: None <macbsd-development@NetBSD.ORG>
From: Ken Nakata <>
List: macbsd-development
Date: 11/22/1994 13:30:36
I wrote this small assembly routine to detect whether or not FPU is
installed...  It's been a long time since I've written 68k assembly
last time, and it was Motorola syntax, so I'm not so sure if it's
correct or not.  But you'll get the basic idea.  Another problem is
that I can't decide where in the kernel I should put a call to the

I'm assuming that stack is available and it's running in supervisor
mode.  It is intended to return 1 in d0 if there is an FPU installed,
0 otherwise.

Could someone verify or even better test this code?


#include "assym.s"
#include "vectors.s"

	.globl _fpudetect
	moveml	a0-a2,sp@-
	lea	nofpu,a0		| temporary trap handler
	movl	vbr,a1
	lea	a1@(11*4),a1		| get vector address
	movl	a1@,a2			| save old f-line trap vector 
	movl	a0,a1@			| set new one
	fmovl	d0,fp0			| try an fp instruction
	movq	#1,d0			| fell through -- we have an fpu
	bra	exit

nofpu:					| oh uh, caught an f-line trap
	addq	#8,sp			| throw away stack frame
	movq	#0,d0			| we don't have an fpu
	movl	a2,a1@			| restore old f-line vector
	moveml	sp@+,a0-a2