X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Fasmstmt.c;h=b54771aa9332080baa0b851b1329ca8e379dc771;hb=9b7c16ec4cbb5282642c377272224e3fc825f860;hp=30176add99b9dd3925b020a612a593bdc7f8694d;hpb=9fc71c5e93f7e8270dd6f8fc3810b7b731bf1259;p=cc65 diff --git a/src/cc65/asmstmt.c b/src/cc65/asmstmt.c index 30176add9..b54771aa9 100644 --- a/src/cc65/asmstmt.c +++ b/src/cc65/asmstmt.c @@ -6,8 +6,8 @@ /* */ /* */ /* */ -/* (C) 2001-2004 Ullrich von Bassewitz */ -/* Römerstrasse 52 */ +/* (C) 2001-2008 Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@musoftware.de */ /* */ @@ -39,6 +39,7 @@ #include "xsprintf.h" /* cc65 */ +#include "asmlabel.h" #include "codegen.h" #include "datatype.h" #include "error.h" @@ -223,8 +224,8 @@ static void ParseGVarArg (StrBuf* T, unsigned Arg) } /* Check for external linkage */ - if (Sym->Flags & (SC_EXTERN | SC_STORAGE)) { - /* External linkage */ + if (Sym->Flags & (SC_EXTERN | SC_STORAGE | SC_FUNC)) { + /* External linkage or a function */ /* ### FIXME: Asm name should be generated by codegen */ SB_AppendChar (T, '_'); SB_AppendStr (T, Sym->Name); @@ -275,6 +276,31 @@ static void ParseLVarArg (StrBuf* T, unsigned Arg) +static void ParseLabelArg (StrBuf* T, unsigned Arg attribute ((unused))) +/* Parse the %g format specifier */ +{ + /* We expect an identifier separated by a comma */ + ConsumeComma (); + if (CurTok.Tok != TOK_IDENT) { + + Error ("Label name expected"); + + } else { + + /* Add a new label symbol if we don't have one until now */ + SymEntry* Entry = AddLabelSym (CurTok.Ident, SC_REF); + + /* Append the label name to the buffer */ + SB_AppendStr (T, LocalLabelName (Entry->V.Label)); + + /* Eat the label name */ + NextToken (); + + } +} + + + static void ParseStrArg (StrBuf* T, unsigned Arg attribute ((unused))) /* Parse the %s format specifier */ { @@ -340,6 +366,7 @@ static void ParseAsm (void) * %l - Numerical 32 bit value * %v - Assembler name of a (global) variable * %o - Stack offset of a (local) variable + * %g - Assembler name of a C label * %s - Any argument converted to a string (almost) * %% - The % sign */ @@ -359,13 +386,14 @@ static void ParseAsm (void) ++Arg; C = SB_Get (&S); switch (C) { - case '%': SB_AppendChar (&T, '%'); break; - case 'b': ParseByteArg (&T, Arg); break; - case 'l': ParseLongArg (&T, Arg); break; - case 'o': ParseLVarArg (&T, Arg); break; - case 's': ParseStrArg (&T, Arg); break; - case 'v': ParseGVarArg (&T, Arg); break; - case 'w': ParseWordArg (&T, Arg); break; + case '%': SB_AppendChar (&T, '%'); break; + case 'b': ParseByteArg (&T, Arg); break; + case 'g': ParseLabelArg (&T, Arg); break; + case 'l': ParseLongArg (&T, Arg); break; + case 'o': ParseLVarArg (&T, Arg); break; + case 's': ParseStrArg (&T, Arg); break; + case 'v': ParseGVarArg (&T, Arg); break; + case 'w': ParseWordArg (&T, Arg); break; default: Error ("Error in __asm__ format specifier %u", Arg); AsmErrorSkip (); @@ -387,8 +415,8 @@ static void ParseAsm (void) Done: /* Call the string buf destructors */ - DoneStrBuf (&S); - DoneStrBuf (&T); + SB_Done (&S); + SB_Done (&T); }