Run a MiMa until it halts
This commit is contained in:
parent
ac5fbf3942
commit
9532d0487b
1 changed files with 7 additions and 0 deletions
|
|
@ -9,6 +9,7 @@ module Mima.State
|
||||||
, AbortReason(..)
|
, AbortReason(..)
|
||||||
, ExecException(..)
|
, ExecException(..)
|
||||||
, step
|
, step
|
||||||
|
, run
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.Bits
|
import Data.Bits
|
||||||
|
|
@ -98,3 +99,9 @@ executeLargeOpcode HALT ms =
|
||||||
in Left $ ExecException addr word Halted
|
in Left $ ExecException addr word Halted
|
||||||
executeLargeOpcode NOT ms = incrementIp ms{msAcc = complement (msAcc ms)}
|
executeLargeOpcode NOT ms = incrementIp ms{msAcc = complement (msAcc ms)}
|
||||||
executeLargeOpcode RAR ms = incrementIp ms{msAcc = rotateR (msAcc ms) 1}
|
executeLargeOpcode RAR ms = incrementIp ms{msAcc = rotateR (msAcc ms) 1}
|
||||||
|
|
||||||
|
run :: MimaState -> (MimaState, ExecException)
|
||||||
|
run ms =
|
||||||
|
case step ms of
|
||||||
|
Left e -> (ms, e)
|
||||||
|
Right ms' -> run ms'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue