From 6a2047aae1e21f09e5cd381215f7cfc2805a7b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Przemys=C5=82aw=20Pluta?= Date: Tue, 9 Nov 2021 19:05:15 +0100 Subject: [PATCH] Fix jumping --- app/VirtualMachine/Instruction.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/VirtualMachine/Instruction.hs b/app/VirtualMachine/Instruction.hs index 3cfdf41..206710d 100644 --- a/app/VirtualMachine/Instruction.hs +++ b/app/VirtualMachine/Instruction.hs @@ -88,7 +88,7 @@ debug vm _ _ = do jumpIf :: (Int -> Int -> Bool) -> VM -> Params -> Pops -> ExceptT String IO VM jumpIf predicate vm (addr:_) (top:_) = except $ Right $ vm { _pc = pc } - where pc = if top `predicate` 0 then addr else _pc vm + 1 + where pc = if top `predicate` 0 then addr else _pc vm + 2 jumpIf _ _ [] _ = except $ Left "Address expected" jumpIf _ _ _ [] = except $ Left "Empty stack - nothing to compare"