diff options
| author | cheapie <no-email-for-you@example.com> | 2026-05-27 03:50:13 -0500 |
|---|---|---|
| committer | cheapie <no-email-for-you@example.com> | 2026-05-27 03:50:13 -0500 |
| commit | 4b15372e1dbd7bcdf4e53a5c78e0d741a2e9d4b7 (patch) | |
| tree | 3306137c464b0811a694c1f7fe4541e0cedd390c | |
| parent | e6b8c97d92f3a4de21cc6c2dfb4206665b4fa58a (diff) | |
| download | rvcontroller-4b15372e1dbd7bcdf4e53a5c78e0d741a2e9d4b7.tar rvcontroller-4b15372e1dbd7bcdf4e53a5c78e0d741a2e9d4b7.tar.gz rvcontroller-4b15372e1dbd7bcdf4e53a5c78e0d741a2e9d4b7.tar.bz2 rvcontroller-4b15372e1dbd7bcdf4e53a5c78e0d741a2e9d4b7.tar.xz rvcontroller-4b15372e1dbd7bcdf4e53a5c78e0d741a2e9d4b7.zip | |
Fix big-endian doubleword stores/loads
| -rw-r--r-- | rvcontroller.lua | 8 |
1 files changed, 4 insertions, 4 deletions
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) |
