shithub: mc

Download patch

ref: 1826bfd454a41be808611d158192da835b637952
parent: 01c1608893e34bf92640bee970fb35f01db97458
author: Ori Bernstein <[email protected]>
date: Wed Jun 6 21:04:36 EDT 2012

Add support for negation.

--- a/8/insns.def
+++ b/8/insns.def
@@ -26,6 +26,7 @@
 Insn(Isub,      "\tsub%t %r,%x\n",              0)
 Insn(Imul,      "\tmul%t %r\n",              0)
 Insn(Idiv,      "\tdiv%t %r\n",              0)
+Insn(Ineg,      "\tneg%t %r\n",              0)
 Insn(Iand,      "\tand%t %r,%x\n",              0)
 Insn(Ior,       "\tor%t %r,%x\n",               0)
 Insn(Ixor,      "\txor%t %r,%x\n",              0)
--- a/8/isel.c
+++ b/8/isel.c
@@ -552,7 +552,11 @@
             else
                 r = edx;
             break;
-        case Oneg:      die("Unimplemented op %s", opstr(exprop(n))); break;
+        case Oneg:
+            r = selexpr(s, args[0]);
+            r = inr(s, r);
+            g(s, Ineg, &r, NULL);
+            break;
 
         case Obor:      r = binop(s, Ior,  args[0], args[1]); break;
         case Oband:     r = binop(s, Iand, args[0], args[1]); break;
--- a/test/loop.myr
+++ b/test/loop.myr
@@ -1,6 +1,3 @@
-const f = {a
-}
-
 const main = {
 	var i
 	var n
--- a/test/test.sh
+++ b/test/test.sh
@@ -20,9 +20,13 @@
 }
 
 function exitswith {
-    ./$1
-    if [ $? -eq $2 ]; then
-        echo "PASS: $1"
+    if [ -e $1 ]; then
+        ./$1
+        if [ $? -eq $2 ]; then
+            echo "PASS: $1"
+        else
+            echo "FAIL: $1"
+        fi
     else
         echo "FAIL: $1"
     fi