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.
This commit is contained in:
parent
9bdf602ebb
commit
16acf605e2
6 changed files with 26 additions and 17 deletions
|
@ -29,6 +29,8 @@ typedef struct Frtype Frtype;
|
||||||
Extern int kernel;
|
Extern int kernel;
|
||||||
Extern int text;
|
Extern int text;
|
||||||
Extern int silent;
|
Extern int silent;
|
||||||
|
Extern int fsize[];
|
||||||
|
Extern char afmt;
|
||||||
Extern Fhdr fhdr;
|
Extern Fhdr fhdr;
|
||||||
Extern int line;
|
Extern int line;
|
||||||
Extern Biobuf* bout;
|
Extern Biobuf* bout;
|
||||||
|
|
|
@ -87,7 +87,7 @@ struct Btab
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
char vfmt[] = "aBbcCdDfFgGiIoOqQrRsSuUVWxXYZ38";
|
char vfmt[] = "aABbcCdDfFgGiIoOqQrRsSuUVWxXYZ38";
|
||||||
|
|
||||||
void
|
void
|
||||||
mkprint(Lsym *s)
|
mkprint(Lsym *s)
|
||||||
|
@ -365,7 +365,7 @@ follow(Node *r, Node *args)
|
||||||
for(i = 0; i < n; i++) {
|
for(i = 0; i < n; i++) {
|
||||||
l = al(TINT);
|
l = al(TINT);
|
||||||
l->ival = f[i];
|
l->ival = f[i];
|
||||||
l->fmt = 'X';
|
l->fmt = 'A';
|
||||||
*tail = l;
|
*tail = l;
|
||||||
tail = &l->next;
|
tail = &l->next;
|
||||||
}
|
}
|
||||||
|
@ -390,11 +390,11 @@ funcbound(Node *r, Node *args)
|
||||||
r->l = al(TINT);
|
r->l = al(TINT);
|
||||||
l = r->l;
|
l = r->l;
|
||||||
l->ival = bounds[0];
|
l->ival = bounds[0];
|
||||||
l->fmt = 'X';
|
l->fmt = 'A';
|
||||||
l->next = al(TINT);
|
l->next = al(TINT);
|
||||||
l = l->next;
|
l = l->next;
|
||||||
l->ival = bounds[1];
|
l->ival = bounds[1];
|
||||||
l->fmt = 'X';
|
l->fmt = 'A';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -970,10 +970,14 @@ void
|
||||||
patom(char type, Store *res)
|
patom(char type, Store *res)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
char fmt;
|
||||||
char buf[512];
|
char buf[512];
|
||||||
extern char *typenames[];
|
extern char *typenames[];
|
||||||
|
|
||||||
switch(res->fmt) {
|
fmt = res->fmt;
|
||||||
|
if(fmt == 'A')
|
||||||
|
fmt = afmt;
|
||||||
|
switch(fmt) {
|
||||||
case 'c':
|
case 'c':
|
||||||
Bprint(bout, "%c", (int)res->ival);
|
Bprint(bout, "%c", (int)res->ival);
|
||||||
break;
|
break;
|
||||||
|
@ -1065,7 +1069,6 @@ patom(char type, Store *res)
|
||||||
Bprint(bout, "%S", (Rune*)res->string->string);
|
Bprint(bout, "%S", (Rune*)res->string->string);
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
case 'A':
|
|
||||||
symoff(buf, sizeof(buf), res->ival, CANY);
|
symoff(buf, sizeof(buf), res->ival, CANY);
|
||||||
Bprint(bout, "%s", buf);
|
Bprint(bout, "%s", buf);
|
||||||
break;
|
break;
|
||||||
|
@ -1117,10 +1120,7 @@ comx(Node res)
|
||||||
Lsym *sl;
|
Lsym *sl;
|
||||||
Node *n, xx;
|
Node *n, xx;
|
||||||
|
|
||||||
if(res.fmt != 'a' && res.fmt != 'A')
|
if(res.fmt != 'a' || res.comt == 0 || res.comt->base == 0)
|
||||||
return 0;
|
|
||||||
|
|
||||||
if(res.comt == 0 || res.comt->base == 0)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
sl = res.comt->base;
|
sl = res.comt->base;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#define Extern extern
|
#define Extern extern
|
||||||
#include "acid.h"
|
#include "acid.h"
|
||||||
|
|
||||||
static int fsize[] =
|
int fsize[] =
|
||||||
{
|
{
|
||||||
['A'] 4,
|
['A'] 4,
|
||||||
['B'] 4,
|
['B'] 4,
|
||||||
|
@ -149,7 +149,7 @@ oframe(Node *n, Node *res)
|
||||||
|
|
||||||
res->ival = ival;
|
res->ival = ival;
|
||||||
res->op = OCONST;
|
res->op = OCONST;
|
||||||
res->fmt = 'X';
|
res->fmt = 'A';
|
||||||
res->type = TINT;
|
res->type = TINT;
|
||||||
|
|
||||||
/* Try and set comt */
|
/* Try and set comt */
|
||||||
|
|
|
@ -185,7 +185,7 @@ listvar(char *s, vlong v)
|
||||||
l->string = strnode(s);
|
l->string = strnode(s);
|
||||||
l->next = al(TINT);
|
l->next = al(TINT);
|
||||||
l = l->next;
|
l = l->next;
|
||||||
l->fmt = 'X';
|
l->fmt = 'A';
|
||||||
l->ival = v;
|
l->ival = v;
|
||||||
|
|
||||||
return tl;
|
return tl;
|
||||||
|
@ -260,7 +260,7 @@ trlist(Map *map, uvlong pc, uvlong sp, Symbol *sym)
|
||||||
l = al(TINT); /* Function address */
|
l = al(TINT); /* Function address */
|
||||||
q->l = l;
|
q->l = l;
|
||||||
l->ival = sym->value;
|
l->ival = sym->value;
|
||||||
l->fmt = 'X';
|
l->fmt = 'A';
|
||||||
|
|
||||||
l->next = al(TINT); /* called from address */
|
l->next = al(TINT); /* called from address */
|
||||||
l = l->next;
|
l = l->next;
|
||||||
|
|
|
@ -281,7 +281,7 @@ readtext(char *s)
|
||||||
if(mach->sbreg && lookup(0, mach->sbreg, &sym)) {
|
if(mach->sbreg && lookup(0, mach->sbreg, &sym)) {
|
||||||
mach->sb = sym.value;
|
mach->sb = sym.value;
|
||||||
l = enter("SB", Tid);
|
l = enter("SB", Tid);
|
||||||
l->v->fmt = 'X';
|
l->v->fmt = 'A';
|
||||||
l->v->ival = mach->sb;
|
l->v->ival = mach->sb;
|
||||||
l->v->type = TINT;
|
l->v->type = TINT;
|
||||||
l->v->set = 1;
|
l->v->set = 1;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "acid.h"
|
#include "acid.h"
|
||||||
#include "y.tab.h"
|
#include "y.tab.h"
|
||||||
|
|
||||||
|
char afmt = 'X';
|
||||||
static int syren;
|
static int syren;
|
||||||
|
|
||||||
Lsym*
|
Lsym*
|
||||||
|
@ -88,7 +89,7 @@ varsym(void)
|
||||||
l->v->type = TINT;
|
l->v->type = TINT;
|
||||||
l->v->ival = v;
|
l->v->ival = v;
|
||||||
if(l->v->comt == 0)
|
if(l->v->comt == 0)
|
||||||
l->v->fmt = 'X';
|
l->v->fmt = 'A';
|
||||||
|
|
||||||
/* Enter as list of { name, type, value } */
|
/* Enter as list of { name, type, value } */
|
||||||
list = al(TSTRING);
|
list = al(TSTRING);
|
||||||
|
@ -101,7 +102,7 @@ varsym(void)
|
||||||
list->ival = s->type;
|
list->ival = s->type;
|
||||||
list->next = al(TINT);
|
list->next = al(TINT);
|
||||||
list = list->next;
|
list = list->next;
|
||||||
list->fmt = 'X';
|
list->fmt = l->v->fmt;
|
||||||
list->ival = v;
|
list->ival = v;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -122,6 +123,12 @@ varreg(void)
|
||||||
Reglist *r;
|
Reglist *r;
|
||||||
List **tail, *li;
|
List **tail, *li;
|
||||||
|
|
||||||
|
if(mach->szaddr == 8){
|
||||||
|
afmt = 'Y';
|
||||||
|
fsize['a'] = fsize[afmt];
|
||||||
|
fsize['A'] = fsize[afmt];
|
||||||
|
}
|
||||||
|
|
||||||
l = mkvar("registers");
|
l = mkvar("registers");
|
||||||
v = l->v;
|
v = l->v;
|
||||||
v->set = 1;
|
v->set = 1;
|
||||||
|
|
Loading…
Reference in a new issue