summary refs log tree commit diff
path: root/lisc/emit.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-02-04 12:21:45 -0500
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-02-04 12:21:50 -0500
commit90138539bce046fa8746c326841d2fc7e4e8c20d (patch)
tree9a80c39967e618f77c00641aab17d8b4e08de89e /lisc/emit.c
parent059d378b9d4115061647b8efae95b3a7dc54abe2 (diff)
downloadroux-90138539bce046fa8746c326841d2fc7e4e8c20d.tar.gz
fix emit bugs for binops
Diffstat (limited to 'lisc/emit.c')
-rw-r--r--lisc/emit.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/lisc/emit.c b/lisc/emit.c
index e0fb5b4..480b6d0 100644
--- a/lisc/emit.c
+++ b/lisc/emit.c
@@ -41,11 +41,11 @@ static struct {
 	short cls;
 	char *asm;
 } omap[] = {
-	{ OAdd,    Ka, "+add%k %1, %0" },
-	{ OSub,    Ka, "-sub%k %1, %0" },
-	{ OAnd,    Ki, "+and%k %1, %0" },
-	{ OMul,    Ki, "+imul%k %1, %0" },
-	{ ODiv,    Ka, "-div%k %1, %0" },
+	{ OAdd,    Ka, "+add%k %1, %=" },
+	{ OSub,    Ka, "-sub%k %1, %=" },
+	{ OAnd,    Ki, "+and%k %1, %=" },
+	{ OMul,    Ki, "+imul%k %1, %=" },
+	{ ODiv,    Ka, "-div%k %1, %=" },
 	{ OStorel, Ki, "movq %L0, %M1" },
 	{ OStorew, Ki, "movl %W0, %M1" },
 	{ OStoreh, Ki, "movw %H0, %M1" },
@@ -187,8 +187,6 @@ emitf(char *s, Ins *i, Fn *fn, FILE *f)
 	Mem *m;
 	Con off;
 
-	fputc('\t', f);
-
 	switch (*s) {
 	case '+':
 		if (req(i->arg[1], i->to)) {
@@ -200,11 +198,12 @@ emitf(char *s, Ins *i, Fn *fn, FILE *f)
 	case '-':
 		if (req(i->arg[1], i->to) && !req(i->arg[0], i->to))
 			diag("emit: cannot convert to 2-address");
-		emitcopy(i->arg[0], i->to, i->cls, fn, f);
+		emitcopy(i->to, i->arg[0], i->cls, fn, f);
 		s++;
 		break;
 	}
 
+	fputc('\t', f);
 Next:
 	while ((c = *s++) != '%')
 		if (!c) {