emit alignment directives properly
This commit is contained in:
parent
bf3e6753f3
commit
25f7bc06e3
3 changed files with 27 additions and 20 deletions
33
lisc/emit.c
33
lisc/emit.c
|
@ -315,7 +315,6 @@ emitfn(Fn *fn, FILE *f)
|
|||
int *r, c, fs;
|
||||
|
||||
fprintf(f,
|
||||
"\n"
|
||||
".text\n"
|
||||
".globl %s\n"
|
||||
".type %s, @function\n"
|
||||
|
@ -371,34 +370,34 @@ emitfn(Fn *fn, FILE *f)
|
|||
void
|
||||
emitdat(Dat *d, FILE *f)
|
||||
{
|
||||
static char *dtoa[] = {
|
||||
[DAlign] = ".align",
|
||||
[DB] = "\t.byte",
|
||||
[DH] = "\t.value",
|
||||
[DW] = "\t.long",
|
||||
[DL] = "\t.quad"
|
||||
};
|
||||
|
||||
switch (d->type) {
|
||||
case DStart:
|
||||
fprintf(f, ".data\n");
|
||||
break;
|
||||
case DEnd:
|
||||
fprintf(f, "\n");
|
||||
break;
|
||||
case DName:
|
||||
fprintf(f,
|
||||
"\n"
|
||||
".data\n"
|
||||
".globl %s\n"
|
||||
".type %s, @object\n"
|
||||
"%s:\n",
|
||||
d->u.str, d->u.str, d->u.str
|
||||
);
|
||||
break;
|
||||
case DAlign:
|
||||
fprintf(f, ".align %"PRId64"\n", d->u.num);
|
||||
break;
|
||||
case DA:
|
||||
fprintf(f, "\t.string \"%s\"\n", d->u.str);
|
||||
break;
|
||||
case DB:
|
||||
fprintf(f, "\t.byte %"PRId64"\n", d->u.num);
|
||||
break;
|
||||
case DH:
|
||||
fprintf(f, "\t.value %"PRId64"\n", d->u.num);
|
||||
break;
|
||||
case DW:
|
||||
fprintf(f, "\t.long %"PRId64"\n", d->u.num);
|
||||
break;
|
||||
case DL:
|
||||
fprintf(f, "\t.quad %"PRId64"\n", d->u.num);
|
||||
default:
|
||||
fprintf(f, "%s %"PRId64"\n", dtoa[d->type], d->u.num);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue