/*
* tack on the string file.
*/
- printf(".area data\n");
+ printf(".globl\n.data\n");
if (*argv[2] != '-') {
if (freopen(argv[2], "r", stdin)==NULL) {
error("Missing temp file");
}
tree = atree;
tree->op = CALL2;
-#if 0 /* seems to generate "jsr pc,*#label" instead of "jsr pc,label" */
if (modf && tree->tr1->op==NAME && tree->tr1->class==EXTERN)
tree->op = CALL1;
-#endif
if (cexpr(tree, regtab, reg)<0)
error("compiler botch: call");
popstk(r);
string = opt->tabstring;
p1 = tree->tr1;
if (p1->op==FCON && p1->value>0) {
- printf(".area data\nL%d:.dw %d,%d,%d,%d\n.area text\n", p1->value, p1->fvalue);
+ printf(".data\nL%d:%o;%o;%o;%o\n.text\n", p1->value, p1->fvalue);
p1->value = -p1->value;
}
p2 = 0;
if (opdope[tree->op]&BINARY) {
p2 = tree->tr2;
if (p2->op==FCON && p2->value>0) {
- printf(".area data\nL%d:.dw %d,%d,%d,%d\n.area text\n", p2->value, p2->fvalue);
+ printf(".data\nL%d:%o;%o;%o;%o\n.text\n", p2->value, p2->fvalue);
p2->value = -p2->value;
}
}
* Mask used in field assignments
*/
case 'Z':
- printf("#%d", tree->mask);
+ printf("$%o", tree->mask);
goto loop;
/*
} else {
if (retval!=0)
printf("mov r%d,r0\n", retval);
- printf("mov #%d,r1\n", size);
+ printf("mov $%o,r1\n", size);
printf("L%d:mov -(r0),-(sp)\ndec\tr1\njne\tL%d\n", isn, isn);
isn++;
}
tree = atree;
type = atype;
if (type==CHAR) {
- printf(".db ");
+ printf(".byte ");
if (tree->type&XTYPE)
goto illinit;
type = INT;
}
- else
- printf(".dw ");
if (type&XTYPE)
type = INT;
switch (type) {
tree->value = lval;
}
if (tree->op == CON)
- printf("%d\n", tree->value);
+ printf("%o\n", tree->value);
else if (tree->op==AMPER) {
pname(tree->tr1, 0);
putchar('\n');
goto illinit;
if (type==FLOAT) {
sfval = fval;
- printf("%d,%d\n", sfval);
+ printf("%o; %o\n", sfval);
} else
- printf("%d,%d,%d,%d\n", fval);
+ printf("%o; %o; %o; %o\n", fval);
return;
case LONG:
lval = tree->lvalue;
else
goto illinit;
- printf("%d,%d\n", lval);
+ printf("%o; %o\n", lval);
return;
}
illinit:
switch(p->op) {
case LCON:
- printf("#%d", flag>10? p->lvalue.intx[1]:p->lvalue.intx[0]);
+ printf("$%o", flag>10? p->lvalue.intx[1]:p->lvalue.intx[0]);
return;
case SFCON:
case CON:
- printf("#");
+ printf("$");
psoct(p->value);
return;
return;
case AMPER:
- putchar('#');
+ putchar('$');
p = p->tr1;
if (p->op==NAME && p->class==REG)
regerr();
*/
char dirsw[] {"\
-cmp r0,#%d\n\
+cmp r0,$%o\n\
jhi L%d\n\
asl r0\n\
jmp *L%d(r0)\n\
-.area data\n\
+.data\n\
L%d:\
" };
char hashsw[] {"\
mov r0,r1\n\
clr r0\n\
-div #%d,r0\n\
+div $%o,r0\n\
asl r1\n\
jmp *L%d(r1)\n\
-.area data\n\
+.data\n\
L%d:\
"};
/* direct switch */
if (range>0 && range <= 3*ncase) {
if (fp->swval)
- printf("sub #%d,r0\n", fp->swval);
+ printf("sub $%o,r0\n", fp->swval);
printf(dirsw, range, deflab, isn, isn);
isn++;
for (i=fp->swval; ; i++) {
if (i==fp->swval) {
- printf(".dw L%d\n", fp->swlab);
+ printf("L%d\n", fp->swlab);
if (fp==lp)
break;
fp++;
} else
- printf(".dw L%d\n", deflab);
+ printf("L%d\n", deflab);
}
- printf(".area text\n");
+ printf(".text\n");
return;
}
/* simple switch */
printf(hashsw, tabs, i, i);
isn++;
for (i=0; i<tabs; i++)
- printf(".dw L%d\n", isn+i);
- printf(".area text\n");
+ printf("L%d\n", isn+i);
+ printf(".text\n");
for (i=0; i<tabs; i++) {
printf("L%d:", isn++);
for (swp=fp; swp<=lp; swp++) {
if (v==0)
printf("tst r0\n");
else
- printf("cmp r0,#%d\n", v);
+ printf("cmp r0,$%o\n", v);
printf("jeq L%d\n", l);
}
}
if (cexpr(tree, cctab, reg) < 0) {
reg = rcexpr(tree, regtab, reg);
- printf("ashc #0,r%d\n", reg);
+ printf("ashc $0,r%d\n", reg);
branch(xlab1, op, 0);
}
xlab1 = xl1;
printf("cmp (sp)+,(sp)+\n");
return;
}
- printf("add #%d,sp\n", a);
+ printf("add $%o,sp\n", a);
}
error(s, p1, p2, p3, p4, p5, p6)
n = -n;
sign = '-';
}
- printf("%c%d", sign, n);
+ printf("%c%o", sign, n);
}
/*
case SINIT:
fprintf(stderr, "SINIT\n");
- printf("%d\n", geti());
+ printf("%o\n", geti());
break;
case EOFC:
case BDATA:
fprintf(stderr, "BDATA\n");
if (geti() == 1) {
- printf(".db ");
+ printf(".byte ");
for (;;) {
- printf("%d", geti());
+ printf("%o", geti());
if (geti() != 1)
break;
printf(",");
case PROG:
fprintf(stderr, "PROG\n");
- printf(".area text\n");
+ printf(".text\n");
break;
case DATA:
fprintf(stderr, "DATA\n");
- printf(".area data\n");
+ printf(".data\n");
break;
case BSS:
fprintf(stderr, "BSS\n");
- printf(".area bss\n");
+ printf(".bss\n");
break;
case SYMDEF:
fprintf(stderr, "SYMDEF\n");
outname(s);
- if (s[0])
- printf(".globl %.8s\n", s);
+ printf(".globl%s%.8s\n", s[0]?" ":"", s);
sfuncr.nloc = 0;
break;
case RETRN:
fprintf(stderr, "RETRN\n");
- printf(".globl cret\njmp cret\n");
+ printf("jmp cret\n");
break;
case CSPACE:
fprintf(stderr, "CSPACE\n");
t = outname(s);
- printf(".comm %.8s,%d\n", t, geti());
+ printf(".comm %.8s,%o\n", t, geti());
break;
case SSPACE:
fprintf(stderr, "SSPACE\n");
- printf(".=.+%d\n", (t=geti()));
+ printf(".=.+%o\n", (t=geti()));
totspace += (unsigned)t;
break;
case SAVE:
fprintf(stderr, "SAVE\n");
- printf(".globl csv\njsr r5,csv\n");
+ printf("jsr r5,csv\n");
break;
case SETSTK:
if (t==2)
printf("tst -(sp)\n");
else if (t != 0)
- printf("sub #%d,sp\n", t);
+ printf("sub $%o,sp\n", t);
break;
case PROFIL:
fprintf(stderr, "PROFIL\n");
t = geti();
- printf("mov #L%d,r0\n.globl mcount\njsr pc,mcount\n", t);
- printf(".area bss\nL%d:.=.+2\n.area text\n", t);
+ printf("mov $L%d,r0\njsr pc,mcount\n", t);
+ printf(".bss\nL%d:.=.+2\n.text\n", t);
break;
case SNAME:
fprintf(stderr, "SNAME\n");
t = outname(s);
- printf(";~%s=L%d\n", t+1, geti());
+ printf("~%s=L%d\n", t+1, geti());
break;
case ANAME:
fprintf(stderr, "ANAME\n");
t = outname(s);
- printf(";~%s=%d\n", t+1, geti());
+ printf("~%s=%o\n", t+1, geti());
break;
case RNAME:
fprintf(stderr, "RNAME\n");
t = outname(s);
- printf(";~%s=r%d\n", t+1, geti());
+ printf("~%s=r%d\n", t+1, geti());
break;
case SWIT:
else {
if ((*sp)->type==LONG) {
rcexpr(tnode(RFORCE, (*sp)->type, *sp), efftab, 0);
- printf("ashc #0,r0\n");
+ printf("ashc $0,r0\n");
} else {
rcexpr(*sp, cctab, 0);
if (isfloat(*sp))
np = getblk(sizeof(*xnp));
np->type = geti();
outname(np->name);
- printf(".globl %.8s\n", np->name);
} else {
np = getblk(sizeof(*np));
np->type = geti();
case RLABEL:
fprintf(stderr, "RLABEL\n");
t = outname(s);
- printf("%.8s:\n;~~%s:\n", t, t+1);
+ printf("%.8s:\n~~%s:\n", t, t+1);
break;
case BRANCH:
i = getchar();
i += getchar()<<8;
+ fprintf(stderr, "i %d\n", i);
return(i);
}
do {
*p++ = 0;
} while (n++ < 8);
+ fprintf(stderr, "outname %.8s\n", s);
return(s);
}
if (tp->op==RFORCE) { /* function return */
if (sfuncr.nloc==0) {
sfuncr.nloc = isn++;
- printf(".area bss\nL%d:.=.+%d\n.area text\n", sfuncr.nloc, nwords*sizeof(int));
+ printf(".bss\nL%d:.=.+%o\n.text\n", sfuncr.nloc, nwords*sizeof(int));
}
atp->tr1 = tnode(ASSIGN, STRUCT, &sfuncr, tp->tr1);
strasg(atp);
- printf("mov #L%d,r0\n", sfuncr.nloc);
+ printf("mov $L%d,r0\n", sfuncr.nloc);
return;
}
if (tp->op==CALL) {
}
if (nreg<=1)
printf("mov r2,-(sp)\n");
- printf("mov #%d,r2\n", nwords);
+ printf("mov $%o,r2\n", nwords);
printf("L%d:mov (r1)+,(r0)+\ndec\tr2\njne\tL%d\n", isn, isn);
isn++;
if (nreg<=1)
continue;
}
}
- if (equstr(regs[RT1], "#0")) {
+ if (equstr(regs[RT1], "$0")) {
p->op = CLR;
strcpy(regs[RT1], regs[RT2]);
regs[RT2][0] = 0;
case ASH:
dble:
dualop(p);
- if (p->op==BIC && (equstr(regs[RT1], "#-1") || equstr(regs[RT1], "#177777"))) {
+ if (p->op==BIC && (equstr(regs[RT1], "$-1") || equstr(regs[RT1], "$177777"))) {
p->op = CLR;
strcpy(regs[RT1], regs[RT2]);
regs[RT2][0] = 0;
p->code = copy(1, regs[RT1]);
goto sngl;
}
- if ((p->op==BIC || p->op==BIS) && equstr(regs[RT1], "#0")) {
+ if ((p->op==BIC || p->op==BIS) && equstr(regs[RT1], "$0")) {
if (p->forw->op!=CBR) {
p->back->forw = p->forw;
p->forw->back = p->back;
dest(regs[RT1], flt);
if (p->op==CLR && flt==0)
if ((r = isreg(regs[RT1])) >= 0)
- savereg(r, "#0");
+ savereg(r, "$0");
else
- setcon("#0", regs[RT1]);
+ setcon("$0", regs[RT1]);
ccloc[0] = 0;
continue;
source(regs[RT1]);
source(regs[RT2]);
if(p->op==BIT) {
- if (equstr(regs[RT1], "#-1") || equstr(regs[RT1], "#177777")) {
+ if (equstr(regs[RT1], "$-1") || equstr(regs[RT1], "$177777")) {
p->op = TST;
strcpy(regs[RT1], regs[RT2]);
regs[RT2][0] = 0;
p->code = copy(1, regs[RT1]);
nchange++;
nsaddr++;
- } else if (equstr(regs[RT2], "#-1") || equstr(regs[RT2], "#177777")) {
+ } else if (equstr(regs[RT2], "$-1") || equstr(regs[RT2], "$177777")) {
p->op = TST;
regs[RT2][0] = 0;
p->code = copy(1, regs[RT1]);
nchange++;
nsaddr++;
}
- if (equstr(regs[RT1], "#0")) {
+ if (equstr(regs[RT1], "$0")) {
p->op = TST;
regs[RT2][0] = 0;
p->code = copy(1, regs[RT1]);
nchange++;
nsaddr++;
- } else if (equstr(regs[RT2], "#0")) {
+ } else if (equstr(regs[RT2], "$0")) {
p->op = TST;
strcpy(regs[RT1], regs[RT2]);
regs[RT2][0] = 0;
if (p->back->op==TST || p->back->op==CMP) {
if (p->back->op==TST) {
singop(p->back);
- savereg(RT2, "#0");
+ savereg(RT2, "$0");
} else
dualop(p->back);
r = compare(p->subop, findcon(RT1), findcon(RT2));
while (*s) {
if ((*s=='(' && (*(s+1)!='r' || *(s+2)!='5')) || *s++=='*') {
for (i=0; i<NREG+NREG; i++) {
- if (regs[i][0] != '#')
+ if (regs[i][0] != '$')
regs[i][0] = 0;
conloc[0] = 0;
}
p1 = nonlab(p1);
if (p1->op==TST) {
singop(p1);
- savereg(RT2, "#0");
+ savereg(RT2, "$0");
} else if (p1->op==CMP)
dualop(p1);
else
register r;
p = regs[i];
- if (*p=='#')
+ if (*p=='$')
return(p);
if ((r = isreg(p)) >= 0)
return(regs[r]);
{
register unsigned n1, n2;
- if (*cp1++ != '#' || *cp2++ != '#')
+ if (*cp1++ != '$' || *cp2++ != '$')
return(-1);
n1 = 0;
while (*cp2 >= '0' && *cp2 <= '7') {
cl = ar2;
cv = ar1;
- if (*cv != '#')
+ if (*cv != '$')
return;
if (!natural(cl))
return;