ref: 68cbebc85a6394a3e23a75f911330eed9022629c
parent: 6cc5bc96736774d258b2cd7757f9831be6845863
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)