shithub: mc

Download patch

ref: 638f06666e1c54c566f2ba8062a477499c66cedb
parent: eed72af62209c958db8cfd6af207cccd9f2daa18
author: Ori Bernstein <[email protected]>
date: Tue Dec 23 03:34:17 EST 2014

Get some more plan9 addressing syntax in there.

--- a/6/genp9.c
+++ b/6/genp9.c
@@ -89,35 +89,27 @@
     if (l->type == Locmem) {
         if (l->mem.constdisp)
             fprintf(fd, "%ld", l->mem.constdisp);
-    } else {
-        if (l->mem.lbldisp) {
-            if (l->mem.base)
-                fprintf(fd, "$%s", l->mem.lbldisp);
-            else
-                fprintf(fd, "%s", l->mem.lbldisp);
-        }
+    } else if (l->mem.lbldisp) {
+        if (l->mem.base)
+            fprintf(fd, "$%s", l->mem.lbldisp);
+        else
+            fprintf(fd, "%s", l->mem.lbldisp);
     }
-    if (l->mem.base) {
-        if (l->mem.base->reg.colour == Rrip) {
+    if (!l->mem.base || l->mem.base->reg.colour == Rrip) {
             fprintf(fd, "+0(SB)");
-        } else {
+    } else {
+        fprintf(fd, "(");
+        locprint(fd, l->mem.base, 'r');
+        fprintf(fd, ")");
+    }
+        if (l->mem.idx) {
             fprintf(fd, "(");
-            locprint(fd, l->mem.base, 'r');
-            if (l->mem.idx) {
-                fprintf(fd, ",");
-                locprint(fd, l->mem.idx, 'r');
-            }
+            locprint(fd, l->mem.idx, 'r');
             if (l->mem.scale > 1)
-                fprintf(fd, ",%d", l->mem.scale);
-            if (l->mem.base)
-                fprintf(fd, ")");
+                fprintf(fd, "*%d", l->mem.scale);
+            fprintf(fd, ")");
         }
-    } else if (l->type != Locmeml) {
-        die("Only locmeml can have unspecified base reg");
-    } else {
-        fprintf(fd, "+0(SB)");
     }
-
 }
 
 static void locprint(FILE *fd, Loc *l, char spec)