Widen valu_t in the assembler to 64 bits.

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.
This commit is contained in:
George Koehler 2019-10-04 18:58:56 -04:00
parent 0b0c3d5b60
commit a434749fd9
15 changed files with 14 additions and 55 deletions

View file

@ -8,9 +8,6 @@
#define WORDS_REVERSED #define WORDS_REVERSED
#define BYTES_REVERSED #define BYTES_REVERSED
*/ */
#undef valu_t
#define valu_t long
#undef ADDR_T #undef ADDR_T
#define ADDR_T long #define ADDR_T long

View file

@ -11,8 +11,6 @@
#define LISTING /* enable listing facilities */ #define LISTING /* enable listing facilities */
#define RELOCATION /* generate relocation info */ #define RELOCATION /* generate relocation info */
#undef valu_t
#define valu_t long
#undef ADDR_T #undef ADDR_T
#define ADDR_T long #define ADDR_T long

View file

@ -12,9 +12,6 @@
#define RELOCATION /* generate relocation info */ #define RELOCATION /* generate relocation info */
#define DEBUG 0 #define DEBUG 0
#undef valu_t
#define valu_t long
#undef ALIGNWORD #undef ALIGNWORD
#define ALIGNWORD 2 #define ALIGNWORD 2
#undef ALIGNSECT #undef ALIGNSECT

View file

@ -14,8 +14,6 @@
#define RELOCATION /* generate relocatable code */ #define RELOCATION /* generate relocatable code */
#define DEBUG 0 #define DEBUG 0
#undef valu_t
#define valu_t long
#undef ADDR_T #undef ADDR_T
#define ADDR_T long #define ADDR_T long

View file

@ -17,8 +17,6 @@
#define Xfit(f) if (!(f)) Xnofit(); #define Xfit(f) if (!(f)) Xnofit();
#undef valu_t
#define valu_t long
#undef ADDR_T #undef ADDR_T
#define ADDR_T long #define ADDR_T long

View file

@ -8,9 +8,6 @@
#define RELOCATION /* generate relocatable code */ #define RELOCATION /* generate relocatable code */
#define DEBUG 0 #define DEBUG 0
#undef valu_t
#define valu_t int32_t
#undef ADDR_T #undef ADDR_T
#define ADDR_T uint32_t #define ADDR_T uint32_t

View file

@ -10,8 +10,6 @@
#define THREE_PASS /* branch and offset optimization */ #define THREE_PASS /* branch and offset optimization */
#define LISTING /* enable listing facilities */ #define LISTING /* enable listing facilities */
#undef valu_t
#define valu_t long
#undef ADDR_T #undef ADDR_T
#define ADDR_T long #define ADDR_T long
#undef ALIGNSECT #undef ALIGNSECT

View file

@ -10,9 +10,6 @@
#define RELOCATION /* generate relocatable code */ #define RELOCATION /* generate relocatable code */
#define DEBUG 0 #define DEBUG 0
#undef valu_t
#define valu_t int32_t
#undef ADDR_T #undef ADDR_T
#define ADDR_T uint32_t #define ADDR_T uint32_t

View file

@ -58,7 +58,8 @@ _include <string.h>
#define GENLAB "I" /* compiler generated labels */ #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 ADDR_T unsigned short /* type of dot */
#define word_t short /* type of keyword value */ #define word_t short /* type of keyword value */
/* /*

View file

@ -22,7 +22,6 @@ static item_t *last_it, *o_it;
%union { %union {
word_t y_word; word_t y_word;
valu_t y_valu; valu_t y_valu;
int64_t y_valu8;
expr_t y_expr; expr_t y_expr;
item_t *y_item; item_t *y_item;
#ifdef ASLD #ifdef ASLD
@ -44,7 +43,7 @@ static item_t *last_it, *o_it;
%token NUMBER2 %token NUMBER2
%token NUMBER3 %token NUMBER3
%token NUMBER4 %token NUMBER4
%token <y_valu8> NUMBER8 %token <y_valu> NUMBER8
%token NUMBERF %token NUMBERF
%token DOT %token DOT
%token EXTERN %token EXTERN
@ -77,7 +76,6 @@ static item_t *last_it, *o_it;
%nonassoc '~' %nonassoc '~'
%type <y_valu> absexp optabs1 optabs2 %type <y_valu> absexp optabs1 optabs2
%type <y_valu8> datum8
%type <y_expr> expr %type <y_expr> expr
%type <y_item> id_fb %type <y_item> id_fb
@ -285,17 +283,10 @@ datalist
} }
; ;
/* datum8 isn't expr, because int64_t may be wider than valu_t. */
datum8 : NUMBER8
{ $$ = $1;}
| '-' NUMBER8
{ $$ = -$2;}
;
data8list data8list
: datum8 : absexp
{ emit8($1);} { emit8($1);}
| data8list ',' datum8 | data8list ',' absexp
{ emit8($3);} { emit8($3);}
; ;

View file

@ -121,7 +121,7 @@ void putval(int c)
v = yylval.y_valu; v = yylval.y_valu;
goto putnum; goto putnum;
case NUMBER8: case NUMBER8:
v = yylval.y_valu8; v = yylval.y_valu;
for (n = 0; n < sizeof(v); n++) for (n = 0; n < sizeof(v); n++)
{ {
if (v == 0) if (v == 0)
@ -132,7 +132,7 @@ void putval(int c)
c = NUMBER0 + n; c = NUMBER0 + n;
else else
n = 8; n = 8;
v = yylval.y_valu8; v = yylval.y_valu;
putnum: putnum:
putc(c, tempfile); putc(c, tempfile);
putc(c >> 8, tempfile); putc(c >> 8, tempfile);
@ -236,10 +236,7 @@ int getval(int c)
v <<= 8; v <<= 8;
v |= getc(tempfile); v |= getc(tempfile);
} }
if (c == NUMBER8) yylval.y_valu = v;
yylval.y_valu8 = v;
else
yylval.y_valu = v;
return (c); return (c);
case IDENT: case IDENT:
case FBSYM: case FBSYM:
@ -421,7 +418,7 @@ static void need_stringbuf()
static int innumber(int c) static int innumber(int c)
{ {
uint64_t uv; uvalu_t uv;
char* p; char* p;
int radix; int radix;
static char num[40 + 1]; static char num[40 + 1];
@ -473,7 +470,7 @@ static int innumber(int c)
serror("digit exceeds radix"); serror("digit exceeds radix");
uv = uv * radix + c; uv = uv * radix + c;
} }
yylval.y_valu8 = uv; /* signed = unsigned */ yylval.y_valu = uv; /* signed = unsigned */
return (NUMBER8); return (NUMBER8);
floatconstant: floatconstant:

View file

@ -12,8 +12,6 @@
#define LISTING #define LISTING
#define RELOCATION #define RELOCATION
#undef valu_t
#define valu_t long
#undef word_t #undef word_t
#define word_t long #define word_t long
#undef ADDR_T #undef ADDR_T

View file

@ -10,9 +10,6 @@
#define RELOCATION /* generate relocatable code */ #define RELOCATION /* generate relocatable code */
#define DEBUG 0 #define DEBUG 0
#undef valu_t
#define valu_t long
#undef ADDR_T #undef ADDR_T
#define ADDR_T long #define ADDR_T long

View file

@ -14,7 +14,5 @@
#define ASLD #define ASLD
#undef ALIGNSECT #undef ALIGNSECT
#define ALIGNSECT 2 #define ALIGNSECT 2
#undef valu_t
#define valu_t long
#undef ADDR_T #undef ADDR_T
#define ADDR_T long #define ADDR_T long

View file

@ -154,9 +154,8 @@ if the number starts with '0x' it is hexadecimal else
if the number starts with '0' it is octal else if the number starts with '0' it is octal else
it's decimal. it's decimal.
.fi .fi
The range of numbers depends on the machine. The width of numbers is at least 64 bits, so the .data8 pseudo may
A rule of the thumb is that the width of the machine's registers accept the full range of 8-byte values.
the same is as the number of bits allowed in numbers.
.IP comment .IP comment
The character '!' denotes the start of comment, every character The character '!' denotes the start of comment, every character
up to the next newline is skipped. up to the next newline is skipped.
@ -206,11 +205,9 @@ This is not followed by automatic alignment.
.Pu ".data4 \fIexpression\fP [, \fIexpression\fP]*" .Pu ".data4 \fIexpression\fP [, \fIexpression\fP]*"
Initialize a sequence of longs (4-byte values). Initialize a sequence of longs (4-byte values).
This is not followed by automatic alignment. 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). Initialize a sequence of long longs (8-byte values).
This accepts only literal integers, not symbols nor expressions; but The expressions must be absolute.
a \fIliteralint\fP may be any signed or unsigned 8-byte integer, even
if it is outside the usual range for the machine.
This is not followed by automatic alignment. This is not followed by automatic alignment.
.Pu ".dataf4 \fIliteralfloat\fP [, \fIliteralfloat\fP]*" .Pu ".dataf4 \fIliteralfloat\fP [, \fIliteralfloat\fP]*"
Initialize a sequence of floats (4-byte values). Initialize a sequence of floats (4-byte values).