diff --git a/src/asm/asmy.y b/src/asm/asmy.y index 23342ac1..24f06079 100644 --- a/src/asm/asmy.y +++ b/src/asm/asmy.y @@ -405,7 +405,6 @@ static void updateUnion(void) nPC = unionStart[unionIndex]; pCurrentSection->nPC = unionStart[unionIndex]; - pPCSymbol->nValue = unionStart[unionIndex]; } static size_t strlenUTF8(const char *s) @@ -858,7 +857,6 @@ endu : T_POP_ENDU nUnionDepth--; nPC = unionStart[nUnionDepth] + unionSize[nUnionDepth]; pCurrentSection->nPC = nPC; - pPCSymbol->nValue = nPC; } ; diff --git a/src/asm/section.c b/src/asm/section.c index f45b4654..a1eaea44 100644 --- a/src/asm/section.c +++ b/src/asm/section.c @@ -148,7 +148,6 @@ static void setCurrentSection(struct Section *pSect) pCurrentSection = pSect; nPC = (pSect != NULL) ? pSect->nPC : 0; - pPCSymbol->nValue = nPC; pPCSymbol->pSection = pCurrentSection; pPCSymbol->isConstant = pSect && pSect->nOrg != -1; } @@ -207,7 +206,6 @@ static void absByteBypassCheck(int32_t b) pCurrentSection->tData[nPC] = b; pCurrentSection->nPC++; nPC++; - pPCSymbol->nValue++; } /* @@ -237,7 +235,6 @@ void out_Skip(int32_t skip) if (!sect_HasData(pCurrentSection->nType)) { pCurrentSection->nPC += skip; nPC += skip; - pPCSymbol->nValue += skip; } else if (nUnionDepth > 0) { while (skip--) absByteBypassCheck(CurrentOptions.fillchar); @@ -272,7 +269,6 @@ void out_RelByte(struct Expression *expr) out_CreatePatch(PATCHTYPE_BYTE, expr); pCurrentSection->nPC++; nPC++; - pPCSymbol->nValue++; } else { out_AbsByte(expr->nVal); } @@ -291,7 +287,6 @@ static void absWord(int32_t b) pCurrentSection->tData[nPC + 1] = b >> 8; pCurrentSection->nPC += 2; nPC += 2; - pPCSymbol->nValue += 2; } /* @@ -308,7 +303,6 @@ void out_RelWord(struct Expression *expr) out_CreatePatch(PATCHTYPE_WORD, expr); pCurrentSection->nPC += 2; nPC += 2; - pPCSymbol->nValue += 2; } else { absWord(expr->nVal); } @@ -328,7 +322,6 @@ static void absLong(int32_t b) pCurrentSection->tData[nPC + 3] = b >> 24; pCurrentSection->nPC += 4; nPC += 4; - pPCSymbol->nValue += 4; } /* @@ -347,7 +340,6 @@ void out_RelLong(struct Expression *expr) out_CreatePatch(PATCHTYPE_LONG, expr); pCurrentSection->nPC += 4; nPC += 4; - pPCSymbol->nValue += 4; } else { absLong(expr->nVal); } @@ -367,7 +359,6 @@ void out_PCRelByte(struct Expression *expr) out_CreatePatch(PATCHTYPE_JR, expr); pCurrentSection->nPC++; nPC++; - pPCSymbol->nValue++; } else { /* Target is relative to the byte *after* the operand */ uint16_t address = pCurrentSection->nOrg + nPC + 1; @@ -417,7 +408,6 @@ void out_BinaryFile(char const *s) pCurrentSection->nPC += fsize; nPC += fsize; - pPCSymbol->nValue += fsize; fclose(f); } @@ -464,7 +454,6 @@ void out_BinaryFileSlice(char const *s, int32_t start_pos, int32_t length) pCurrentSection->nPC += length; nPC += length; - pPCSymbol->nValue += length; fclose(f); } diff --git a/src/asm/symbol.c b/src/asm/symbol.c index c3f9aaea..73752523 100644 --- a/src/asm/symbol.c +++ b/src/asm/symbol.c @@ -64,6 +64,11 @@ static int32_t Callback__LINE__(unused_ struct sSymbol const *sym) return nLineNo; } +static int32_t CallbackPC(struct sSymbol const *self) +{ + return self->pSection ? self->pSection->nOrg + self->pSection->nPC : 0; +} + /* * Get the nValue field of a symbol */ @@ -722,6 +727,7 @@ void sym_Init(void) sym_AddReloc("@"); pPCSymbol = findsymbol("@", NULL); + pPCSymbol->Callback = CallbackPC; sym_AddEqu("_NARG", 0); p_NARGSymbol = findsymbol("_NARG", NULL); p_NARGSymbol->Callback = Callback_NARG;