]> Shamusworld >> Repos - rmac/commitdiff
Fix for section alignment values in ELF objects.
authorShamus Hammons <jlhamm@acm.org>
Tue, 29 Aug 2017 17:20:17 +0000 (12:20 -0500)
committerShamus Hammons <jlhamm@acm.org>
Tue, 29 Aug 2017 17:20:17 +0000 (12:20 -0500)
Thanks to SainT for the patch. :-)

22 files changed:
6502.c
amode.c
amode.h
direct.c
direct.h
eagen0.c
expr.c
expr.h
listing.c
listing.h
mach.c
macro.c
object.c
procln.c
procln.h
riscasm.c
rmac.c
rmac.h
sect.c
token.c
token.h
version.h

diff --git a/6502.c b/6502.c
index 24000c20f50b01bba97e3e0434e4276f8276b17f..f7078b8e5a9bb3f90bb43fcb8139b31ea8a0c4e4 100644 (file)
--- a/6502.c
+++ b/6502.c
@@ -247,7 +247,7 @@ void m6502cg(int op)
 {
        register int amode;             // (Parsed) addressing mode
        register int i;
-       VALUE eval;                             // Expression value
+       uint32_t eval;                  // Expression value
        WORD eattr;                             // Expression attributes
        int zpreq;                              // 1, optimize instr to zero-page form
        register char * p;              // (Temp) string usage
diff --git a/amode.c b/amode.c
index 56814123d8d50a3073dfb43fd9ff348e63d3407f..3d789af93cb3f258a12d4370e18f3a22d0678cf8 100644 (file)
--- a/amode.c
+++ b/amode.c
@@ -27,16 +27,16 @@ int nmodes;                                 // Number of addr'ing modes found
 int am0;                                       // Addressing mode
 int a0reg;                                     // Register
 TOKEN a0expr[EXPRSIZE];                // Expression
-VALUE a0exval;                         // Expression's value
+uint32_t a0exval;                              // Expression's value
 WORD a0exattr;                         // Expression's attribute
 int a0ixreg;                           // Index register
 int a0ixsiz;                           // Index register size (and scale)
 TOKEN a0oexpr[EXPRSIZE];       // Outer displacement expression
-VALUE a0oexval;                                // Outer displacement value
+uint32_t a0oexval;                             // Outer displacement value
 WORD a0oexattr;                                // Outer displacement attribute
 SYM * a0esym;                          // External symbol involved in expr
 TOKEN a0bexpr[EXPRSIZE];       // Base displacement expression
-VALUE a0bexval;                                // Base displacement value
+uint32_t a0bexval;                             // Base displacement value
 WORD a0bexattr;                                // Base displacement attribute
 WORD a0bsize;                          // Base displacement size
 WORD a0extension;                      // 020+ extension address word
@@ -45,16 +45,16 @@ WORD am0_030;                               // ea bits for 020+ addressing modes
 int am1;                                       // Addressing mode
 int a1reg;                                     // Register
 TOKEN a1expr[EXPRSIZE];                // Expression
-VALUE a1exval;                         // Expression's value
+uint32_t a1exval;                              // Expression's value
 WORD a1exattr;                         // Expression's attribute
 int a1ixreg;                           // Index register
 int a1ixsiz;                           // Index register size (and scale)
 TOKEN a1oexpr[EXPRSIZE];       // Outer displacement expression
-VALUE a1oexval;                                // Outer displacement value
+uint32_t a1oexval;                             // Outer displacement value
 WORD a1oexattr;                                // Outer displacement attribute
 SYM * a1esym;                          // External symbol involved in expr
 TOKEN a1bexpr[EXPRSIZE];       // Base displacement expression
-VALUE a1bexval;                                // Base displacement value
+uint32_t a1bexval;                             // Base displacement value
 WORD a1bexattr;                                // Base displacement attribute
 WORD a1bsize;                          // Base displacement size
 WORD a1extension;                      // 020+ extension address word
@@ -68,7 +68,7 @@ int bfparam2;                         // bfxxx / fmove instruction parameter 2
 int bfval1;                                    //bfxxx / fmove value 1
 int bfval2;                                    //bfxxx / fmove value 2
 TOKEN bf0expr[EXPRSIZE];       // Expression
-VALUE bf0exval;                                // Expression's value
+uint32_t bf0exval;                             // Expression's value
 WORD bf0exattr;                                // Expression's attribute
 SYM * bf0esym;                         // External symbol involved in expr
 
diff --git a/amode.h b/amode.h
index ae93cfa95614cc381a59b16bc0d4d155cb3fbf3b..f1a47a8c307a9216fd50194e43ae1174868112fd 100644 (file)
--- a/amode.h
+++ b/amode.h
@@ -137,15 +137,15 @@ extern int nmodes;
 extern int am0, am1;
 extern int a0reg, a1reg, a2reg;
 extern TOKEN a0expr[], a1expr[];
-extern VALUE a0exval, a1exval;
+extern uint32_t a0exval, a1exval;
 extern WORD a0exattr, a1exattr;
 extern int a0ixreg, a1ixreg;
 extern int a0ixsiz, a1ixsiz;
 extern TOKEN a0oexpr[], a1oexpr[];
-extern VALUE a0oexval, a1oexval;
+extern uint32_t a0oexval, a1oexval;
 extern WORD a0oexattr, a1oexattr;
 extern SYM * a0esym, * a1esym;
-extern VALUE a0bexval, a1bexval;
+extern uint32_t a0bexval, a1bexval;
 extern WORD a0bexattr, a1bexattr;
 extern WORD a0bsize, a1bsize;
 extern TOKEN a0bexpr[], a1bexpr[];
@@ -155,7 +155,7 @@ extern int bfparam1;
 extern int bfparam2;
 extern int bfval1;
 extern int bfval2;
-extern VALUE bf0exval;
+extern uint32_t bf0exval;
 
 // mnattr:
 #define CGSPECIAL    0x8000                    // Special (don't parse addr modes)
index c9a82d938714730471728f4868820e47ace156c0..54c09d694118c1de435a8097956e0478cc08f34c 100644 (file)
--- a/direct.c
+++ b/direct.c
@@ -28,6 +28,7 @@ TOKEN exprbuf[128];                   // Expression buffer
 SYM * symbolPtr[1000000];      // Symbol pointers table
 static long unused;                    // For supressing 'write' warnings
 char buffer[256];                      // Scratch buffer for messages
+int largestAlign[3] = { 2, 2, 2 };     // Largest alignment value seen per section
 
 // Function prototypes
 int d_unimpl(void);
@@ -77,6 +78,7 @@ int d_cstruct(void);
 int d_prgflags(void);
 int d_opt(void);
 int d_dsp(void);
+void SetLargestAlignment(int);
 
 // Directive handler table
 int (*dirtab[])() = {
@@ -150,6 +152,20 @@ int (*dirtab[])() = {
 };
 
 
+//
+// Set the largest alignment seen in the current section
+//
+void SetLargestAlignment(int size)
+{
+       if ((scattr & TEXT) && (largestAlign[0] < size))
+               largestAlign[0] = size;
+       else if ((scattr & DATA) && (largestAlign[1] < size))
+               largestAlign[1] = size;
+       else if ((scattr & BSS) && (largestAlign[2] < size))
+               largestAlign[2] = size;
+}
+
+
 //
 // .error - Abort compilation, printing an error message
 //
@@ -197,7 +213,7 @@ int d_warn(char *str)
 //
 int d_org(void)
 {
-       VALUE address;
+       uint32_t address;
 
        if (!rgpu && !rdsp && !m6502)
                return error(".org permitted only in gpu/dsp and 6502 sections");
@@ -250,7 +266,7 @@ int d_print(void)
        int wordlong = 0;                       // WORD = 0, LONG = 1
        int outtype = 0;                        // 0:hex, 1:decimal, 2:unsigned
 
-       VALUE eval;                                     // Expression value
+       uint32_t eval;                                  // Expression value
        WORD eattr;                                     // Expression attributes
        SYM * esym;                                     // External symbol involved in expr.
        TOKEN r_expr[EXPRSIZE];
@@ -577,6 +593,7 @@ int d_long(void)
        unsigned lower2Bits = (rgpu || rdsp ? orgaddr : sloc) & 0x03;
        unsigned bytesToSkip = (0x04 - lower2Bits) & 0x03;
        SkipBytes(bytesToSkip);
+       SetLargestAlignment(4);
 
        return 0;
 }
@@ -599,6 +616,7 @@ int d_phrase(void)
        unsigned lower3Bits = (rgpu || rdsp ? orgaddr : sloc) & 0x07;
        unsigned bytesToSkip = (0x08 - lower3Bits) & 0x07;
        SkipBytes(bytesToSkip);
+       SetLargestAlignment(8);
 
        return 0;
 }
@@ -612,6 +630,7 @@ int d_dphrase(void)
        unsigned lower4Bits = (rgpu || rdsp ? orgaddr : sloc) & 0x0F;
        unsigned bytesToSkip = (0x10 - lower4Bits) & 0x0F;
        SkipBytes(bytesToSkip);
+       SetLargestAlignment(16);
 
        return 0;
 }
@@ -625,6 +644,7 @@ int d_qphrase(void)
        unsigned lower5Bits = (rgpu || rdsp ? orgaddr : sloc) & 0x1F;
        unsigned bytesToSkip = (0x20 - lower5Bits) & 0x1F;
        SkipBytes(bytesToSkip);
+       SetLargestAlignment(32);
 
        return 0;
 }
@@ -667,7 +687,7 @@ int d_unimpl(void)
 //
 // Return absolute (not TDB) and defined expression or return an error
 //
-int abs_expr(VALUE * a_eval)
+int abs_expr(uint32_t * a_eval)
 {
        WORD eattr;
 
@@ -775,7 +795,7 @@ allright:
 int d_assert(void)
 {
        WORD eattr;
-       VALUE eval;
+       uint32_t eval;
 
        for(; expr(exprbuf, &eval, &eattr, NULL)==OK; ++tok)
        {
@@ -833,7 +853,7 @@ int d_globl(void)
 //
 int d_prgflags(void)
 {
-       VALUE eval;
+       uint32_t eval;
 
        if (*tok == EOL)
                return error("PRGFLAGS requires value");
@@ -854,7 +874,7 @@ int d_prgflags(void)
 //
 int d_abs(void)
 {
-       VALUE eval;
+       uint32_t eval;
 
        if (m6502)
                return error(in_6502mode);
@@ -933,7 +953,7 @@ int d_ds(WORD siz)
 {
        DEBUG { printf("Directive: .ds.[size] = %u, sloc = $%X\n", siz, sloc); }
 
-       VALUE eval;
+       uint32_t eval;
 
        if (cursect != M6502)
        {
@@ -946,7 +966,7 @@ int d_ds(WORD siz)
 
        // Check to see if the value being passed in is negative (who the hell does
        // that?--nobody does; it's the code gremlins, or rum, that does it)
-       // N.B.: Since VALUE is of type uint32_t, if it goes negative, it will have
+       // N.B.: Since 'eval' is of type uint32_t, if it goes negative, it will have
        //       its high bit set.
        if (eval & 0x80000000)
                return error("negative sizes not allowed");
@@ -967,7 +987,7 @@ int d_ds(WORD siz)
        }
        else
        {
-               dep_block(eval, siz, (VALUE)0, (WORD)(DEFINED | ABS), NULL);
+               dep_block(eval, siz, 0, (WORD)(DEFINED | ABS), NULL);
        }
 
        at_eol();
@@ -981,7 +1001,7 @@ int d_ds(WORD siz)
 int d_dc(WORD siz)
 {
        WORD eattr;
-       VALUE eval;
+       uint32_t eval;
        uint8_t * p;
 
        if ((scattr & SBSS) != 0)
@@ -1132,7 +1152,7 @@ comma:
 //
 int d_dcb(WORD siz)
 {
-       VALUE evalc, eval;
+       uint32_t evalc, eval;
        WORD eattr;
 
        DEBUG { printf("dcb: section is %s%s%s (scattr=$%X)\n", (cursect & TEXT ? "TEXT" : ""), (cursect & DATA ? " DATA" : ""), (cursect & BSS ? "BSS" : ""), scattr); }
@@ -1169,8 +1189,8 @@ int d_dcb(WORD siz)
 //
 int d_init(WORD def_siz)
 {
-       VALUE count;
-       VALUE eval;
+       uint32_t count;
+       uint32_t eval;
        WORD eattr;
        WORD siz;
 
@@ -1230,7 +1250,7 @@ int d_init(WORD def_siz)
 //
 // Deposit 'count' values of size 'siz' in the current (non-BSS) segment
 //
-int dep_block(VALUE count, WORD siz, VALUE eval, WORD eattr, TOKEN * exprbuf)
+int dep_block(uint32_t count, WORD siz, uint32_t eval, WORD eattr, TOKEN * exprbuf)
 {
        WORD tdb;
        WORD defined;
@@ -1319,7 +1339,7 @@ int d_comm(void)
 {
        SYM * sym;
        char * p;
-       VALUE eval;
+       uint32_t eval;
 
        if (m6502)
                return error(in_6502mode);
@@ -1546,7 +1566,7 @@ int d_dsp(void)
 //
 int d_cargs(void)
 {
-       VALUE eval = 4;         // Default to 4 if no offset specified (to account for
+       uint32_t eval = 4;              // Default to 4 if no offset specified (to account for
                                                // return address)
        WORD rlist;
        SYM * symbol;
@@ -1661,7 +1681,7 @@ int d_cargs(void)
 //
 int d_cstruct(void)
 {
-       VALUE eval = 0;         // Default, if no offset specified, is zero
+       uint32_t eval = 0;              // Default, if no offset specified, is zero
        WORD rlist;
        SYM * symbol;
        char * symbolName;
@@ -1850,7 +1870,7 @@ int d_opt(void)
 int d_if(void)
 {
        WORD eattr;
-       VALUE eval;
+       uint32_t eval;
        SYM * esym;
        IFENT * rif = f_ifent;
 
index 654c580bf1ff0542db14f65466228e6ce0885a5f..0f9615edd0ea8092a3b7a99028833f20df438b3c 100644 (file)
--- a/direct.h
+++ b/direct.h
 extern TOKEN exprbuf[];
 extern SYM * symbolPtr[];
 extern int (* dirtab[])();
+extern int largestAlign[];
 
 // Exported functions
 void auto_even(void);
-int dep_block(VALUE, WORD, VALUE, WORD, TOKEN *);
+int dep_block(uint32_t, WORD, uint32_t, WORD, TOKEN *);
 int eject(void);
-int abs_expr(VALUE *);
+int abs_expr(uint32_t *);
 int symlist(int(*)());
 
 int d_even(void);
index 1bb00ba7c6a372798f81625dccf24251cfedb49c..9293a9f7e1d2eba64a52527cb108136e1cbe6546 100644 (file)
--- a/eagen0.c
+++ b/eagen0.c
@@ -9,7 +9,7 @@
 
 int eaNgen(WORD siz)
 {
-       VALUE vbd, v = aNexval;
+       uint32_t vbd, v = aNexval;
        WORD wbd, w = (WORD)(aNexattr & DEFINED);
        WORD tdbbd, tdb = (WORD)(aNexattr & TDB);
        vbd = aNbdexval;
@@ -86,7 +86,7 @@ int eaNgen(WORD siz)
                {
                        // Just deposit it
                        if ((aNexattr & TDB) == cursect)
-                               v -= (VALUE)sloc;
+                               v -= (uint32_t)sloc;
                        else if ((aNexattr & TDB) != ABS)
                                error(rel_error);
 
@@ -136,7 +136,7 @@ int eaNgen(WORD siz)
                {
                        // Deposit a byte...
                        if ((aNexattr & TDB) == cursect)
-                               v -= (VALUE)sloc;
+                               v -= (uint32_t)sloc;
                        else if ((aNexattr & TDB) != ABS)
                                error(rel_error);
 
diff --git a/expr.c b/expr.c
index c89b1828b6f4f88acf1707b21f248a4b24ddcff5..8d18a67ec5ef9b4fddde0d28e9dd8f268d712abe 100644 (file)
--- a/expr.c
+++ b/expr.c
@@ -23,7 +23,7 @@
 // N.B.: The size of tokenClass should be identical to the largest value of
 //       a token; we're assuming 256 but not 100% sure!
 static char tokenClass[256];           // Generated table of token classes
-static VALUE evstk[EVSTACKSIZE];       // Evaluator value stack
+static uint32_t evstk[EVSTACKSIZE];    // Evaluator value stack
 static WORD evattr[EVSTACKSIZE];       // Evaluator attribute stack
 
 // Token-class initialization list
@@ -61,9 +61,9 @@ static int symbolNum;                         // Pointer to the entry in symbolPtr[]
 //
 // Obtain a string value
 //
-static VALUE str_value(char * p)
+static uint32_t str_value(char * p)
 {
-       VALUE v;
+       uint32_t v;
 
        for(v=0; *p; p++)
                v = (v << 8) | (*p & 0xFF);
@@ -313,7 +313,7 @@ int expr2(void)
 //
 // Recursive-descent expression analyzer (with some simple speed hacks)
 //
-int expr(TOKEN * otk, VALUE * a_value, WORD * a_attr, SYM ** a_esym)
+int expr(TOKEN * otk, uint32_t * a_value, WORD * a_attr, SYM ** a_esym)
 {
        // Passed in values (once derefenced, that is) can all be zero. They are
        // there so that the expression analyzer can fill them in as needed. The
@@ -476,11 +476,11 @@ thrown away right here. What the hell is it for?
 // UNDEFINED, but it's value includes everything but the symbol value, and
 // `a_esym' is set to the external symbol.
 //
-int evexpr(TOKEN * tk, VALUE * a_value, WORD * a_attr, SYM ** a_esym)
+int evexpr(TOKEN * tk, uint32_t * a_value, WORD * a_attr, SYM ** a_esym)
 {
        WORD attr;
        SYM * sy;
-       VALUE * sval = evstk;                                   // (Empty) initial stack
+       uint32_t * sval = evstk;                                // (Empty) initial stack
        WORD * sattr = evattr;
        SYM * esym = NULL;                                              // No external symbol involved
        WORD sym_seg = 0;
@@ -700,8 +700,8 @@ printf("EVEXPR (-): sym1 = %X, sym2 = %X\n", attr, sattr[1]);
                                // Compiler is picky here: Without casting these, it discards
                                // the sign if dividing a negative # by a positive one,
                                // creating a bad result. :-/
-                               // Probably a side effect of using VALUE intead of ints.
-                               *sval = (int)sval[0] / (int)sval[1];
+                               // Definitely a side effect of using uint32_ts intead of ints.
+                               *sval = (int32_t)sval[0] / (int32_t)sval[1];
 //printf("%i\n", *sval);
                                break;
                        case '%':
diff --git a/expr.h b/expr.h
index ee94dad45a99c73f1f996725ce087f05b0df09c2..190fbe468f5b6b985dae332247c7297290a26d52 100644 (file)
--- a/expr.h
+++ b/expr.h
@@ -34,7 +34,7 @@
 void InitExpression(void);
 int expr1(void);
 int expr2(void);
-int expr(TOKEN *, VALUE *, WORD *, SYM **);
-int evexpr(TOKEN *, VALUE *, WORD *, SYM **);
+int expr(TOKEN *, uint32_t *, WORD *, SYM **);
+int evexpr(TOKEN *, uint32_t *, WORD *, SYM **);
 
 #endif // __EXPR_H__
index f2c61f6325e6438e2611549457c48507e4a7c0d6..77226c7efe5be4c09c5143a05e527af17d3cd819 100644 (file)
--- a/listing.c
+++ b/listing.c
@@ -66,9 +66,9 @@ int eject(void)
 //
 // Return GEMDOS format date
 //
-VALUE dos_date(void)
+uint32_t dos_date(void)
 {
-       VALUE v;
+       uint32_t v;
        struct tm * tm;
        time_t tloc;
 
@@ -83,9 +83,9 @@ VALUE dos_date(void)
 //
 // Return GEMDOS format time
 //
-VALUE dos_time(void)
+uint32_t dos_time(void)
 {
-       VALUE v;
+       uint32_t v;
        struct tm * tm;
        time_t tloc;
 
@@ -100,7 +100,7 @@ VALUE dos_time(void)
 //
 // Generate a time string
 //
-void time_string(char * buf, VALUE time)
+void time_string(char * buf, uint32_t time)
 {
        int hour;
        char * ampm;
@@ -123,7 +123,7 @@ void time_string(char * buf, VALUE time)
 //
 // Generate a date string
 //
-void date_string(char * buf, VALUE date)
+void date_string(char * buf, uint32_t date)
 {
        sprintf(buf, "%d-%s-%d",
                (int)(date & 0x1F), month[(date >> 5) & 0xF], (int)((date >> 9) + 1980));
@@ -410,7 +410,7 @@ void lstout(char tag)
 //
 // Output a value to listing
 //
-int listvalue(VALUE v)
+int listvalue(uint32_t v)
 {
        sprintf(buf, "=%08X", v);
        strncpy(lnimage + DATA_COL - 1, buf, 9);
index 75be73d9d8b7a760a30492915a23e6252e8096c1..54cafb57054061c00e2f99b296bfaec1c5392e05 100644 (file)
--- a/listing.h
+++ b/listing.h
@@ -32,15 +32,15 @@ extern uint8_t subttl[];
 
 // Exported functions
 int eject(void);
-VALUE dos_date(void);
-VALUE dos_time(void);
+uint32_t dos_date(void);
+uint32_t dos_time(void);
 void taglist(char);
 void println(const char *);
 void ship_ln(const char *);
 void InitListing(void);
 void listeol(void);
 void lstout(char);
-int listvalue(VALUE);
+int listvalue(uint32_t);
 int d_subttl(void);
 int d_title(void);
 
diff --git a/mach.c b/mach.c
index c3f6d83e11d4c3ade2aa60540820a13e094b2be9..2da58ec74a9614918e2f723fb64eb2cb6eff4ed8 100644 (file)
--- a/mach.c
+++ b/mach.c
@@ -705,7 +705,7 @@ int m_bitop(WORD inst, WORD siz)
 
 int m_dbra(WORD inst, WORD siz)
 {
-       VALUE v;
+       uint32_t v;
 
        siz = siz;
        inst |= a0reg;
@@ -969,7 +969,7 @@ int m_movep(WORD inst, WORD siz)
 //
 int m_br(WORD inst, WORD siz)
 {
-       VALUE v;
+       uint32_t v;
 
        if (a0exattr & DEFINED)
        {
@@ -1105,7 +1105,7 @@ int m_trap(WORD inst, WORD siz)
 //
 int m_movem(WORD inst, WORD siz)
 {
-       VALUE eval;
+       uint32_t eval;
        WORD i;
        WORD w;
        WORD rmask;
@@ -1229,7 +1229,7 @@ int m_br30(WORD inst, WORD siz)
                if ((a0exattr & TDB) != cursect)
                        return error(rel_error);
 
-               VALUE v = a0exval - (sloc + 2);
+               uint32_t v = a0exval - (sloc + 2);
                D_word(inst);
                D_long(v);
 
@@ -1628,7 +1628,7 @@ int m_cpbr(WORD inst, WORD siz)
                if ((a0exattr & TDB) != cursect)
                        return error(rel_error);
 
-               VALUE v = a0exval - (sloc + 2);
+               uint32_t v = a0exval - (sloc + 2);
 
                // Optimize branch instr. size
                if (siz == SIZL)
@@ -1682,7 +1682,7 @@ int m_cpdbr(WORD inst, WORD siz)
 {
     CHECK00;
 
-    VALUE v;
+    uint32_t v;
     WORD condition = inst & 0x1f; // Grab condition sneakily placed in the lower 5 bits of inst
     inst &= 0xffe0;               // And then mask them out - you ain't seen me, roit?
 
@@ -2182,14 +2182,14 @@ int m_pack(WORD inst, WORD siz)
         return error(undef_error);
 
     if (a0exval + 0x8000 > 0x10000)
-        return error("");   
+        return error("");
 
     if (*tok != EOL)
         return error(extra_stuff);
 
     D_word((a0exval & 0xffff));
 
-        
+
 
     return OK;
 
@@ -2575,7 +2575,7 @@ int m_pflush(WORD inst, WORD siz)
             // hardcoded in 68ktab but there is aliasing
             // between 68030 and 68040 opcode. So we just
             // set the 3 lower bits to 1 in pflushn inside
-            // 68ktab and detect it here. 
+            // 68ktab and detect it here.
             inst = (inst & 0xff8) | 8;
         inst |= (tok[1] & 7) | (5 << 8);
         if (tok[3] != EOL)
@@ -2651,7 +2651,7 @@ int m_pload(WORD inst, WORD siz, WORD extension)
     // a 68020 + 68551 socket and since this is
     // an Atari targetted assembler....
     CHECKNO30;
-    
+
                inst |= am1;
 
     D_word(inst);
@@ -2684,7 +2684,7 @@ int m_pload(WORD inst, WORD siz, WORD extension)
     D_word(inst);
 
     ea1gen(siz);
-    
+
     return OK;
 }
 
@@ -3106,7 +3106,7 @@ int m_fdbcc(WORD inst, WORD siz)
                if ((a1exattr & TDB) != cursect)
                        return error(rel_error);
 
-               VALUE v = a1exval - sloc;
+               uint32_t v = a1exval - sloc;
 
                if ((v + 0x8000) > 0x10000)
                        return error(range_error);
diff --git a/macro.c b/macro.c
index 38dfecd80ae7fb573144d759c2cfdbebb8c2300a..469a88c6493e9c9f61f408d3f987ed3da0467951 100644 (file)
--- a/macro.c
+++ b/macro.c
@@ -22,7 +22,7 @@ int macnum;                                   // Unique number for macro definition
 
 static LONG macuniq;           // Unique-per-macro number
 static SYM * curmac;           // Macro currently being defined
-static VALUE argno;                    // Formal argument count
+static uint32_t argno;                 // Formal argument count
 
 static LLIST * firstrpt;       // First .rept line
 static LLIST * nextrpt;                // Last .rept line
@@ -244,7 +244,7 @@ WARNING("!!! Casting (char *) as LONG !!!")
 //
 int HandleRept(void)
 {
-       VALUE eval;
+       uint32_t eval;
 
        // Evaluate repeat expression
        if (abs_expr(&eval) != OK)
index bc3ae229b098035599c0e1518f1e6ad72cfbad75..522a4d918ce6bacc5d5b0bd0c3805a1867a3dd2c 100644 (file)
--- a/object.c
+++ b/object.c
@@ -8,6 +8,7 @@
 
 #include "object.h"
 #include "6502.h"
+#include "direct.h"
 #include "error.h"
 #include "mark.h"
 #include "riscasm.h"
@@ -520,7 +521,7 @@ int WriteObject(int fd)
                {
                        elfHdrNum[ES_TEXT] = shstIndex;
                        shstTab[ES_TEXT] = shstSize;
-                       shstSize += DepositELFSHSTEntry(&shstPtr, "TEXT");
+                       shstSize += DepositELFSHSTEntry(&shstPtr, ".text");
                        shstIndex++;
                        numEntries++;
                }
@@ -529,7 +530,7 @@ int WriteObject(int fd)
                {
                        elfHdrNum[ES_DATA] = shstIndex;
                        shstTab[ES_DATA] = shstSize;
-                       shstSize += DepositELFSHSTEntry(&shstPtr, "DATA");
+                       shstSize += DepositELFSHSTEntry(&shstPtr, ".data");
                        shstIndex++;
                        numEntries++;
                }
@@ -538,7 +539,7 @@ int WriteObject(int fd)
                {
                        elfHdrNum[ES_BSS] = shstIndex;
                        shstTab[ES_BSS] = shstSize;
-                       shstSize += DepositELFSHSTEntry(&shstPtr, "BSS");
+                       shstSize += DepositELFSHSTEntry(&shstPtr, ".bss");
                        shstIndex++;
                        numEntries++;
                }
@@ -619,7 +620,7 @@ for(int j=0; j<i; j++)
                // Construct TEXT section, if any
                if (sect[TEXT].sloc > 0)
                {
-                       headerSize += DepositELFSectionHeader(headers + headerSize, shstTab[ES_TEXT], 1, 6, 0, elfSize, sect[TEXT].sloc, 0, 0, 2, 0);
+                       headerSize += DepositELFSectionHeader(headers + headerSize, shstTab[ES_TEXT], 1, 6, 0, elfSize, sect[TEXT].sloc, 0, 0, largestAlign[0], 0);
 
                        for(CHUNK * cp=sect[TEXT].sfcode; cp!=NULL; cp=cp->chnext)
                        {
@@ -636,7 +637,7 @@ for(int j=0; j<i; j++)
                // Construct DATA section, if any
                if (sect[DATA].sloc > 0)
                {
-                       headerSize += DepositELFSectionHeader(headers + headerSize, shstTab[ES_DATA], 1, 3, 0, elfSize, sect[DATA].sloc, 0, 0, 1, 0);
+                       headerSize += DepositELFSectionHeader(headers + headerSize, shstTab[ES_DATA], 1, 3, 0, elfSize, sect[DATA].sloc, 0, 0, largestAlign[1], 0);
 
                        for(CHUNK * cp=sect[DATA].sfcode; cp!=NULL; cp=cp->chnext)
                        {
@@ -651,7 +652,7 @@ for(int j=0; j<i; j++)
                // Construct BSS section, if any
                if (sect[BSS].sloc > 0)
                {
-                       headerSize += DepositELFSectionHeader(headers + headerSize, shstTab[ES_BSS], 8, 3, 0, elfSize, sect[BSS].sloc, 0, 0, 2, 0);
+                       headerSize += DepositELFSectionHeader(headers + headerSize, shstTab[ES_BSS], 8, 3, 0, elfSize, sect[BSS].sloc, 0, 0, largestAlign[2], 0);
                }
 
                int textrelLoc = headerSize;
index 5b5e18a0e5edf159b5c063e87f2c1b5d502cb796..3a4aac8316d44c570373b675c6994cddfff00e76 100644 (file)
--- a/procln.c
+++ b/procln.c
@@ -39,7 +39,7 @@ static IFENT ifent0;                  // Root ifent
 IFENT * f_ifent;                               // Freelist of ifents
 int disabled;                                  // Assembly conditionally disabled
 int just_bss;                                  // 1, ds.b in microprocessor mode
-VALUE pcloc;                                   // Value of "PC" at beginning of line
+uint32_t pcloc;                                        // Value of "PC" at beginning of line
 SYM * lab_sym;                                 // Label on line (or NULL)
 
 const char extra_stuff[] = "extra (unexpected) text found after addressing mode";
@@ -131,7 +131,7 @@ void Assemble(void)
        char * equate;                          // Symbol (or NULL)
        int labtyp = 0;                         // Label type (':', DCOLON)
        int equtyp = 0;                         // Equ type ('=', DEQUALS)
-       VALUE eval;                                     // Expression value
+       uint32_t eval;                                  // Expression value
        WORD eattr;                                     // Expression attributes
        SYM * esym;                                     // External symbol involved in expr.
        WORD siz = 0;                           // Size suffix to mnem/diretve/macro
@@ -177,7 +177,7 @@ DEBUG { printf("Assemble: Found TKEOF flag...\n"); }
        lab_sym = NULL;                                                 // No (exported) label
        equate = NULL;                                                  // No equate
        tk = tok;                                                               // Save first token in line
-       pcloc = (VALUE)sloc;                                    // Set beginning-of-line PC
+       pcloc = (uint32_t)sloc;                                 // Set beginning-of-line PC
 
 loop1:                                                                         // Internal line processing loop
 
@@ -521,7 +521,7 @@ When checking to see if it's already been equated, issue a warning.
                        if (reglist(&rmask) < 0)
                                goto loop;
 
-                       eval = (VALUE)rmask;
+                       eval = (uint32_t)rmask;
                        eattr = ABS | DEFINED;
                }
                else if (equtyp == CCDEF)
index c8c89cb0f00117a4e178a6aca4b21262b41fbd89..559081ffc51e40f969de48495f0066b8f9ac0300 100644 (file)
--- a/procln.h
+++ b/procln.h
@@ -18,7 +18,7 @@ extern const char locgl_error[];
 extern const char syntax_error[];
 extern const char extra_stuff[];
 extern int just_bss;
-extern VALUE pcloc;
+extern uint32_t pcloc;
 extern SYM * lab_sym;
 extern LONG amsktab[];
 extern IFENT * ifent;
index 33c8cd3f7023f5633ffa006e004afe9da2ef105d..79f9ae26425b2b12e1c2b333165bda61ebe5c688 100644 (file)
--- a/riscasm.c
+++ b/riscasm.c
@@ -174,7 +174,7 @@ void BuildRISCIntructionWord(unsigned short opcode, int reg1, int reg2)
 //
 int GetRegister(WORD rattr)
 {
-       VALUE eval;                                     // Expression value
+       uint32_t eval;                                  // Expression value
        WORD eattr;                                     // Expression attributes
        SYM * esym;                                     // External symbol involved in expr.
        TOKEN r_expr[EXPRSIZE];         // Expression token list
@@ -217,7 +217,7 @@ int GenerateRISCCode(int state)
        WORD attrflg;
        int indexed;                            // Indexed register flag
 
-       VALUE eval;                                     // Expression value
+       uint32_t eval;                                  // Expression value
        WORD eattr;                                     // Expression attributes
        SYM * esym;                                     // External symbol involved in expr.
        TOKEN r_expr[EXPRSIZE];         // Expression token list
diff --git a/rmac.c b/rmac.c
index 3dc0f078a2a1b17ed49045602e8849ba9b0135b4..16af05ca6dfec465cf0a8b2feb9d975990041541 100644 (file)
--- a/rmac.c
+++ b/rmac.c
@@ -308,7 +308,7 @@ int Process(int argc, char ** argv)
                                }
 
                                sy->sattr = DEFINED | EQUATED | ABS;
-                               sy->svalue = (*s ? (VALUE)atoi(s) : 0);
+                               sy->svalue = (*s ? (uint32_t)atoi(s) : 0);
                                break;
                        case 'e':                               // Redirect error message output
                        case 'E':
diff --git a/rmac.h b/rmac.h
index 31cbb855a22521cfeb1309994a78423260029269..d5775cc4f0e0e4a08f23d2fa0fdd05e0ebbc18d4 100644 (file)
--- a/rmac.h
+++ b/rmac.h
 #define SPACE        ' '               // ASCII space
 #define SLASHCHAR    '/'
 #define SLASHSTRING  "/"
-#define VALUE        uint32_t  // Assembler value
 #define TOKEN        uint32_t  // Assembler token
 #define FNSIZ        128               // Maximum size of a filename
 #define OK           0                 // OK return
diff --git a/sect.c b/sect.c
index b5bd6ecfb04673eccb44fa7cb768da51735f90eb..e010ff24696f5629e6f6ebaa623ba44573192109 100644 (file)
--- a/sect.c
+++ b/sect.c
@@ -388,7 +388,7 @@ int AddFixup(uint16_t attr, uint32_t loc, TOKEN * fexpr)
 int ResolveFixups(int sno)
 {
        PTR fup;                                // Current fixup
-       VALUE eval;                             // Expression value
+       uint32_t eval;                          // Expression value
        SYM * sy;                               // (Temp) pointer to a symbol
        uint16_t i;                             // (Temp) word
        int reg2;
@@ -514,7 +514,7 @@ int ResolveFixups(int sno)
                                if (eattr & DEFINED)
                                {
                                        if (tdb == sno)
-                                               eval -= (VALUE)loc;
+                                               eval -= (uint32_t)loc;
                                        else if (tdb)
                                        {
                                                error("PC-relative expr across sections");
@@ -525,7 +525,7 @@ int ResolveFixups(int sno)
                                                warn("unoptimized short branch");
                                }
                                else if (obj_format == MWC)
-                                       eval -= (VALUE)loc;
+                                       eval -= (uint32_t)loc;
 
                                tdb = 0;
                                eattr &= ~TDB;
diff --git a/token.c b/token.c
index 091aea49c7aa9d3189ad7fa09b87f2507cf4096e..6246a7418f0b98e1e9848c1a2a2289b868926d68 100644 (file)
--- a/token.c
+++ b/token.c
@@ -949,7 +949,7 @@ int TokenizeLine(void)
        int state = 0;                          // State for keyword detector
        int j = 0;                                      // Var for keyword detector
        uint8_t c;                                      // Random char
-       VALUE v;                                        // Random value
+       uint32_t v;                                     // Random value
        uint8_t * nullspot = NULL;      // Spot to clobber for SYMBOL termination
        int stuffnull;                          // 1:terminate SYMBOL '\0' at *nullspot
        uint8_t c1;
@@ -1133,7 +1133,7 @@ DEBUG { printf("TokenizeLine: Calling fpop() from SRC_IFILE...\n"); }
                                if (((chrtab[*ln] & DOT) == 0) || (dotxtab[*ln] == 0))
                                        return error("[bwsl] must follow '.' in symbol");
 
-                               v = (VALUE)dotxtab[*ln++];
+                               v = (uint32_t)dotxtab[*ln++];
 
                                if (chrtab[*ln] & CTSYM)
                                        return error("misuse of '.'; not allowed in symbols");
diff --git a/token.h b/token.h
index f8df49ae19cc2c50bc197790e9397d20d363638e..cbacccf3a1ae45460e7b2ff283994085f9d4e96c 100644 (file)
--- a/token.h
+++ b/token.h
@@ -144,7 +144,7 @@ IMACRO {
 IREPT {
        LLIST * ir_firstln;             // Pointer to first line
        LLIST * ir_nextln;              // Pointer to next line
-       VALUE ir_count;                 // Repeat count (decrements)
+       uint32_t ir_count;              // Repeat count (decrements)
 };
 
 // Exported variables
index dc9118712e32af71f2d86ac1bf87ef44233c6e50..9db74724eeb676a5a11507ab922983bd878caeb6 100644 (file)
--- a/version.h
+++ b/version.h
@@ -5,7 +5,7 @@
 // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
 // Source utilised with the kind permission of Landon Dyer
 //
-// Contributors: James Hammons, George Nakos, Graeme Hinchliffe, SCPCD
+// Contributors: James Hammons, George Nakos, Graeme Hinchliffe, SCPCD, SainT
 //
 
 #ifndef __VERSION_H__
@@ -15,7 +15,7 @@
 
 #define MAJOR   1              // Major version number
 #define MINOR   8              // Minor version number
-#define PATCH   4              // Patch release number
+#define PATCH   5              // Patch release number
 
 #endif // __VERSION_H__