3 ms·
I'd be keen to know more about how the transcendental instructions worked.
by simonbyrne 8y ago
I'd be keen to know more about how the transcendental instructions worked.
- kens 8y agoI plan to write about that, but the short answer is that the 8087 computes transcendental functions using CORDIC. The chip contains constants atan(2^0), ..., atan(2^-15). It operates a bit at a time using these constants to compute tan and arctan. It doesn't natively support sine and cosine, but these can be computed from the tangent. Likewise, the constants log2(1+2^(-2)), ..., log2(1+2^(-15)) are used for logarithm and exponentiation. https://en.wikipedia.org/wiki/CORDIC https://en.wikipedia.org/wiki/CORDIC Edit: the constant ROM is the vertical stripe in the lower left in the die photo. You can see each bit in the ROM as a green or purple rectangle: https://lh3.googleusercontent.com/-7S_Q0bzu-7A/W3RDsZwprvI/AAAAAAABTmQ/mUZVqFspfJEzvXyFJdQtA1AOBdKcCFDJACHMYBhgL/w9999/stripped.jpg https://lh3.googleusercontent.com/-7S_Q0bzu-7A/W3RDsZwprvI/A...
- deleted 8y ago[deleted]
- cmroanirgo 8y ago> It doesn't natively support sine and cosine, but these can be computed from the tangent. I'd not ever looked into it, but that neatly explains the existence of the sincos instruction.
- bonzini 8y agosincos is useful in general. Rotations for example often need sine and cosine of the same angle. Because transcendental functions are implemented as a microcode loop, a sincos instruction lets you cut in half the loop overhead. If the overhead were 50% (e.g. 100 cycles arithmetic and 50 cycles overhead) you could cut sincos to 250 cycles, for an overhead of only 25%.
- userbinator 8y agoCORDIC is itself a very interesting algorithm due to its conceptual simplicity: a vector rotation using successive approximations. When stripped down to its essentials, it forms the basis of a surprisingly simple circle-drawing algorithm: https://nbickford.wordpress.com/2011/04/03/the-minsky-circle-algorithm/ https://nbickford.wordpress.com/2011/04/03/the-minsky-circle... (Previously also discussed here at https://news.ycombinator.com/item?id=15266331 https://news.ycombinator.com/item?id=15266331 )