Add more conversions

This commit is contained in:
Joscha 2019-11-09 23:37:22 +00:00
parent 803c826395
commit 21e72420dd
3 changed files with 21 additions and 14 deletions

View file

@ -5,6 +5,7 @@ module Mima.Instruction
, LargeOpcode(..)
, Instruction(..)
, wordToInstruction
, instructionToWord
) where
import qualified Data.Map.Strict as Map
@ -105,3 +106,7 @@ parseLargeOpcode w = case largeOpcodeMap Map.!? w of
Just oc -> pure oc
Nothing -> Left $ "Unknown large opcode " <> T.pack (show w)
<> " (" <> integralToHex 1 w <> ")"
instructionToWord :: Instruction -> MimaWord
instructionToWord (SmallInstruction so lv) = wordFromSmallOpcode (smallOpcodeNr so) lv
instructionToWord (LargeInstruction lo sv) = wordFromLargeOpcode (largeOpcodeNr lo) sv