diff options
| author | cheapie <cheapiephp@gmail.com> | 2026-11-08 08:12:18 -0600 |
|---|---|---|
| committer | cheapie <cheapiephp@gmail.com> | 2026-11-08 08:12:18 -0600 |
| commit | d29584ca1361f7268511fda2404f15991ca9c5c9 (patch) | |
| tree | 4c79666ccf34d4ef40c80511814c81caaa1ed6c5 /rvcontroller.lua | |
| parent | f8cc0d73afe12cc1c8dd1600a28ff4634decf617 (diff) | |
| download | rvcontroller-d29584ca1361f7268511fda2404f15991ca9c5c9.tar rvcontroller-d29584ca1361f7268511fda2404f15991ca9c5c9.tar.gz rvcontroller-d29584ca1361f7268511fda2404f15991ca9c5c9.tar.bz2 rvcontroller-d29584ca1361f7268511fda2404f15991ca9c5c9.tar.xz rvcontroller-d29584ca1361f7268511fda2404f15991ca9c5c9.zip | |
Mask mnepc as needed on reads
Diffstat (limited to 'rvcontroller.lua')
| -rw-r--r-- | rvcontroller.lua | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/rvcontroller.lua b/rvcontroller.lua index bf9877f..801178c 100644 --- a/rvcontroller.lua +++ b/rvcontroller.lua @@ -413,6 +413,15 @@ local function readcsr(address) ret = ret - 2 end return ret + elseif address == 0x741 then --mnepc + local ret = mem.csr[0x741] + --mnepc[0] must be 0 + if ret%2 == 1 then ret = ret-1 end + --mnepc[1] must be 0 if IALIGN=32 + if not mem.isa.c and ret%4 >= 2 then + ret = ret - 2 + end + return ret elseif address == 0x300 then --mstatus local bits = {} bits[3] = mem.mie |
