summaryrefslogtreecommitdiff
path: root/erc32.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 /erc32.c
parentacd17e755506d316e073175c3993954cb7d51f3e (diff)
Fix incorrect operation on big-endian hosts
Diffstat (limited to 'erc32.c')
-rw-r--r--erc32.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/erc32.c b/erc32.c
index 3a7899d..dd86907 100644
--- a/erc32.c
+++ b/erc32.c
@@ -16,12 +16,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifdef WORDS_BIGENDIAN
-#define EBT 0
-#else
-#define EBT 3
-#endif
-
#define ROM_START 0
#define RAM_START 0x02000000
@@ -1620,7 +1614,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 = mem_ramw_ws + 3;
break;
@@ -1628,7 +1624,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 = mem_ramw_ws + 3;
break;
case 2: