summaryrefslogtreecommitdiff
path: root/utils/8l/span.c
diff options
context:
space:
mode:
authorforsyth <forsyth@lavoro.terzarima.net>2013-06-03 21:01:14 +0000
committerforsyth <forsyth@lavoro.terzarima.net>2013-06-03 21:01:14 +0000
commit45a20ab721a513710138340faff3d59a31c3e01e (patch)
treeeea29d2684c51cc73725b8992a2125bede48e118 /utils/8l/span.c
parentcd8e99851af33e52bcdf8faf34f9d4e62fa0cbaf (diff)
sync compilers with Plan 9
remove 1[acl] 2[acl]
Diffstat (limited to 'utils/8l/span.c')
-rw-r--r--utils/8l/span.c46
1 files changed, 36 insertions, 10 deletions
diff --git a/utils/8l/span.c b/utils/8l/span.c
index 67ec929b..729ae8df 100644
--- a/utils/8l/span.c
+++ b/utils/8l/span.c
@@ -236,12 +236,12 @@ asmlc(void)
if(p->line == oldlc || p->as == ATEXT || p->as == ANOP) {
if(p->as == ATEXT)
curtext = p;
- if(debug['L'])
+ if(debug['V'])
Bprint(&bso, "%6lux %P\n",
p->pc, p);
continue;
}
- if(debug['L'])
+ if(debug['V'])
Bprint(&bso, "\t\t%6ld", lcsize);
v = (p->pc - oldpc) / MINLC;
while(v) {
@@ -249,7 +249,7 @@ asmlc(void)
if(v < 127)
s = v;
cput(s+128); /* 129-255 +pc */
- if(debug['L'])
+ if(debug['V'])
Bprint(&bso, " pc+%ld*%d(%ld)", s, MINLC, s+128);
v -= s;
lcsize++;
@@ -263,7 +263,7 @@ asmlc(void)
cput(s>>16);
cput(s>>8);
cput(s);
- if(debug['L']) {
+ if(debug['V']) {
if(s > 0)
Bprint(&bso, " lc+%ld(%d,%ld)\n",
s, 0, s);
@@ -278,14 +278,14 @@ asmlc(void)
}
if(s > 0) {
cput(0+s); /* 1-64 +lc */
- if(debug['L']) {
+ if(debug['V']) {
Bprint(&bso, " lc+%ld(%ld)\n", s, 0+s);
Bprint(&bso, "%6lux %P\n",
p->pc, p);
}
} else {
cput(64-s); /* 65-128 -lc */
- if(debug['L']) {
+ if(debug['V']) {
Bprint(&bso, " lc%ld(%ld)\n", s, 64-s);
Bprint(&bso, "%6lux %P\n",
p->pc, p);
@@ -298,12 +298,30 @@ asmlc(void)
cput(s);
lcsize++;
}
- if(debug['v'] || debug['L'])
+ if(debug['v'] || debug['V'])
Bprint(&bso, "lcsize = %ld\n", lcsize);
Bflush(&bso);
}
int
+prefixof(Adr *a)
+{
+ switch(a->type) {
+ case D_INDIR+D_CS:
+ return 0x2e;
+ case D_INDIR+D_DS:
+ return 0x3e;
+ case D_INDIR+D_ES:
+ return 0x26;
+ case D_INDIR+D_FS:
+ return 0x64;
+ case D_INDIR+D_GS:
+ return 0x65;
+ }
+ return 0;
+}
+
+int
oclass(Adr *a)
{
long v;
@@ -608,7 +626,7 @@ asmand(Adr *a, int r)
}
if(t >= D_INDIR) {
t -= D_INDIR;
- if(t == D_NONE) {
+ if(t == D_NONE || D_CS <= t && t <= D_GS) {
*andptr++ = (0 << 6) | (5 << 0) | (r << 3);
put4(v);
return;
@@ -769,6 +787,7 @@ uchar ymovtab[] =
ASHRL, Ycol, Yml, 6, 0xac,0xad,0,0,
/* extra imul */
+ AIMULW, Yml, Yrl, 7, Pq,0xaf,0,0,
AIMULL, Yml, Yrl, 7, Pm,0xaf,0,0,
0
};
@@ -823,7 +842,14 @@ doasm(Prog *p)
Prog *q, pp;
uchar *t;
int z, op, ft, tt;
- long v;
+ long v, pre;
+
+ pre = prefixof(&p->from);
+ if(pre)
+ *andptr++ = pre;
+ pre = prefixof(&p->to);
+ if(pre)
+ *andptr++ = pre;
o = &optab[p->as];
ft = oclass(&p->from) * Ymax;
@@ -1063,7 +1089,7 @@ found:
q = p->pcond;
if(q) {
v = q->pc - p->pc - 2;
- if(v < -128 && v > 127)
+ if(v < -128 || v > 127)
diag("loop too far: %P", p);
*andptr++ = op;
*andptr++ = v;