aboutsummaryrefslogtreecommitdiff
path: root/X64.hs
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-08-26 23:16:00 +0200
committertomsmeding <tom.smeding@gmail.com>2017-08-26 23:16:15 +0200
commitaa049227c17f15ad22092f1fcab4410bbf3521ba (patch)
tree7046e62ff530746754e19d07d4e8bc7d7a42ea22 /X64.hs
parentb2c5ef755bc7a2c736c5f52c4753dde66c04c3aa (diff)
Cleanup and features
debugger, bitwise ops, bounds checking, hex literals, better typing of some optimisations, makefile fix, exit function.
Diffstat (limited to 'X64.hs')
-rw-r--r--X64.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/X64.hs b/X64.hs
index 222d1cd..a577a75 100644
--- a/X64.hs
+++ b/X64.hs
@@ -48,6 +48,7 @@ data Ins
| JMP String
| JCC CondCode String
| RET
+ | INT3
deriving (Show, Eq)
type Func = (String, [Ins])
@@ -104,6 +105,7 @@ verify (Asm funcs) = mapM_ (\(_, inss) -> mapM_ goI inss) funcs
goI (JMP s) = when (null s) $ Left "Empty jump target"
goI (JCC _ s) = when (null s) $ Left "Empty jcc target"
goI RET = return ()
+ goI INT3 = return ()
ckReg (XReg _ _) = return ()
ckReg _ = Left "Argument is not a Reg"
@@ -252,6 +254,7 @@ instance Stringifiable Ins where
stringify (JMP s) = "jmp " ++ s
stringify (JCC cc s) = "j" ++ stringify cc ++ " " ++ s
stringify RET = "ret"
+ stringify INT3 = "int3"
instance Stringifiable Asm where
stringify (Asm funcs) = intercalate "\n" $ map goF funcs
@@ -305,6 +308,7 @@ xrefMapM f (POP (RegMem x)) = POP <$> (RegMem <$> f x)
xrefMapM _ i@(JMP _) = return i
xrefMapM _ i@(JCC _ _) = return i
xrefMapM _ i@RET = return i
+xrefMapM _ i@INT3 = return i
xrefMap :: (XRef -> XRef) -> Ins -> Ins
xrefMap f i = runIdentity $ xrefMapM (return . f) i