Google-Apps
Hauptmenü

Post a Comment On: Ken Shirriff's blog

"Extracting ROM constants from the 8087 math coprocessor's die"

9 Comments -

1 – 9 of 9
Blogger Richard said...

Another interesting job.

It is impressive to know that he is able to open and study all the secrets within the CI and that they are hardly found in books.

It is a unique and impressive work that details with excellent clarity and helps with existing doubts.

These circuits accompanied my adolescence and I always classified it as magic and I was always trying to understand how it was produced.

Thank you one more time.

May 18, 2020 at 5:25 PM

Comment deleted

This comment has been removed by the author.

May 19, 2020 at 10:28 PM

Blogger MartyMacGyver said...

Long time reader, first time poster here!

There seem to be inverse pairs present, particularly

log2(e) == log(e)/log(2)
ln(2) == log(2)/log(e)

and

ln(2)/3 == log(2)/log(e) * 1/3
3*log2(e) == log(e)/log(2) * 3

The latter might appear to serve the same purpose as the former, but combining them, if x == 7, e^x = 2^(7*log2(e)) or 2^(3*log2(e)+3*log2(e)+log2(e)).

Perhaps this pre-calculation of the log constants multiplied/divided by 3 preserves greater precision and/or reduces cycle time, as one can decompose such calculations into a sequence of additions/subtractions and binary shifts rather than more costly odd-numbered multiplications and divisions?

Edit: Actually, to be exact these appear to be "nice numbers" to use the term mentioned in the Quinapalus page you linked to... and that would explain the absence of log2(3/2) as these serve a similar purpose.

May 19, 2020 at 10:39 PM

Blogger CuriousMarc said...

And I was proud of myself playing baby Ken S. with my little power supply reverse engineering. This is just a whole other level. Congrats Master Ken.

May 24, 2020 at 10:37 PM

Blogger Pane said...

Hi Ken,
Thank you for such deep analyse – as always interesting. I am still amazed what you can do in reverse engineering. I was blown out when I first read about HP35 ROM optical disassembly by Petr Monta (http://www.pmonta.com/calculators/hp-35/).
Not to take any credit away it must have been similar reverse engineering techniques to yours used when 8080 chip was cloned by many and it might be interesting to compare the chips. If there is any interest I might try to get hold of MHB8080 produced in former Czechoslovakia (http://www.teslakatalog.cz/MHB8080A.html).
I appreciate you keep educating all of us, thank you.
KR
Pavel

June 9, 2020 at 11:32 AM

Anonymous Anonymous said...

It's possible that the exponents are encoded in the chip's microcode instructions, much like multiplication can be encoded in assembly instructions.

For example, a compiler can turn:
mult a, 18

into:
shl a, 1
mov a, b
shl a, 3
add a, b

which is transforming a * 18 to (a * 16 + a * 2).

Another possibility is that they found a way to "store" the values inside existing values. For example, if you have to store the data 0x42ABF170 and also the data 0xABF1, you can just re-use the first piece of data and hardcode in your algorithm to load it, shift left by 8, then shift right by 16.

June 13, 2020 at 2:31 AM

Anonymous Dave said...


I think I have the reason there is ln(2)/3 in the ROM, it is used in the FX2M1 instruction. 2^x = e^(ln(2)x) = 1 + ln(2)x + ((ln(2)x)^2)/2!....

Thus for 2^x - 1 we have the series below:-

2^x -1 = ln(2)x + ((ln(2)x)^2)/2 + ((ln(2)x)^3)/3! + ((ln(2)x)^4)/4!....

this can be rearranged as follows to reduce the number of multiplies

2^x -1 = ln(2)x (1 + ln(2)x/2 (1 + ln(2)x/3 (1 + ln(2)x/4 (1 + ln(2)x/5))))

all of the constants required can be generated using FLD1, FCHS, FSCALE, ln(2)/3

e.g. 0.5 = FSCALE(FLD1, -1.0, 0.25 = FSCALE(FLD1, -2) etc
ln(2) / 3 is in the 8087 ROM
ln(2) / 6 is FSCALE(LN2DIV3, -1.0)
the constant 1 / 7 = 0.14285714 is a bit more tricky, possibly 1 / (FSCALE(FLD1, 3) - FLD1)
not really sure how many terms the 8087 uses, it might finish before the 1 / 7 term
which might account for the restricted range of the argument

Still puzzled by 3*log2(e)

January 23, 2021 at 6:58 AM

Anonymous Anonymous said...

nice

February 3, 2021 at 1:49 AM

Anonymous Anonymous said...

One of my favorite posts so far, which is a high bar to begin with. :)

Regarding the fact that 10^18 appears twice in the constant ROM, I noticed that log2(e) appears twice as well. You mentioned this yourself (unwittingly, maybe?) in the following sentence:

"The first group is values that the user can load (1, pi, log210, log2e, log102, and ln 2)12 along with values used internally (1018, ln(2)/3, 3*log2(e), log2(e), and sqrt(2))."

At first I thought that maybe log2e is meant to be read as log(2e), where log could stand for base 10, making it different from log2(e). However, your table in the footnote clearly shows that they're the same. I have close to zero expertise in this stuff, I just thought that maybe this could be some kind of useful hint.

November 29, 2021 at 6:24 AM

You can use some HTML tags, such as <b>, <i>, <a>

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.
Please prove you're not a robot