diff options
author | Camil Staps | 2017-07-18 21:01:31 +0000 |
---|---|---|
committer | Camil Staps | 2017-07-18 21:01:31 +0000 |
commit | c0dfbd7ca37ae769d87ae99c1a6a8443a2a8851f (patch) | |
tree | e60a856d996021594aed02524a72272d2daa1f3a | |
parent | Add remI (diff) |
Add negI
-rw-r--r-- | ABC/Assembler.dcl | 1 | ||||
-rw-r--r-- | ABC/Assembler.icl | 1 | ||||
-rw-r--r-- | ABC/Machine/BStack.dcl | 1 | ||||
-rw-r--r-- | ABC/Machine/BStack.icl | 4 | ||||
-rw-r--r-- | ABC/Machine/Instructions.dcl | 1 | ||||
-rw-r--r-- | ABC/Machine/Instructions.icl | 4 |
6 files changed, 12 insertions, 0 deletions
diff --git a/ABC/Assembler.dcl b/ABC/Assembler.dcl index c597407..2c6894a 100644 --- a/ABC/Assembler.dcl +++ b/ABC/Assembler.dcl @@ -85,6 +85,7 @@ from ABC.Machine.GraphStore import ::Desc | IncI | LtI | MulI + | NegI | RemI | SubI // Clean compiler additions diff --git a/ABC/Assembler.icl b/ABC/Assembler.icl index 9096101..ca121a8 100644 --- a/ABC/Assembler.icl +++ b/ABC/Assembler.icl @@ -199,5 +199,6 @@ where trans IncI _ _ = incI trans LtI _ _ = ltI trans MulI _ _ = mulI + trans NegI _ _ = negI trans RemI _ _ = remI trans SubI _ _ = subI diff --git a/ABC/Machine/BStack.dcl b/ABC/Machine/BStack.dcl index 900e856..9d938ef 100644 --- a/ABC/Machine/BStack.dcl +++ b/ABC/Machine/BStack.dcl @@ -36,5 +36,6 @@ bs_eqIi :: Int BSrc BStack -> BStack bs_gtI :: BStack -> BStack bs_ltI :: BStack -> BStack bs_mulI :: BStack -> BStack +bs_negI :: BStack -> BStack bs_remI :: BStack -> BStack bs_subI :: BStack -> BStack diff --git a/ABC/Machine/BStack.icl b/ABC/Machine/BStack.icl index 70007fd..a9a2d0e 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_negI :: BStack -> BStack +bs_negI [Int n:s] = bs_pushI (~n) s +bs_negI _ = abortn "bs_negI: no integer" + bs_remI :: BStack -> BStack bs_remI [Int m:Int n:s] = bs_pushI (m rem n) s bs_remI _ = abortn "bs_remI: no integers" diff --git a/ABC/Machine/Instructions.dcl b/ABC/Machine/Instructions.dcl index 5140c98..d5a37f9 100644 --- a/ABC/Machine/Instructions.dcl +++ b/ABC/Machine/Instructions.dcl @@ -62,5 +62,6 @@ gtI :: State -> State incI :: State -> State ltI :: State -> State mulI :: State -> State +negI :: State -> State remI :: State -> State subI :: State -> State diff --git a/ABC/Machine/Instructions.icl b/ABC/Machine/Instructions.icl index 42dcb62..54e7ebd 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} +negI :: State -> State +negI st=:{bstack} + = {st & bstack=bs_negI bstack} + remI :: State -> State remI st=:{bstack} = {st & bstack=bs_remI bstack} |