From 47d9abb9652d7ad1a7896d3353bdeb0904d9827c Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Tue, 18 Jul 2017 20:55:08 +0000 Subject: Add remI --- ABC/Assembler.dcl | 1 + ABC/Assembler.icl | 1 + ABC/Machine/BStack.dcl | 1 + ABC/Machine/BStack.icl | 4 ++++ ABC/Machine/Instructions.dcl | 1 + ABC/Machine/Instructions.icl | 4 ++++ 6 files changed, 12 insertions(+) diff --git a/ABC/Assembler.dcl b/ABC/Assembler.dcl index cb83da9..c597407 100644 --- a/ABC/Assembler.dcl +++ b/ABC/Assembler.dcl @@ -85,6 +85,7 @@ from ABC.Machine.GraphStore import ::Desc | IncI | LtI | MulI + | RemI | SubI // Clean compiler additions | Comment String diff --git a/ABC/Assembler.icl b/ABC/Assembler.icl index 17104c4..9096101 100644 --- a/ABC/Assembler.icl +++ b/ABC/Assembler.icl @@ -199,4 +199,5 @@ where trans IncI _ _ = incI trans LtI _ _ = ltI trans MulI _ _ = mulI + trans RemI _ _ = remI trans SubI _ _ = subI diff --git a/ABC/Machine/BStack.dcl b/ABC/Machine/BStack.dcl index 0af277b..900e856 100644 --- a/ABC/Machine/BStack.dcl +++ b/ABC/Machine/BStack.dcl @@ -36,4 +36,5 @@ bs_eqIi :: Int BSrc BStack -> BStack bs_gtI :: BStack -> BStack bs_ltI :: BStack -> BStack bs_mulI :: BStack -> BStack +bs_remI :: BStack -> BStack bs_subI :: BStack -> BStack diff --git a/ABC/Machine/BStack.icl b/ABC/Machine/BStack.icl index 70a1f1a..70007fd 100644 --- a/ABC/Machine/BStack.icl +++ b/ABC/Machine/BStack.icl @@ -102,6 +102,10 @@ bs_mulI :: BStack -> BStack bs_mulI [Int m:Int n:s] = bs_pushI (m * n) s bs_mulI _ = abortn "bs_mulI: no integers" +bs_remI :: BStack -> BStack +bs_remI [Int m:Int n:s] = bs_pushI (m rem n) s +bs_remI _ = abortn "bs_remI: no integers" + bs_subI :: BStack -> BStack bs_subI [Int m:Int n:s] = bs_pushI (m - n) s bs_subI _ = abortn "bs_subI: no integers" diff --git a/ABC/Machine/Instructions.dcl b/ABC/Machine/Instructions.dcl index f0cc5b2..5140c98 100644 --- a/ABC/Machine/Instructions.dcl +++ b/ABC/Machine/Instructions.dcl @@ -62,4 +62,5 @@ gtI :: State -> State incI :: State -> State ltI :: State -> State mulI :: State -> State +remI :: State -> State subI :: State -> State diff --git a/ABC/Machine/Instructions.icl b/ABC/Machine/Instructions.icl index 3ca55af..42dcb62 100644 --- a/ABC/Machine/Instructions.icl +++ b/ABC/Machine/Instructions.icl @@ -385,6 +385,10 @@ mulI :: State -> State mulI st=:{bstack} = {st & bstack=bs_mulI bstack} +remI :: State -> State +remI st=:{bstack} + = {st & bstack=bs_remI bstack} + subI :: State -> State subI st=:{bstack} = {st & bstack=bs_subI bstack} -- cgit v1.2.3