diff options
| author | Quentin Carbonneaux <[email protected]> | 2026-01-06 20:42:31 +0100 |
|---|---|---|
| committer | Quentin Carbonneaux <[email protected]> | 2026-01-06 20:43:42 +0100 |
| commit | e0ded59639848a82878bbcf0b27fb3637f8d9353 (patch) | |
| tree | c14ead4583fb7e83c61e9d4524538ef0a7454c36 /emit.c | |
| parent | 0f6bbb1c7cfef879096f5e8e8e23951ac02dbab0 (diff) | |
please as with truncated constants
Apple's assembler actually hard
crashed on overflows.
Diffstat (limited to 'emit.c')
| -rw-r--r-- | emit.c | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -61,11 +61,14 @@ emitfnlnk(char *n, Lnk *l, FILE *f) void emitdat(Dat *d, FILE *f) { - static char *dtoa[] = { - [DB] = "\t.byte", - [DH] = "\t.short", - [DW] = "\t.int", - [DL] = "\t.quad" + static struct { + char decl[8]; + int64_t mask; + } di[] = { + [DB] = {"\t.byte", 0xffL}, + [DH] = {"\t.short", 0xffffL}, + [DW] = {"\t.int", 0xffffffffL}, + [DL] = {"\t.quad", -1L}, }; static int64_t zero; char *p; @@ -111,12 +114,13 @@ emitdat(Dat *d, FILE *f) else if (d->isref) { p = d->u.ref.name[0] == '"' ? "" : T.assym; fprintf(f, "%s %s%s%+"PRId64"\n", - dtoa[d->type], p, d->u.ref.name, + di[d->type].decl, p, d->u.ref.name, d->u.ref.off); } else { fprintf(f, "%s %"PRId64"\n", - dtoa[d->type], d->u.num); + di[d->type].decl, + d->u.num & di[d->type].mask); } break; } |
