Weed assembly statements
There's still an undefined in Assembly.hs. To get rid of it, I'll need to adjust how I weed labels. Once that's finished, the rest should be fairly straightforward.
This commit is contained in:
parent
f3b39f78f4
commit
702f58e2a4
4 changed files with 297 additions and 0 deletions
51
src/Mima/Parse/Assembly/Weed/Common.hs
Normal file
51
src/Mima/Parse/Assembly/Weed/Common.hs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
module Mima.Parse.Assembly.Weed.Common
|
||||
( Registers(..)
|
||||
, emptyRegisters
|
||||
, AlmostWord(..)
|
||||
, WeedResult(..)
|
||||
, emptyResult
|
||||
) where
|
||||
|
||||
import qualified Data.Map as Map
|
||||
|
||||
import Mima.Flag
|
||||
import Mima.Label
|
||||
import Mima.Parse.Assembly.RawInstruction
|
||||
import Mima.Word
|
||||
|
||||
data Registers a = Registers
|
||||
{ rIAR :: Maybe a
|
||||
, rACC :: Maybe MimaWord
|
||||
, rRA :: Maybe a
|
||||
, rSP :: Maybe a
|
||||
, rFP :: Maybe a
|
||||
} deriving (Show)
|
||||
|
||||
emptyRegisters :: Registers a
|
||||
emptyRegisters = Registers
|
||||
{ rIAR = Nothing
|
||||
, rACC = Nothing
|
||||
, rRA = Nothing
|
||||
, rSP = Nothing
|
||||
, rFP = Nothing
|
||||
}
|
||||
|
||||
data AlmostWord a
|
||||
= AInstruction (RawInstruction a)
|
||||
| ALiteral MimaWord
|
||||
deriving (Show)
|
||||
|
||||
data WeedResult a = WeedResult
|
||||
{ wrRegisters :: Registers a
|
||||
, wrMemory :: Map.Map MimaAddress (AlmostWord a)
|
||||
, wrLabels :: Map.Map LabelName MimaAddress
|
||||
, wrFlags :: Map.Map Char [AddressRange]
|
||||
} deriving (Show)
|
||||
|
||||
emptyResult :: WeedResult a
|
||||
emptyResult = WeedResult
|
||||
{ wrRegisters = emptyRegisters
|
||||
, wrMemory = Map.empty
|
||||
, wrLabels = Map.empty
|
||||
, wrFlags = Map.empty
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue