Post Reply 
HP-35 style trig functions
01-14-2019, 02:34 AM (This post was last modified: 01-14-2019 02:35 AM by Druzyek.)
Post: #6
RE: HP-35 style trig functions
Hi Dan, I have admired your AriCalculator for a while!

Quote:There are CORDIC algorithms for sine and cosine but I didn't use them
Right, but do any of them use a table of atan(10^(-i))? That lets you shift X and Y to divide by 10, which is easy in BCD. Everything else I've seen (other than the links I posted) uses a table of atan(2^(-i)), which means you have to halve BCD values and that is turning out to be extremely slow.

I'm keeping everything in BCD without ever converting to binary. My numbers are 16 bytes of packed BCD. What I have so far can do multiplies in 16k cycles, division in 25k cycles, and tan in about 1.1 million cycles. 90% of the cycles in tan are for halving X and Y down before adding them. I have a lookup table for 8 bit shifts (ie 0-0x99 BCD divided by 256) and finish with 1 bit shifts but with the last CORDIC cycle requiring 106 divides by 2, it requires a huge amount of shifting. Using the method I posted above with divides by 10 only takes 60k-80k cycles! Calculating sine and cosine from that might take 2-4 times longer with the square root and multiplies, which is still very fast, but it would be nice to know how to do it without that (I'm starting to think it is not possible).

I'm using an MSP430 programmed in assembly, so no hardware multiply or divide. I used the same chip programmed in C for my first calculator: RPN Scientific Calculator. The chip has 16 bit registers and a BCD add instruction, so it is not bad to work with in assembly. Using the slow divide by 2 CORDIC I have the four functions plus the 6 trig and inverse functions in only 4k of firmware.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP-35 style trig functions - Druzyek - 01-13-2019, 08:32 PM
RE: HP-35 style trig functions - pier4r - 01-13-2019, 08:37 PM
RE: HP-35 style trig functions - Druzyek - 01-14-2019, 12:56 AM
RE: HP-35 style trig functions - Dan - 01-14-2019, 01:31 AM
RE: HP-35 style trig functions - Druzyek - 01-14-2019 02:34 AM
RE: HP-35 style trig functions - Dan - 01-15-2019, 03:43 AM
RE: HP-35 style trig functions - Druzyek - 01-15-2019, 11:49 PM
RE: HP-35 style trig functions - Druzyek - 08-28-2023, 12:19 AM



User(s) browsing this thread: 4 Guest(s)