Revision 5e9ae189 target-ppc/op_helper.c
b/target-ppc/op_helper.c | ||
---|---|---|
1865 | 1865 |
/* 602 specific instructions */ |
1866 | 1866 |
/* mfrom is the most crazy instruction ever seen, imho ! */ |
1867 | 1867 |
/* Real implementation uses a ROM table. Do the same */ |
1868 |
/* Extremly decomposed: |
|
1869 |
* -arg / 256 |
|
1870 |
* return 256 * log10(10 + 1.0) + 0.5 |
|
1871 |
*/ |
|
1868 | 1872 |
#if !defined (CONFIG_USER_ONLY) |
1869 |
#define USE_MFROM_ROM_TABLE |
|
1870 | 1873 |
target_ulong helper_602_mfrom (target_ulong arg) |
1871 | 1874 |
{ |
1872 | 1875 |
if (likely(arg < 602)) { |
1873 |
#if defined(USE_MFROM_ROM_TABLE) |
|
1874 | 1876 |
#include "mfrom_table.c" |
1875 | 1877 |
return mfrom_ROM_table[arg]; |
1876 |
#else |
|
1877 |
double d; |
|
1878 |
/* Extremly decomposed: |
|
1879 |
* -arg / 256 |
|
1880 |
* return 256 * log10(10 + 1.0) + 0.5 |
|
1881 |
*/ |
|
1882 |
d = arg; |
|
1883 |
d = float64_div(d, 256, &env->fp_status); |
|
1884 |
d = float64_chs(d); |
|
1885 |
d = exp10(d); // XXX: use float emulation function |
|
1886 |
d = float64_add(d, 1.0, &env->fp_status); |
|
1887 |
d = log10(d); // XXX: use float emulation function |
|
1888 |
d = float64_mul(d, 256, &env->fp_status); |
|
1889 |
d = float64_add(d, 0.5, &env->fp_status); |
|
1890 |
return float64_round_to_int(d, &env->fp_status); |
|
1891 |
#endif |
|
1892 | 1878 |
} else { |
1893 | 1879 |
return 0; |
1894 | 1880 |
} |
Also available in: Unified diff