Skip to content

Commit

Permalink
Widen valu_t in the assembler to 64 bits.
Browse files Browse the repository at this point in the history
Most machines had undefined valu_t and redefined it to a different
type.  Edit mach/*/as/mach0.c to remove such redefinitions, so the
next change to valu_t will affect all machines.

Edit mach/proto/as/comm0.h to change valu_t to int64_t, and add
uvalu_t and uint64_t.

Remove int64_t y_valu8 from the yacc %union, now that valu_t y_valu
can hold 64 bits.  Replace y_valu8 with y_valu.  The .data8 pseudo
becomes less special; it now accepts absolute expressions.

This change simplifies the assembler and seems to have no effect on
the assembled output.  Among the files in share/ack/examples, the only
changes are in hilo_bas.* and startrek_c.linuxppc, but those files
seem to change whenever I rebuild them.
  • Loading branch information
kernigh committed Oct 4, 2019
1 parent 0b0c3d5 commit a434749
Show file tree
Hide file tree
Showing 15 changed files with 14 additions and 55 deletions.
3 changes: 0 additions & 3 deletions mach/arm/as/mach0.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
#define WORDS_REVERSED
#define BYTES_REVERSED
*/
#undef valu_t
#define valu_t long

#undef ADDR_T
#define ADDR_T long

Expand Down
2 changes: 0 additions & 2 deletions mach/i386/as/mach0.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#define LISTING /* enable listing facilities */
#define RELOCATION /* generate relocation info */

#undef valu_t
#define valu_t long
#undef ADDR_T
#define ADDR_T long

Expand Down
3 changes: 0 additions & 3 deletions mach/i86/as/mach0.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
#define RELOCATION /* generate relocation info */
#define DEBUG 0

#undef valu_t
#define valu_t long

#undef ALIGNWORD
#define ALIGNWORD 2
#undef ALIGNSECT
Expand Down
2 changes: 0 additions & 2 deletions mach/m68020/as/mach0.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#define RELOCATION /* generate relocatable code */
#define DEBUG 0

#undef valu_t
#define valu_t long
#undef ADDR_T
#define ADDR_T long

Expand Down
2 changes: 0 additions & 2 deletions mach/m68k2/as/mach0.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

#define Xfit(f) if (!(f)) Xnofit();

#undef valu_t
#define valu_t long
#undef ADDR_T
#define ADDR_T long

Expand Down
3 changes: 0 additions & 3 deletions mach/mips/as/mach0.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
#define RELOCATION /* generate relocatable code */
#define DEBUG 0

#undef valu_t
#define valu_t int32_t

#undef ADDR_T
#define ADDR_T uint32_t

Expand Down
2 changes: 0 additions & 2 deletions mach/ns/as/mach0.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#define THREE_PASS /* branch and offset optimization */
#define LISTING /* enable listing facilities */

#undef valu_t
#define valu_t long
#undef ADDR_T
#define ADDR_T long
#undef ALIGNSECT
Expand Down
3 changes: 0 additions & 3 deletions mach/powerpc/as/mach0.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
#define RELOCATION /* generate relocatable code */
#define DEBUG 0

#undef valu_t
#define valu_t int32_t

#undef ADDR_T
#define ADDR_T uint32_t

Expand Down
3 changes: 2 additions & 1 deletion mach/proto/as/comm0.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ _include <string.h>

#define GENLAB "I" /* compiler generated labels */

#define valu_t long /* type of expression values */
#define valu_t int64_t /* type of expression values */
#define uvalu_t uint64_t /* unsigned valu_t */
#define ADDR_T unsigned short /* type of dot */
#define word_t short /* type of keyword value */
/*
Expand Down
15 changes: 3 additions & 12 deletions mach/proto/as/comm2.y
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ static item_t *last_it, *o_it;
%union {
word_t y_word;
valu_t y_valu;
int64_t y_valu8;
expr_t y_expr;
item_t *y_item;
#ifdef ASLD
Expand All @@ -44,7 +43,7 @@ static item_t *last_it, *o_it;
%token NUMBER2
%token NUMBER3
%token NUMBER4
%token <y_valu8> NUMBER8
%token <y_valu> NUMBER8
%token NUMBERF
%token DOT
%token EXTERN
Expand Down Expand Up @@ -77,7 +76,6 @@ static item_t *last_it, *o_it;
%nonassoc '~'

%type <y_valu> absexp optabs1 optabs2
%type <y_valu8> datum8
%type <y_expr> expr
%type <y_item> id_fb

Expand Down Expand Up @@ -285,17 +283,10 @@ datalist
}
;

/* datum8 isn't expr, because int64_t may be wider than valu_t. */
datum8 : NUMBER8
{ $$ = $1;}
| '-' NUMBER8
{ $$ = -$2;}
;

data8list
: datum8
: absexp
{ emit8($1);}
| data8list ',' datum8
| data8list ',' absexp
{ emit8($3);}
;

Expand Down
13 changes: 5 additions & 8 deletions mach/proto/as/comm5.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void putval(int c)
v = yylval.y_valu;
goto putnum;
case NUMBER8:
v = yylval.y_valu8;
v = yylval.y_valu;
for (n = 0; n < sizeof(v); n++)
{
if (v == 0)
Expand All @@ -132,7 +132,7 @@ void putval(int c)
c = NUMBER0 + n;
else
n = 8;
v = yylval.y_valu8;
v = yylval.y_valu;
putnum:
putc(c, tempfile);
putc(c >> 8, tempfile);
Expand Down Expand Up @@ -236,10 +236,7 @@ int getval(int c)
v <<= 8;
v |= getc(tempfile);
}
if (c == NUMBER8)
yylval.y_valu8 = v;
else
yylval.y_valu = v;
yylval.y_valu = v;
return (c);
case IDENT:
case FBSYM:
Expand Down Expand Up @@ -421,7 +418,7 @@ static void need_stringbuf()

static int innumber(int c)
{
uint64_t uv;
uvalu_t uv;
char* p;
int radix;
static char num[40 + 1];
Expand Down Expand Up @@ -473,7 +470,7 @@ static int innumber(int c)
serror("digit exceeds radix");
uv = uv * radix + c;
}
yylval.y_valu8 = uv; /* signed = unsigned */
yylval.y_valu = uv; /* signed = unsigned */
return (NUMBER8);

floatconstant:
Expand Down
2 changes: 0 additions & 2 deletions mach/vax4/as/mach0.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#define LISTING
#define RELOCATION

#undef valu_t
#define valu_t long
#undef word_t
#define word_t long
#undef ADDR_T
Expand Down
3 changes: 0 additions & 3 deletions mach/vc4/as/mach0.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
#define RELOCATION /* generate relocatable code */
#define DEBUG 0

#undef valu_t
#define valu_t long

#undef ADDR_T
#define ADDR_T long

Expand Down
2 changes: 0 additions & 2 deletions mach/z8000/as/mach0.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
#define ASLD
#undef ALIGNSECT
#define ALIGNSECT 2
#undef valu_t
#define valu_t long
#undef ADDR_T
#define ADDR_T long
11 changes: 4 additions & 7 deletions man/uni_ass.6
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,8 @@ if the number starts with '0x' it is hexadecimal else
if the number starts with '0' it is octal else
it's decimal.
.fi
The range of numbers depends on the machine.
A rule of the thumb is that the width of the machine's registers
the same is as the number of bits allowed in numbers.
The width of numbers is at least 64 bits, so the .data8 pseudo may
accept the full range of 8-byte values.
.IP comment
The character '!' denotes the start of comment, every character
up to the next newline is skipped.
Expand Down Expand Up @@ -206,11 +205,9 @@ This is not followed by automatic alignment.
.Pu ".data4 \fIexpression\fP [, \fIexpression\fP]*"
Initialize a sequence of longs (4-byte values).
This is not followed by automatic alignment.
.Pu ".data8 \fIliteralint\fP [, \fIliteralint\fP]*"
.Pu ".data8 \fIexpression\fP [, \fIexpression\fP]*"
Initialize a sequence of long longs (8-byte values).
This accepts only literal integers, not symbols nor expressions; but
a \fIliteralint\fP may be any signed or unsigned 8-byte integer, even
if it is outside the usual range for the machine.
The expressions must be absolute.
This is not followed by automatic alignment.
.Pu ".dataf4 \fIliteralfloat\fP [, \fIliteralfloat\fP]*"
Initialize a sequence of floats (4-byte values).
Expand Down

0 comments on commit a434749

Please sign in to comment.