summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--lisc/emit.c29
-rw-r--r--lisc/main.c2
-rw-r--r--lisc/parse.c2
3 files changed, 22 insertions, 11 deletions
diff --git a/lisc/emit.c b/lisc/emit.c
index 240bfc6..34e7d7e 100644
--- a/lisc/emit.c
+++ b/lisc/emit.c
@@ -538,6 +538,7 @@ emitfn(Fn *fn, FILE *f)
 void
 emitdat(Dat *d, FILE *f)
 {
+	static int align;
 	static char *dtoa[] = {
 		[DAlign] = ".align",
 		[DB] = "\t.byte",
@@ -548,11 +549,14 @@ emitdat(Dat *d, FILE *f)
 
 	switch (d->type) {
 	case DStart:
+		align = 0;
 		fprintf(f, ".data\n");
 		break;
 	case DEnd:
 		break;
 	case DName:
+		if (!align)
+			fprintf(f, ".align 8\n");
 		fprintf(f,
 			".globl %s\n"
 			".type %s, @object\n"
@@ -563,19 +567,24 @@ emitdat(Dat *d, FILE *f)
 	case DZ:
 		fprintf(f, "\t.fill %"PRId64",1,0\n", d->u.num);
 		break;
-	case DB:
+	default:
+		if (d->type == DAlign)
+			align = 1;
+
 		if (d->isstr) {
+			if (d->type != DB)
+				err("strings only supported for 'b' currently");
 			fprintf(f, "\t.ascii \"%s\"\n", d->u.str);
-			break;
 		}
-		/* fallthrough */
-	default:
-		if (d->isstr)
-			err("strings only supported for 'b' currently");
-		if (d->isref)
-			fprintf(f, "%s %s%+"PRId64"\n", dtoa[d->type], d->u.ref.nam, d->u.ref.off);
-		else
-			fprintf(f, "%s %"PRId64"\n", dtoa[d->type], d->u.num);
+		else if (d->isref) {
+			fprintf(f, "%s %s%+"PRId64"\n",
+				dtoa[d->type], d->u.ref.nam,
+				d->u.ref.off);
+		}
+		else {
+			fprintf(f, "%s %"PRId64"\n",
+				dtoa[d->type], d->u.num);
+		}
 		break;
 	}
 }
diff --git a/lisc/main.c b/lisc/main.c
index a8fa105..026a8b0 100644
--- a/lisc/main.c
+++ b/lisc/main.c
@@ -23,7 +23,7 @@ data(Dat *d)
 	if (dbg)
 		return;
 	if (d->type == DEnd) {
-		fputs("/* end data */\n", outf);
+		fputs("/* end data */\n\n", outf);
 		freeall();
 	}
 	emitdat(d, outf);
diff --git a/lisc/parse.c b/lisc/parse.c
index 3cc983a..537ec02 100644
--- a/lisc/parse.c
+++ b/lisc/parse.c
@@ -799,6 +799,8 @@ parsedat(void cb(Dat *))
 	Dat d;
 
 	d.type = DStart;
+	d.isstr = 0;
+	d.isref = 0;
 	cb(&d);
 	if (nextnl() != TGlo || nextnl() != TEq)
 		err("data name, then = expected");