Commit a8d3431ae931aa44ee6228ffecf6277714389de7

Authored by bellard
1 parent 7ff4d218

endianness fixes


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1268 c046a42c-6fe2-441c-8c8c-71466251a162
target-arm/nwfpe/double_cpdo.c
... ... @@ -150,7 +150,11 @@ unsigned int DoubleCPDO(const unsigned int opcode)
150 150 case MNF_CODE:
151 151 {
152 152 unsigned int *p = (unsigned int*)&rFm;
  153 +#ifdef WORDS_BIGENDIAN
  154 + p[0] ^= 0x80000000;
  155 +#else
153 156 p[1] ^= 0x80000000;
  157 +#endif
154 158 fpa11->fpreg[Fd].fDouble = rFm;
155 159 }
156 160 break;
... ... @@ -158,7 +162,11 @@ unsigned int DoubleCPDO(const unsigned int opcode)
158 162 case ABS_CODE:
159 163 {
160 164 unsigned int *p = (unsigned int*)&rFm;
  165 +#ifdef WORDS_BIGENDIAN
  166 + p[0] &= 0x7fffffff;
  167 +#else
161 168 p[1] &= 0x7fffffff;
  169 +#endif
162 170 fpa11->fpreg[Fd].fDouble = rFm;
163 171 }
164 172 break;
... ...
target-arm/nwfpe/fpa11.h
... ... @@ -22,6 +22,10 @@
22 22 #ifndef __FPA11_H__
23 23 #define __FPA11_H__
24 24  
  25 +#include <stdlib.h>
  26 +#include <stdio.h>
  27 +#include <errno.h>
  28 +
25 29 #define GET_FPA11() (qemufpa)
26 30  
27 31 /*
... ... @@ -87,8 +91,6 @@ extern void resetFPA11(void);
87 91 extern void SetRoundingMode(const unsigned int);
88 92 extern void SetRoundingPrecision(const unsigned int);
89 93  
90   -#define get_user(x,y) ((x)=*(y))
91   -#define put_user(x,y) (*(y)=(x))
92 94 static inline unsigned int readRegister(unsigned int reg)
93 95 {
94 96 return (user_registers[(reg)]);
... ... @@ -128,4 +130,7 @@ unsigned int ZF;
128 130  
129 131 unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, unsigned int* qregs);
130 132  
  133 +/* included only for get_user/put_user macros */
  134 +#include "qemu.h"
  135 +
131 136 #endif
... ...
target-arm/nwfpe/fpa11_cpdt.c
... ... @@ -43,8 +43,13 @@ void loadDouble(const unsigned int Fn,const unsigned int *pMem)
43 43 unsigned int *p;
44 44 p = (unsigned int*)&fpa11->fpreg[Fn].fDouble;
45 45 fpa11->fType[Fn] = typeDouble;
  46 +#ifdef WORDS_BIGENDIAN
  47 + get_user(p[0], &pMem[0]); /* sign & exponent */
  48 + get_user(p[1], &pMem[1]);
  49 +#else
46 50 get_user(p[0], &pMem[1]);
47 51 get_user(p[1], &pMem[0]); /* sign & exponent */
  52 +#endif
48 53 }
49 54  
50 55 static inline
... ... @@ -133,8 +138,13 @@ void storeDouble(const unsigned int Fn,unsigned int *pMem)
133 138  
134 139 default: val = fpa11->fpreg[Fn].fDouble;
135 140 }
  141 +#ifdef WORDS_BIGENDIAN
  142 + put_user(p[0], &pMem[0]); /* msw */
  143 + put_user(p[1], &pMem[1]); /* lsw */
  144 +#else
136 145 put_user(p[1], &pMem[0]); /* msw */
137 146 put_user(p[0], &pMem[1]); /* lsw */
  147 +#endif
138 148 }
139 149  
140 150 static inline
... ...