Disable stack modification by branching (j*) instructions
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -42,7 +42,7 @@ data Op = Nop -- 0x00
|
||||
| Out -- 0x17
|
||||
| Clr -- 0x18
|
||||
| Roll -- 0x19
|
||||
| Over -- 0x20
|
||||
| Over -- 0x1A
|
||||
deriving (Eq, Ord, Enum, Show, Read, Bounded)
|
||||
|
||||
type Machine = StateT VM IO
|
||||
|
||||
Reference in New Issue
Block a user