summaryrefslogtreecommitdiffstats
path: root/leon2.c
diff options
context:
space:
mode:
authorJiri Gaisler <jiri@gaisler.se>2020-02-29 11:07:13 +0100
committerJiri Gaisler <jiri@gaisler.se>2020-02-29 14:28:48 +0100
commit09ba9099c1562c4af1e2f624b9aa2692e563118b (patch)
tree2ae06e83b4f993e2e2e9a01f6b1bf9c982d55fa2 /leon2.c
parentAvoid reserved word sparc on SPARC hosts (diff)
downloadsis-09ba9099c1562c4af1e2f624b9aa2692e563118b.tar.bz2
Fix incorrect operation on big-endian hosts
Diffstat (limited to 'leon2.c')
-rw-r--r--leon2.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/leon2.c b/leon2.c
index 6f669a5..b1ed1d6 100644
--- a/leon2.c
+++ b/leon2.c
@@ -19,12 +19,6 @@
* Leon2 emulation, based on leon3.c and erc32.c/
*/
-#ifdef WORDS_BIGENDIAN
-#define EBT 0
-#else
-#define EBT 3
-#endif
-
#define ROM_START 0x00000000
#define RAM_START 0x40000000
@@ -796,7 +790,9 @@ store_bytes (char *mem, uint32 waddr, uint32 * data, int32 sz, int32 * ws)
switch (sz)
{
case 0:
- waddr ^= EBT;
+#ifdef HOST_LITTLE_ENDIAN
+ waddr ^= 3;
+#endif
mem[waddr] = *data & 0x0ff;
*ws = 0;
break;
@@ -804,7 +800,7 @@ store_bytes (char *mem, uint32 waddr, uint32 * data, int32 sz, int32 * ws)
#ifdef HOST_LITTLE_ENDIAN
waddr ^= 2;
#endif
- memcpy (&mem[waddr], data, 2);
+ *((uint16 *) & mem[waddr]) = *data & 0x0ffff;
*ws = 0;
break;
case 2: