aboutsummaryrefslogtreecommitdiff
path: root/X64.hs
diff options
context:
space:
mode:
Diffstat (limited to 'X64.hs')
-rw-r--r--X64.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/X64.hs b/X64.hs
index a577a75..b71012a 100644
--- a/X64.hs
+++ b/X64.hs
@@ -30,6 +30,7 @@ data CondCode = CCA | CCAE | CCB | CCBE | CCC | CCE | CCG | CCGE | CCL | CCLE |
data Ins
= MOV RegMem RegMemImm | MOVi Reg Imm
+ | LEA Reg Mem
| MOVSX Reg RegMem
| ADD RegMem RegMemImm
| SUB RegMem RegMemImm
@@ -84,6 +85,7 @@ verify (Asm funcs) = mapM_ (\(_, inss) -> mapM_ goI inss) funcs
goI :: Ins -> Either String ()
goI (MOV (RegMem a) (RegMemImm b)) = ckRegMem a >> ckRegMemImm b >> ck2mem a b >> ckSizes a b
goI (MOVi (Reg a) (Imm b)) = ckReg a >> ckImm b >> ckSizes64 a b
+ goI (LEA (Reg a) (Mem b)) = ckReg a >> ckMem b >> ckSizes a b
goI (MOVSX (Reg a) (RegMem b)) = ckReg a >> ckRegMem b >> ckMovsx a b
goI (ADD (RegMem a) (RegMemImm b)) = ckRegMem a >> ckRegMemImm b >> ck2mem a b >> ckSizes a b
goI (SUB (RegMem a) (RegMemImm b)) = ckRegMem a >> ckRegMemImm b >> ck2mem a b >> ckSizes a b
@@ -110,6 +112,9 @@ verify (Asm funcs) = mapM_ (\(_, inss) -> mapM_ goI inss) funcs
ckReg (XReg _ _) = return ()
ckReg _ = Left "Argument is not a Reg"
+ ckMem (XMem _ _ _ _ _) = return ()
+ ckMem _ = Left "Argument is not a Mem"
+
ckImm (XImm _) = return ()
ckImm _ = Left "Argument is not an Imm"
@@ -230,6 +235,7 @@ instance Stringifiable CondCode where
instance Stringifiable Ins where
stringify (MOV a b) = "mov " ++ stringify a ++ ", " ++ stringify b
stringify (MOVi a b) = "mov " ++ stringify a ++ ", " ++ stringify b
+ stringify (LEA a b) = "lea " ++ stringify a ++ ", " ++ stringify b
stringify (MOVSX a b@(RegMem bx)) = case compare (xrefGetSize bx) 4 of
EQ -> "movsxd " ++ stringify a ++ ", " ++ stringify b
LT -> "movsx " ++ stringify a ++ ", " ++ stringify b
@@ -287,6 +293,7 @@ isXImm _ = False
xrefMapM :: Monad m => (XRef -> m XRef) -> Ins -> m Ins
xrefMapM f (MOV (RegMem x) (RegMemImm y)) = MOV <$> (RegMem <$> f x) <*> (RegMemImm <$> f y)
xrefMapM f (MOVi (Reg x) (Imm y)) = MOVi <$> (Reg <$> f x) <*> (Imm <$> f y)
+xrefMapM f (LEA (Reg x) (Mem y)) = LEA <$> (Reg <$> f x) <*> (Mem <$> f y)
xrefMapM f (MOVSX (Reg x) (RegMem y)) = MOVSX <$> (Reg <$> f x) <*> (RegMem <$> f y)
xrefMapM f (ADD (RegMem x) (RegMemImm y)) = ADD <$> (RegMem <$> f x) <*> (RegMemImm <$> f y)
xrefMapM f (SUB (RegMem x) (RegMemImm y)) = SUB <$> (RegMem <$> f x) <*> (RegMemImm <$> f y)