Add more conversions
This commit is contained in:
parent
803c826395
commit
21e72420dd
3 changed files with 21 additions and 14 deletions
|
|
@ -13,6 +13,8 @@ module Mima.Word
|
|||
, boolToWord
|
||||
, largeValueToWord
|
||||
, signedSmallValueToWord
|
||||
, wordFromSmallOpcode
|
||||
, wordFromLargeOpcode
|
||||
-- ** 'MimaWord' properties
|
||||
, getSmallOpcode
|
||||
, getLargeOpcode
|
||||
|
|
@ -59,6 +61,12 @@ signedSmallValueToWord sv
|
|||
| topBit sv = 0xFF0000 .|. fromIntegral sv
|
||||
| otherwise = fromIntegral sv
|
||||
|
||||
wordFromSmallOpcode :: Opcode -> LargeValue -> MimaWord
|
||||
wordFromSmallOpcode so lv = shiftL (fromIntegral so) 20 .|. fromIntegral lv
|
||||
|
||||
wordFromLargeOpcode :: Opcode -> SmallValue -> MimaWord
|
||||
wordFromLargeOpcode lo sv = 0xF00000 .|. shiftL (fromIntegral lo) 16 .|. fromIntegral sv
|
||||
|
||||
getSmallOpcode :: MimaWord -> Opcode
|
||||
getSmallOpcode mw = fromIntegral $ shiftR mw 20
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue