module Bindings.Bfd.Disasm.I386.Operand where

import Bindings.Bfd.Disasm.I386.Address
import Bindings.Bfd.Disasm.I386.EffectiveAddr


data Operand = Abs  {
                       address      :: Address
               }
             | DirD {
                       direct       :: String
               }
             | DirJ {
                       direct       :: String
               }
             | Imm  {
                       immed        :: Int
               }
             | IndD {
                       section      :: String
                     , 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