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:
Joscha 2019-11-21 15:12:21 +00:00
parent f3b39f78f4
commit 702f58e2a4
4 changed files with 297 additions and 0 deletions

View 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
}