summaryrefslogtreecommitdiff
path: root/rvcontroller.lua
diff options
context:
space:
mode:
Diffstat (limited to 'rvcontroller.lua')
-rw-r--r--rvcontroller.lua9
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