Disable stack modification by branching (j*) instructions

This commit is contained in:
2021-11-14 11:06:56 +01:00
parent 434d5a16ff
commit 6c50259228
3 changed files with 51 additions and 19 deletions

View File

@@ -110,6 +110,7 @@ jump [] _ = throwError "Address expected"
jumpIf :: (Int -> Int -> Bool) -> Params -> Pops -> ExceptT String Machine ()
jumpIf p (addr:_) (top:_) = lift $ do
pc <- getPc
push [top]
setPc $ if top `p` 0 then addr else pc + 2
return ()
jumpIf _ [] _ = throwError "Address expected"