diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2004-03-31 18:56:43 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2004-03-31 18:56:43 +0000 |
commit | 1f1af9fd7f3fc83a3f933122f772d3a3f8663369 (patch) | |
tree | 2991d6a835a6997ebaf2375251390cd48a4fd703 | |
parent | 858693c63813f91ee3a0140bf3dfe5a069070eea (diff) |
added cpu_get_fp80() and cpu_set_fp80()
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@687 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r-- | target-i386/cpu.h | 4 | ||||
-rw-r--r-- | target-i386/helper.c | 60 |
2 files changed, 62 insertions, 2 deletions
diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 1cabbe42c7..daa2133f8e 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -408,6 +408,10 @@ static inline void cpu_x86_set_cpl(CPUX86State *s, int cpl) #endif } +/* used for debug or cpu save/restore */ +void cpu_get_fp80(uint64_t *pmant, uint16_t *pexp, CPU86_LDouble f); +CPU86_LDouble cpu_set_fp80(uint64_t mant, uint16_t upper); + /* the following helpers are only usable in user mode simulation as they can trigger unexpected exceptions */ void cpu_x86_load_seg(CPUX86State *s, int seg_reg, int selector); diff --git a/target-i386/helper.c b/target-i386/helper.c index dbdabd82ee..e61b05dc5c 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -2005,8 +2005,6 @@ void helper_fstt_ST0_A0(void) /* BCD ops */ -#define MUL10(iv) ( iv + iv + (iv << 3) ) - void helper_fbld_ST0_A0(void) { CPU86_LDouble tmp; @@ -2431,6 +2429,64 @@ void helper_frstor(uint8_t *ptr, int data32) } } +/* XXX: merge with helper_fstt ? */ + +#ifndef USE_X86LDOUBLE + +void cpu_get_fp80(uint64_t *pmant, uint16_t *pexp, CPU86_LDouble f) +{ + CPU86_LDoubleU temp; + int e; + + temp.d = f; + /* mantissa */ + *pmant = (MANTD(temp) << 11) | (1LL << 63); + /* exponent + sign */ + e = EXPD(temp) - EXPBIAS + 16383; + e |= SIGND(temp) >> 16; + *pexp = e; +} + +CPU86_LDouble cpu_set_fp80(uint64_t mant, uint16_t upper) +{ + CPU86_LDoubleU temp; + int e; + uint64_t ll; + + /* XXX: handle overflow ? */ + e = (upper & 0x7fff) - 16383 + EXPBIAS; /* exponent */ + e |= (upper >> 4) & 0x800; /* sign */ + ll = (mant >> 11) & ((1LL << 52) - 1); +#ifdef __arm__ + temp.l.upper = (e << 20) | (ll >> 32); + temp.l.lower = ll; +#else + temp.ll = ll | ((uint64_t)e << 52); +#endif + return temp.d; +} + +#else + +void cpu_get_fp80(uint64_t *pmant, uint16_t *pexp, CPU86_LDouble f) +{ + CPU86_LDoubleU temp; + + temp.d = f; + *pmant = temp.l.lower; + *pexp = temp.l.upper; +} + +CPU86_LDouble cpu_set_fp80(uint64_t mant, uint16_t upper) +{ + CPU86_LDoubleU temp; + + temp.l.upper = upper; + temp.l.lower = mant; + return temp.d; +} +#endif + #if !defined(CONFIG_USER_ONLY) #define MMUSUFFIX _mmu |