From a434749fd958d100ee9106e1e0920db71ca6b636 Mon Sep 17 00:00:00 2001 From: George Koehler Date: Fri, 4 Oct 2019 18:58:56 -0400 Subject: [PATCH] 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. --- mach/arm/as/mach0.c | 3 --- mach/i386/as/mach0.c | 2 -- mach/i86/as/mach0.c | 3 --- mach/m68020/as/mach0.c | 2 -- mach/m68k2/as/mach0.c | 2 -- mach/mips/as/mach0.c | 3 --- mach/ns/as/mach0.c | 2 -- mach/powerpc/as/mach0.c | 3 --- mach/proto/as/comm0.h | 3 ++- mach/proto/as/comm2.y | 15 +++------------ mach/proto/as/comm5.c | 13 +++++-------- mach/vax4/as/mach0.c | 2 -- mach/vc4/as/mach0.c | 3 --- mach/z8000/as/mach0.c | 2 -- man/uni_ass.6 | 11 ++++------- 15 files changed, 14 insertions(+), 55 deletions(-) diff --git a/mach/arm/as/mach0.c b/mach/arm/as/mach0.c index 855541a15..1853f8de4 100644 --- a/mach/arm/as/mach0.c +++ b/mach/arm/as/mach0.c @@ -8,9 +8,6 @@ #define WORDS_REVERSED #define BYTES_REVERSED */ -#undef valu_t -#define valu_t long - #undef ADDR_T #define ADDR_T long diff --git a/mach/i386/as/mach0.c b/mach/i386/as/mach0.c index 6fb5358d5..63f719565 100644 --- a/mach/i386/as/mach0.c +++ b/mach/i386/as/mach0.c @@ -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 diff --git a/mach/i86/as/mach0.c b/mach/i86/as/mach0.c index 1c47e4874..fc69730c9 100644 --- a/mach/i86/as/mach0.c +++ b/mach/i86/as/mach0.c @@ -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 diff --git a/mach/m68020/as/mach0.c b/mach/m68020/as/mach0.c index 498620c0e..8e79b89a6 100644 --- a/mach/m68020/as/mach0.c +++ b/mach/m68020/as/mach0.c @@ -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 diff --git a/mach/m68k2/as/mach0.c b/mach/m68k2/as/mach0.c index 72845b0be..62878f7dc 100644 --- a/mach/m68k2/as/mach0.c +++ b/mach/m68k2/as/mach0.c @@ -17,8 +17,6 @@ #define Xfit(f) if (!(f)) Xnofit(); -#undef valu_t -#define valu_t long #undef ADDR_T #define ADDR_T long diff --git a/mach/mips/as/mach0.c b/mach/mips/as/mach0.c index edce6640b..8aef3d697 100644 --- a/mach/mips/as/mach0.c +++ b/mach/mips/as/mach0.c @@ -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 diff --git a/mach/ns/as/mach0.c b/mach/ns/as/mach0.c index e4ba505ae..218f7c76e 100644 --- a/mach/ns/as/mach0.c +++ b/mach/ns/as/mach0.c @@ -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 diff --git a/mach/powerpc/as/mach0.c b/mach/powerpc/as/mach0.c index 1c2051753..b6eec8f2d 100644 --- a/mach/powerpc/as/mach0.c +++ b/mach/powerpc/as/mach0.c @@ -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 diff --git a/mach/proto/as/comm0.h b/mach/proto/as/comm0.h index 03b48f75e..5ef226be6 100644 --- a/mach/proto/as/comm0.h +++ b/mach/proto/as/comm0.h @@ -58,7 +58,8 @@ _include #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 */ /* diff --git a/mach/proto/as/comm2.y b/mach/proto/as/comm2.y index 1e28979fa..83d74f5fc 100644 --- a/mach/proto/as/comm2.y +++ b/mach/proto/as/comm2.y @@ -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 @@ -44,7 +43,7 @@ static item_t *last_it, *o_it; %token NUMBER2 %token NUMBER3 %token NUMBER4 -%token NUMBER8 +%token NUMBER8 %token NUMBERF %token DOT %token EXTERN @@ -77,7 +76,6 @@ static item_t *last_it, *o_it; %nonassoc '~' %type absexp optabs1 optabs2 -%type datum8 %type expr %type 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 - : datum8 + : absexp { emit8($1);} - | data8list ',' datum8 + | data8list ',' absexp { emit8($3);} ; diff --git a/mach/proto/as/comm5.c b/mach/proto/as/comm5.c index 2987aedb2..ee877120c 100644 --- a/mach/proto/as/comm5.c +++ b/mach/proto/as/comm5.c @@ -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) @@ -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); @@ -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: @@ -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]; @@ -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: diff --git a/mach/vax4/as/mach0.c b/mach/vax4/as/mach0.c index 531de3a15..97f8ca93f 100644 --- a/mach/vax4/as/mach0.c +++ b/mach/vax4/as/mach0.c @@ -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 diff --git a/mach/vc4/as/mach0.c b/mach/vc4/as/mach0.c index 2df70061c..0e92645ea 100644 --- a/mach/vc4/as/mach0.c +++ b/mach/vc4/as/mach0.c @@ -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 diff --git a/mach/z8000/as/mach0.c b/mach/z8000/as/mach0.c index 15b97913b..c731d5a50 100644 --- a/mach/z8000/as/mach0.c +++ b/mach/z8000/as/mach0.c @@ -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 diff --git a/man/uni_ass.6 b/man/uni_ass.6 index 558fae2de..572ec0ff1 100644 --- a/man/uni_ass.6 +++ b/man/uni_ass.6 @@ -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. @@ -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).