diff --git a/src/cc65/codeent.c b/src/cc65/codeent.c index a891aeb3d..e87311c30 100644 --- a/src/cc65/codeent.c +++ b/src/cc65/codeent.c @@ -306,7 +306,7 @@ void CE_ReplaceOPC (CodeEntry* E, opc_t OPC) int CodeEntriesAreEqual (const CodeEntry* E1, const CodeEntry* E2) /* Check if both code entries are equal */ { - return E1->OPC == E2->OPC && E1->AM == E2->AM && strcmp (E1->Arg, E2->Arg) == 0; + return (E1->OPC == E2->OPC && E1->AM == E2->AM && strcmp (E1->Arg, E2->Arg) == 0); } @@ -336,6 +336,18 @@ void CE_MoveLabel (CodeLabel* L, CodeEntry* E) +void CE_SetArg (CodeEntry* E, const char* Arg) +/* Replace the argument by the new one. */ +{ + /* Free the old argument */ + FreeArg (E->Arg); + + /* Assign the new one */ + E->Arg = GetArgCopy (Arg); +} + + + void CE_SetNumArg (CodeEntry* E, long Num) /* Set a new numeric argument for the given code entry that must already * have a numeric argument. @@ -357,11 +369,8 @@ void CE_SetNumArg (CodeEntry* E, long Num) Internal ("Invalid instruction size in CE_SetNumArg"); } - /* Free the old argument */ - FreeArg (E->Arg); - - /* Assign the new one */ - E->Arg = GetArgCopy (Buf); + /* Replace the argument by the new one */ + CE_SetArg (E, Buf); /* Use the new numerical value */ E->Num = Num; diff --git a/src/cc65/codeent.h b/src/cc65/codeent.h index 81660287a..2c42faf35 100644 --- a/src/cc65/codeent.h +++ b/src/cc65/codeent.h @@ -157,7 +157,7 @@ INLINE int CE_HasMark (const CodeEntry* E) #else # define CE_HasMark(E) (((E)->Flags & CEF_USERMARK) != 0) #endif - + #if defined(HAVE_INLINE) INLINE void CE_SetMark (CodeEntry* E) /* Set the CEF_USERMARK flag for the given entry */ @@ -178,6 +178,9 @@ INLINE void CE_ResetMark (CodeEntry* E) # define CE_ResetMark(E) ((E)->Flags &= ~CEF_USERMARK) #endif +void CE_SetArg (CodeEntry* E, const char* Arg); +/* Replace the argument by the new one. */ + void CE_SetNumArg (CodeEntry* E, long Num); /* Set a new numeric argument for the given code entry that must already * have a numeric argument. diff --git a/src/cc65/codelab.c b/src/cc65/codelab.c index f4c14ea75..7fd66e7e2 100644 --- a/src/cc65/codelab.c +++ b/src/cc65/codelab.c @@ -89,6 +89,9 @@ void CL_AddRef (CodeLabel* L, struct CodeEntry* E) /* The insn at E jumps to this label */ E->JumpTo = L; + /* Replace the code entry argument with the name of the new label */ + CE_SetArg (E, L->Name); + /* Remember that in the label */ CollAppend (&L->JumpFrom, E); }