Clean up string formatting
This commit is contained in:
parent
510ecaa51d
commit
f3a3432c9c
3 changed files with 46 additions and 56 deletions
|
|
@ -77,12 +77,6 @@ data Instruction
|
|||
| LargeInstruction !LargeOpcode !SmallValue
|
||||
deriving (Show, Eq)
|
||||
|
||||
instance ToText Instruction where
|
||||
toText (SmallInstruction oc lv) = T.justifyLeft 4 ' ' (toText oc) <> " " <> largeValueToDec lv
|
||||
toText (LargeInstruction oc sv)
|
||||
| sv == minBound = T.justifyLeft 4 ' ' (toText oc)
|
||||
| otherwise = T.justifyLeft 4 ' ' (toText oc) <> " " <> smallValueToDec sv
|
||||
|
||||
wordToInstruction :: MimaWord -> Either T.Text Instruction
|
||||
wordToInstruction mw = if getSmallOpcode mw == 0xF
|
||||
then parseLargeInstruction mw
|
||||
|
|
@ -99,7 +93,7 @@ parseSmallOpcode :: Word32 -> Either T.Text SmallOpcode
|
|||
parseSmallOpcode w = case smallOpcodeMap Map.!? w of
|
||||
Just oc -> pure oc
|
||||
Nothing -> Left $ "Unknown small opcode " <> T.pack (show w)
|
||||
<> " (" <> toHex 1 w <> ")"
|
||||
<> " (" <> integralToHex 1 w <> ")"
|
||||
|
||||
parseLargeInstruction :: MimaWord -> Either T.Text Instruction
|
||||
parseLargeInstruction mw = do
|
||||
|
|
@ -112,4 +106,4 @@ parseLargeOpcode :: Word32 -> Either T.Text LargeOpcode
|
|||
parseLargeOpcode w = case largeOpcodeMap Map.!? w of
|
||||
Just oc -> pure oc
|
||||
Nothing -> Left $ "Unknown large opcode " <> T.pack (show w)
|
||||
<> " (" <> toHex 1 w <> ")"
|
||||
<> " (" <> integralToHex 1 w <> ")"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue