From 0c2b9dc0c37505a5134f904ea867f2a311bfe162 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sun, 25 Sep 2022 20:22:31 +0100 Subject: Optimizations --- src/Micro/Asm/Sdcc.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Micro/Asm/Sdcc.hs b/src/Micro/Asm/Sdcc.hs index 3aa9a36..a3f83ed 100644 --- a/src/Micro/Asm/Sdcc.hs +++ b/src/Micro/Asm/Sdcc.hs @@ -100,9 +100,14 @@ emit x = o {oCode = oCode (emit a) ++ ["\tld c, a"] ++ oCode (emit b) ++ ["\tld b, a", "\tld a, c", "\tsub b"]} (A.BinOp A.Mul _ _ (A.Num 0 _)) -> o {oCode = ["\txor a"]} - (A.BinOp A.Mul _ _ (A.Num 1 _)) -> o + (A.BinOp A.Mul _ (A.Num 0 _) _) -> + o {oCode = ["\txor a"]} + (A.BinOp A.Mul _ (A.Num 1 _) b) -> o {oCode = oCode (emit b)} + (A.BinOp A.Mul _ a (A.Num 1 _)) -> o {oCode = oCode (emit a)} (A.BinOp A.Mul _ a (A.Num 2 _)) -> o {oCode = oCode (emit a) ++ ["\tsla a"]} + (A.BinOp A.Mul _ (A.Num 2 _) b) -> + o {oCode = oCode (emit b) ++ ["\tsla a"]} (A.BinOp A.Mul _ a (A.Num v _)) -> o {oCode = oCode (emit a) ++ ["\tld c, a"] ++ replicate (fromInteger v - 1) "\tadd c"} (A.BinOp A.Mul p a b) -> do -- cgit v1.2.3