On 5/10/25 09:36, Andreas Schwab wrote:
On Mai 07 2025, Richard Henderson wrote:

+    /* Convert the 3 digit decimal exponent to binary. */
+    exp = ((hi >> 24) & 0xf)
+        + ((hi >> 20) & 0xf) * 10
+        + ((hi >> 16) & 0xf) * 100;

This is backwards.  An exponent of 123 is stored as 0x01230000, not
0x03210000.

+    for (int i = 24; exp10; i -= 4, exp10 /= 10) {
+        res_hi |= (exp10 % 10) << i;

Again, this is backwards.  Also, the decimal exponent of an extended
precision number can be as big as 4951.  From the fpsp040:

| A15. Convert the exponent to bcd.
|      As in A14 above, the exp is converted to bcd and the
|      digits are stored in the final string.
|
|      Digits are stored in L_SCR1(a6) on return from BINDEC as:
|
|        32               16 15                0
|       -----------------------------------------
|       |  0 | e3 | e2 | e1 | e4 |  X |  X |  X |
|       -----------------------------------------

That is, the fourth digit of the exponent is stored in the upper 4 bits
of the padding (OPERR is set if e4 is non-zero).


Well that's annoying.  There's a mis-print in the m68000pm/ad manual, where it 
says

  SE SM YY E0 E1 E0 E3 x x D16

I didn't notice E0 listed twice and so thought "0 1 2 3" was the order.

Will fix.


r~

Reply via email to