Use callback for PC's value

This causes it to auto-update whenever the current section's attributes are
updated, simplifying the code and eliminating redundancy.
This should also overall reduce overhead (one extra function call on each
PC evaluation, but less bookkeeping for each byte output)
This commit is contained in:
ISSOtm
2020-02-09 15:10:47 +01:00
parent 8c4b473d6f
commit 598c923506
3 changed files with 6 additions and 13 deletions

View File

@@ -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;