From 4b15372e1dbd7bcdf4e53a5c78e0d741a2e9d4b7 Mon Sep 17 00:00:00 2001 From: cheapie Date: Wed, 27 May 2026 03:50:13 -0500 Subject: Fix big-endian doubleword stores/loads --- rvcontroller.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'rvcontroller.lua') diff --git a/rvcontroller.lua b/rvcontroller.lua index 57f458c..18fa788 100644 --- a/rvcontroller.lua +++ b/rvcontroller.lua @@ -653,8 +653,8 @@ local operations = { if rd == 0 or rd == 31 then return end if imm >= 2^11 then imm = imm - 2^12 end local address = getreg(rs1)+imm - setreg(rd,readram(address,4)) - setreg(rd+1,readram(address+4,4)) + setreg(rd,readram(address+(mem.bigendian and 4 or 0),4)) + setreg(rd+1,readram(address+(mem.bigendian and 0 or 4),4)) end, lhu = function(rd,rs1,imm) if imm >= 2^11 then imm = imm - 2^12 end @@ -682,8 +682,8 @@ local operations = { if rs2 == 31 then return end if imm >= 2^11 then imm = imm - 2^12 end local address = getreg(rs1)+imm - writeram(address,getreg(rs2),4) - writeram(address+4,getreg(rs2+1),4) + writeram(address+(mem.bigendian and 4 or 0),getreg(rs2),4) + writeram(address+(mem.bigendian and 0 or 4),getreg(rs2+1),4) end, ecall = function() local func = getreg(17) -- cgit v1.2.3