summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2014-02-09 22:43:09 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2014-02-09 22:43:09 +0100
commit16acf605e21e55e8f0520cf54016bfec5291802e (patch)
treeb63615e24216e3d054c052cf330372e1a45b4a23
parent9bdf602ebbdcfcb4baaeb17499a1f1f6865ddc61 (diff)
downloadplan9front-16acf605e21e55e8f0520cf54016bfec5291802e.tar.xz
acid: make 'a' and 'A' format to have the same size as mach->szaddr
to make it easier to write portable acid code, we introduce 'A' format in the same meaning as in db(1): A Print the value of dot in hexadecimal. Dot is unaffected. both 'a' (symbolic) and 'A' will both have 64 or 32 bit size depending on the mach, so pointer array indexing works the same.
-rw-r--r--sys/src/cmd/acid/acid.h2
-rw-r--r--sys/src/cmd/acid/builtin.c20
-rw-r--r--sys/src/cmd/acid/expr.c4
-rw-r--r--sys/src/cmd/acid/list.c4
-rw-r--r--sys/src/cmd/acid/main.c2
-rw-r--r--sys/src/cmd/acid/util.c11
6 files changed, 26 insertions, 17 deletions
diff --git a/sys/src/cmd/acid/acid.h b/sys/src/cmd/acid/acid.h
index bd0d6b7cb..41f63db4f 100644
--- a/sys/src/cmd/acid/acid.h
+++ b/sys/src/cmd/acid/acid.h
@@ -29,6 +29,8 @@ typedef struct Frtype Frtype;
Extern int kernel;
Extern int text;
Extern int silent;
+Extern int fsize[];
+Extern char afmt;
Extern Fhdr fhdr;
Extern int line;
Extern Biobuf* bout;
diff --git a/sys/src/cmd/acid/builtin.c b/sys/src/cmd/acid/builtin.c
index 0ebc11bbf..b8d904c7b 100644
--- a/sys/src/cmd/acid/builtin.c
+++ b/sys/src/cmd/acid/builtin.c
@@ -87,7 +87,7 @@ struct Btab
0
};
-char vfmt[] = "aBbcCdDfFgGiIoOqQrRsSuUVWxXYZ38";
+char vfmt[] = "aABbcCdDfFgGiIoOqQrRsSuUVWxXYZ38";
void
mkprint(Lsym *s)
@@ -365,7 +365,7 @@ follow(Node *r, Node *args)
for(i = 0; i < n; i++) {
l = al(TINT);
l->ival = f[i];
- l->fmt = 'X';
+ l->fmt = 'A';
*tail = l;
tail = &l->next;
}
@@ -390,11 +390,11 @@ funcbound(Node *r, Node *args)
r->l = al(TINT);
l = r->l;
l->ival = bounds[0];
- l->fmt = 'X';
+ l->fmt = 'A';
l->next = al(TINT);
l = l->next;
l->ival = bounds[1];
- l->fmt = 'X';
+ l->fmt = 'A';
}
}
@@ -970,10 +970,14 @@ void
patom(char type, Store *res)
{
int i;
+ char fmt;
char buf[512];
extern char *typenames[];
- switch(res->fmt) {
+ fmt = res->fmt;
+ if(fmt == 'A')
+ fmt = afmt;
+ switch(fmt) {
case 'c':
Bprint(bout, "%c", (int)res->ival);
break;
@@ -1065,7 +1069,6 @@ patom(char type, Store *res)
Bprint(bout, "%S", (Rune*)res->string->string);
break;
case 'a':
- case 'A':
symoff(buf, sizeof(buf), res->ival, CANY);
Bprint(bout, "%s", buf);
break;
@@ -1117,10 +1120,7 @@ comx(Node res)
Lsym *sl;
Node *n, xx;
- if(res.fmt != 'a' && res.fmt != 'A')
- return 0;
-
- if(res.comt == 0 || res.comt->base == 0)
+ if(res.fmt != 'a' || res.comt == 0 || res.comt->base == 0)
return 0;
sl = res.comt->base;
diff --git a/sys/src/cmd/acid/expr.c b/sys/src/cmd/acid/expr.c
index 4ba0943c2..cd24ec7b8 100644
--- a/sys/src/cmd/acid/expr.c
+++ b/sys/src/cmd/acid/expr.c
@@ -6,7 +6,7 @@
#define Extern extern
#include "acid.h"
-static int fsize[] =
+int fsize[] =
{
['A'] 4,
['B'] 4,
@@ -149,7 +149,7 @@ oframe(Node *n, Node *res)
res->ival = ival;
res->op = OCONST;
- res->fmt = 'X';
+ res->fmt = 'A';
res->type = TINT;
/* Try and set comt */
diff --git a/sys/src/cmd/acid/list.c b/sys/src/cmd/acid/list.c
index 5ad7c54e4..be0c3362b 100644
--- a/sys/src/cmd/acid/list.c
+++ b/sys/src/cmd/acid/list.c
@@ -185,7 +185,7 @@ listvar(char *s, vlong v)
l->string = strnode(s);
l->next = al(TINT);
l = l->next;
- l->fmt = 'X';
+ l->fmt = 'A';
l->ival = v;
return tl;
@@ -260,7 +260,7 @@ trlist(Map *map, uvlong pc, uvlong sp, Symbol *sym)
l = al(TINT); /* Function address */
q->l = l;
l->ival = sym->value;
- l->fmt = 'X';
+ l->fmt = 'A';
l->next = al(TINT); /* called from address */
l = l->next;
diff --git a/sys/src/cmd/acid/main.c b/sys/src/cmd/acid/main.c
index 0ef9f65cf..9a18f5f53 100644
--- a/sys/src/cmd/acid/main.c
+++ b/sys/src/cmd/acid/main.c
@@ -281,7 +281,7 @@ readtext(char *s)
if(mach->sbreg && lookup(0, mach->sbreg, &sym)) {
mach->sb = sym.value;
l = enter("SB", Tid);
- l->v->fmt = 'X';
+ l->v->fmt = 'A';
l->v->ival = mach->sb;
l->v->type = TINT;
l->v->set = 1;
diff --git a/sys/src/cmd/acid/util.c b/sys/src/cmd/acid/util.c
index b47d4cbbb..46431f75e 100644
--- a/sys/src/cmd/acid/util.c
+++ b/sys/src/cmd/acid/util.c
@@ -7,6 +7,7 @@
#include "acid.h"
#include "y.tab.h"
+char afmt = 'X';
static int syren;
Lsym*
@@ -88,7 +89,7 @@ varsym(void)
l->v->type = TINT;
l->v->ival = v;
if(l->v->comt == 0)
- l->v->fmt = 'X';
+ l->v->fmt = 'A';
/* Enter as list of { name, type, value } */
list = al(TSTRING);
@@ -101,7 +102,7 @@ varsym(void)
list->ival = s->type;
list->next = al(TINT);
list = list->next;
- list->fmt = 'X';
+ list->fmt = l->v->fmt;
list->ival = v;
}
@@ -122,6 +123,12 @@ varreg(void)
Reglist *r;
List **tail, *li;
+ if(mach->szaddr == 8){
+ afmt = 'Y';
+ fsize['a'] = fsize[afmt];
+ fsize['A'] = fsize[afmt];
+ }
+
l = mkvar("registers");
v = l->v;
v->set = 1;