home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.dsp:2060 comp.sys.next.programmer:5885
- Newsgroups: comp.dsp,comp.sys.next.programmer
- Path: sparky!uunet!stanford.edu!leland.Stanford.EDU!phaedrus
- From: phaedrus@leland.Stanford.EDU (Avery Wang)
- Subject: Fast arccos for the DSP 56001 code here
- Message-ID: <1992Aug31.155659.21355@leland.Stanford.EDU>
- Sender: news@leland.Stanford.EDU (Mr News)
- Organization: DSG, Stanford University, CA 94305 USA
- Date: Mon, 31 Aug 92 15:56:59 GMT
- Lines: 49
-
- Hi DSP hackers-
- A few months ago I wrote a simple inverse-table lookup algorithm for an inverse
- cosine on the DSP 56001 from Motorola. The output is normalized to between 0
- and 127 = (0 to Pi). You get 7 bits of accuracy, which is all you can really
- get from an inverse Sine-ROM lookup. Incidentally, this algorithm can be
- easily adapted to do an inverse table lookup on any monotonically decreasing
- function in tabular form (128 elements).
-
- All I ask is for you to send me email telling me that you think it's useful, so
- I'll feel good and be encouraged to put more stuff on the net in the future.
-
- =======================================================================
- ; arccos.asm
- ; Calculates the arc-cosine of the input to 8 bits.
- ; The output is between 0 and +127 and is in a
- ;
- ; Copyright! February 20,1992
- ; Free for non-profit usage
- ;
- ; Avery Wang
- ; Ruhr-Uni-Bochum
- ; Institut fuer Neuroinformatik
- ; ND03, Postfach 102148
- ; W-4630 Bochum
- ; Germany
- ; avery@neuroinformatik.ruhr-uni-bochum.de or
- ; awang@isl.stanford.edu
-
- ; uses the Sine-ROM and simply does an inverse table lookup.
- ; input and output are in a
- ; uses a,b,x0,y0,r6,r7,n7
- arccos macro
- move #$140,r7 ;offset
- move r7,r6
- move #$40,n7 ;guess
- move n7,b
- do #7,_arccos_loop
- move (r6)+n7 ;update guess
- asr b a,x0 y:(r6),y0 ;make increment smaller, lookup cosine
- cmp y0,a b,n7
- tlt x0,a r6,r7 ;dummy move, if arg>table value, keep old guess
- nop
- _arccos_loop
- move r7,a
- move #$140,y0
- sub y0,a ;result is here
-
- endm
-
-