packages feed

bindings-bfd-1.2.0.0: src/Bindings/Bfd/Disasm/I386/Operand.hs

module Bindings.Bfd.Disasm.I386.Operand where

import Bindings.Bfd.Disasm.I386.Address
import Bindings.Bfd.Disasm.I386.Cell
import Bindings.Bfd.Disasm.I386.EffectiveAddr
import Bindings.Bfd.Disasm.I386.Register      as R


data Operand = Abs  {
                       address      :: Address
               }
             | DirD {
                       direct       :: Register
               }
             | DirJ {
                       direct       :: Register
               }
             | Imm  {
                       immed        :: Int
               }
             | IndD {
                       section      :: Maybe Register
                     , effAddr      :: EffectiveAddr
                     , displacement :: Maybe Int
                     , mbAddress    :: Maybe Address
               }
             | IndJ {
                       effAddr      :: EffectiveAddr
                     , displacement :: Maybe Int
                     , mbAddress    :: Maybe Address
               }
             -- must be last in the operand list in Insn
             | Length {
                       len          :: Int
               }
     deriving (Eq, Ord, Show)


isAbs
   :: Operand
   -> Bool
isAbs (Abs _) = True
isAbs _       = False

isIndJ
   :: Operand
   -> Bool
isIndJ (IndJ _ _ _) = True
isIndJ _            = False

isDirJ
   :: Operand
   -> Bool
isDirJ (DirJ _) = True
isDirJ _        = False

defines
   :: Int
   -> Operand
   -> [Cell]
defines _ (DirD r       ) = [Reg r]
defines w (IndD s ea d a) = [Ind w s ea d a]
defines _ o        = error $ "Operand.defines: " ++ show o