diff --git a/src/cc65/coptmisc.c b/src/cc65/coptmisc.c index 0e3dd0d56..e21234cd1 100644 --- a/src/cc65/coptmisc.c +++ b/src/cc65/coptmisc.c @@ -1226,15 +1226,15 @@ unsigned OptTosPushPop(CodeSeg *S) strcmp(N->Arg, "popax") == 0 && !CE_HasLabel (N)) { - /* Delete the old code */ - CS_DelEntries (S, I, 2); - /* Insert an rts if jmp popax */ if (N->OPC == OP65_JMP) { CodeEntry* X = NewCodeEntry (OP65_RTS, AM65_IMP, 0, 0, E->LI); CS_InsertEntry (S, X, I); } + /* Delete the old code */ + CS_DelEntries (S, I+1, 2); + /* Regenerate register info */ CS_GenRegInfo (S);