mirror of
https://github.com/cc65/cc65.git
synced 2025-04-09 10:39:40 +00:00
Inline assembly can now reference C labels with the %g format specifier
git-svn-id: svn://svn.cc65.org/cc65/trunk@3128 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
a3e6fbd21f
commit
9cb7015055
@ -957,6 +957,7 @@ the format specifier before passing the assembly code line to the backend.
|
||||
<item><tt/%l/ - Numerical 32 bit value
|
||||
<item><tt/%v/ - Assembler name of a (global) variable or function
|
||||
<item><tt/%o/ - Stack offset of a (local) variable
|
||||
<item><tt/%g/ - Assembler name of a C label
|
||||
<item><tt/%s/ - The argument is converted to a string
|
||||
<item><tt/%%/ - The % sign itself
|
||||
</itemize><p>
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "xsprintf.h"
|
||||
|
||||
/* cc65 */
|
||||
#include "asmlabel.h"
|
||||
#include "codegen.h"
|
||||
#include "datatype.h"
|
||||
#include "error.h"
|
||||
@ -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 ();
|
||||
|
Loading…
x
Reference in New Issue
Block a user