1
0
mirror of https://github.com/cc65/cc65.git synced 2025-03-01 11:29:27 +00:00

Fix non-goto jumps (i.e. inline assembly).

This commit is contained in:
laubzega 2018-09-29 12:06:33 -07:00 committed by Oliver Schmidt
parent 8845e71161
commit 2ec21c5b7f
3 changed files with 6 additions and 4 deletions

View File

@ -61,7 +61,7 @@ void GotoStatement (void)
} else { } else {
/* Add a new label symbol if we don't have one until now */ /* Add a new label symbol if we don't have one until now */
SymEntry* Entry = AddLabelSym (CurTok.Ident, SC_REF); SymEntry* Entry = AddLabelSym (CurTok.Ident, SC_REF | SC_GOTO);
/* Jump to the label */ /* Jump to the label */
g_jump (Entry->V.L.Label); g_jump (Entry->V.L.Label);

View File

@ -98,6 +98,8 @@ struct LiteralPool;
#define SC_HAVEATTR 0x10000U /* Symbol has attributes */ #define SC_HAVEATTR 0x10000U /* Symbol has attributes */
#define SC_GOTO 0x20000U

View File

@ -701,7 +701,7 @@ SymEntry* AddLabelSym (const char* Name, unsigned Flags)
for (i = 0; i < CollCount (Entry->V.L.DefsOrRefs); i++) { for (i = 0; i < CollCount (Entry->V.L.DefsOrRefs); i++) {
DOR = CollAt (Entry->V.L.DefsOrRefs, i); DOR = CollAt (Entry->V.L.DefsOrRefs, i);
if ((DOR->Flags & SC_DEF) && (Flags & SC_REF)) { if ((DOR->Flags & SC_DEF) && (Flags & SC_REF) && (Flags & SC_GOTO)) {
/* We're processing a goto and here is its destination label. /* We're processing a goto and here is its destination label.
This means the difference between SP values is already known, This means the difference between SP values is already known,
so we simply emit the SP adjustment code. */ so we simply emit the SP adjustment code. */
@ -721,7 +721,7 @@ SymEntry* AddLabelSym (const char* Name, unsigned Flags)
} }
if ((DOR->Flags & SC_REF) && (Flags & SC_DEF)) { if ((DOR->Flags & SC_REF) && (DOR->Flags & SC_GOTO) && (Flags & SC_DEF)) {
/* We're processing a label, let's update all gotos encountered /* We're processing a label, let's update all gotos encountered
so far */ so far */
g_defdatalabel (DOR->LateSP_Label); g_defdatalabel (DOR->LateSP_Label);
@ -762,7 +762,7 @@ SymEntry* AddLabelSym (const char* Name, unsigned Flags)
} }
/* We are processing a goto, but the label has not yet been defined */ /* We are processing a goto, but the label has not yet been defined */
if (!SymIsDef (Entry) && (Flags & SC_REF)) { if (!SymIsDef (Entry) && (Flags & SC_REF) && (Flags & SC_GOTO)) {
g_lateadjustSP (NewDOR->LateSP_Label); g_lateadjustSP (NewDOR->LateSP_Label);
} }