🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.amiga.tech
2 messages
2 total messages Started by Lamonte Koop Sun, 16 Dec 1990 23:16
68881/68882 programming
#7511
Author: Lamonte Koop
Date: Sun, 16 Dec 1990 23:16
15 lines
1221 bytes
Does anyone have some good examples of DIRECTLY accessing the 68881 or 68882
math coprocessors from within a program? (without going through the math
libraries).  Specifically, I'm looking for assembly source examples if
possible.  I have a partially working code model, but would be interested to
see other examples or hear other ideas about the subject as I have hit a few 
'interesting' effects.
 

                             LaMonte Koop
 Internet: lkoop@pnet01.cts.com         ARPA: crash!pnet01!lkoop@nosc.mil
           UUCP: {hplabs!hp-sdd ucsd nosc}!crash!pnet01!lkoop
  A scientist is one who finds interest in the kinetic energy of Jell-O
   moving at ridiculous velocities...an engineer is one who can find a
               real-life application for such silliness.
Re: 68881/68882 programming
#7519
Author: John Schultz
Date: Tue, 18 Dec 1990 00:52
77 lines
2678 bytes
In <6361@crash.cts.com> lkoop@pnet01.cts.com (Lamonte Koop) writes:


>Does anyone have some good examples of DIRECTLY accessing the 68881 or 68882
>math coprocessors from within a program? (without going through the math
>libraries).  Specifically, I'm looking for assembly source examples if
>possible.  I have a partially working code model, but would be interested to
>see other examples or hear other ideas about the subject as I have hit a few 
>'interesting' effects.
> 

  Using the 881/882 is just as easy as the 030. Here's a simple example 
that computes distance. Pick up "68030 Assembly Language Reference", by
Steve Williams [Addision Wesley]. It's got C and equivalent 882 asm examples
(in addition to 030 examples).

; This function works on long integers. It converts the longs to 
; reals with the fmove.l instruction, sums the squares, then takes the
; sqrt, then fmove.l converts back to long. fmul could also be used
; but fsglmul is faster.

	section distance,code

	OPT	p=68020/68881	; Necessary for Adapt to use
                                ; 020/030/881/882

	xdef _distance

; extern long __asm distance64(register __d0 long x,
;                              register __d1 long y,
;                              register __d2 long z);
_distance:
	fmove.l	d0,fp0
	fsglmul	fp0,fp0
	fmove.l	d1,fp1
	fsglmul	fp1,fp1
	fadd	fp0,fp1
	fmove.l	d2,fp0
	fsglmul	fp0,fp0
	fadd	fp1,fp0
	fsqrt	fp0
	fmove.l	fp0,d0
	rts

	END

--------------------------------------------------------------

Here's the code and cycles:
PMA 68030+ Program Module Analyzer V17 ADAPT Release 1.00
Copyright ) 1990, HoweSoft, Inc. All Rights Reserved.
*  Program_unit #0 name "<UNNAMED>".
*  Hunk_Name #0 name "distance".
*  Code_Hunk [PUBLIC] #0 Length = 44 bytes [11 longwords]
	fmove.l	D0,FP0				; 60	CYCLES
	fsglmul.x	FP0,FP0			; 59	CYCLES
	fmove.l	D1,FP1				; 60	CYCLES
	fsglmul.x	FP1,FP1			; 59	CYCLES
	fadd.x	FP0,FP1				; 51	CYCLES
	fmove.l	D2,FP0				; 60	CYCLES
	fsglmul.x	FP0,FP0			; 59	CYCLES
	fadd.x	FP1,FP0				; 51	CYCLES
	fsqrt.x	FP0				; 107	CYCLES
	fmove.l	FP0,D0				; 100	CYCLES
	rts					; 16	CYCLES
	DC.W	0
* 682 Total Cycles
*  Hunk_Ext:
*  Type = ext_def, Name = "_distance"
*  Hunk_End.

  Pretty fast, eh?


  Have fun,

  John
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads