aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Orlov <nikitf-97@mail.ru>2021-03-22 13:15:19 +0300
committerNikita Orlov <nikitf-97@mail.ru>2021-03-22 13:15:19 +0300
commit1328d948ba1d3e4d72ceb8a4a01db7bb982535b4 (patch)
tree92b3a3cefbd206b76e1529d498a917618ea2ed99
parent9180aab5f90381b8e9fec0288b795cf197e3b420 (diff)
downloadsuem-1328d948ba1d3e4d72ceb8a4a01db7bb982535b4.tar
suem-1328d948ba1d3e4d72ceb8a4a01db7bb982535b4.tar.xz
suem-1328d948ba1d3e4d72ceb8a4a01db7bb982535b4.zip
PC access added
-rw-r--r--src/Commands.hs4
-rw-r--r--src/Machine.hs13
2 files changed, 14 insertions, 3 deletions
diff --git a/src/Commands.hs b/src/Commands.hs
index 6fce17b..32fc17f 100644
--- a/src/Commands.hs
+++ b/src/Commands.hs
@@ -114,11 +114,9 @@ doLINK _ = return ()
doUNLK :: Int -> Emulator ()
doUNLK a = do
+ incPC
addr <- readA a
val <- getLong addr
- with pc $ \pc -> do
- pcval <- readIORef pc
- writeIORef pc (pcval + 2)
writeA a val
writeA 7 (addr + 4)
diff --git a/src/Machine.hs b/src/Machine.hs
index 6a09be9..23b7872 100644
--- a/src/Machine.hs
+++ b/src/Machine.hs
@@ -166,6 +166,19 @@ writeA _ _ = return $ error "Incorrect Address register write"
-------------------------------------------------------------------------------
+-- PC Register Access
+readPC = with pc $ \pc -> do
+ return pc
+
+writePC r = with pc $ \pc -> do
+ writeIORef pc r
+
+incPC = with pc $ \pc -> do
+ pcval <- readIORef pc
+ writeIORef pc (pcval + 2)
+
+
+-------------------------------------------------------------------------------
-- Status Register Access
isTracing :: Emulator Bool