From aa049227c17f15ad22092f1fcab4410bbf3521ba Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 26 Aug 2017 23:16:00 +0200 Subject: Cleanup and features debugger, bitwise ops, bounds checking, hex literals, better typing of some optimisations, makefile fix, exit function. --- X64.hs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'X64.hs') 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 -- cgit v1.2.3-70-g09d2