X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=sect.c;h=7a88a5610693f2271e5154f75aab471d0b0bf887;hp=965fcf0dfeb24c12e5095457f72d320eb5be382d;hb=feabdce307d2077374739a7f596846382784b35e;hpb=052be802baa4836564801c780b1d432cfe17c576 diff --git a/sect.c b/sect.c index 965fcf0..7a88a56 100644 --- a/sect.c +++ b/sect.c @@ -7,6 +7,7 @@ // #include "sect.h" +#include "6502.h" #include "direct.h" #include "error.h" #include "expr.h" @@ -16,7 +17,6 @@ #include "riscasm.h" #include "symbol.h" #include "token.h" -extern int m6502; /* 1, assembler in .6502 mode */ // Function prototypes @@ -417,7 +417,7 @@ int ResolveFixups(int sno) */ if (sno == M6502) cch->ch_size = cch->challoc; - + do { fup.cp = ch->chptr; // fup -> start of chunk @@ -592,25 +592,25 @@ int ResolveFixups(int sno) *locp = (uint8_t)eval; break; - // Fixup high/low byte off word for 6502 - case FU_BYTEH: - if (!(eattr & DEFINED)) - { - error("external byte reference"); - continue; - } - - *locp = (uint8_t)((eval >> 8) & 0xff); - break; - case FU_BYTEL: - if (!(eattr & DEFINED)) - { - error("external byte reference"); - continue; - } - - *locp = (uint8_t)(eval & 0xff); - break; + // Fixup high/low byte off word for 6502 + case FU_BYTEH: + if (!(eattr & DEFINED)) + { + error("external byte reference"); + continue; + } + + *locp = (uint8_t)((eval >> 8) & 0xFF); + break; + case FU_BYTEL: + if (!(eattr & DEFINED)) + { + error("external byte reference"); + continue; + } + + *locp = (uint8_t)(eval & 0xFF); + break; // Fixup WORD forward references; // the word could be unaligned in the section buffer, so we have to // be careful. @@ -741,15 +741,12 @@ int ResolveFixups(int sno) } } - if (sno != M6502) - { - *locp++ = (char)(eval >> 8); - *locp = (char)eval; - } + // 6502 words are little endian, so handle that here + if (sno == M6502) + SETLE16(locp, 0, eval) else - { - SETBE16(locp, 0, eval); - } + SETBE16(locp, 0, eval) + break; // Fixup LONG forward references; // the long could be unaligned in the section buffer, so be careful