diff options
author | Juan J. Martinez <jjm@usebox.net> | 2022-09-25 20:22:31 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2022-09-25 20:22:31 +0100 |
commit | 0c2b9dc0c37505a5134f904ea867f2a311bfe162 (patch) | |
tree | 1085c7edefe466a9af5809264705c3b1ecc518d0 /src/Micro/Asm | |
parent | a8bd2cac6d7b3d71f2ff3d9ce655e65a827d5775 (diff) | |
download | micro-lang-hs-0c2b9dc0c37505a5134f904ea867f2a311bfe162.tar.gz micro-lang-hs-0c2b9dc0c37505a5134f904ea867f2a311bfe162.zip |
Optimizations
Diffstat (limited to 'src/Micro/Asm')
-rw-r--r-- | src/Micro/Asm/Sdcc.hs | 7 |
1 files changed, 6 insertions, 1 deletions
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 |