mirror of
https://github.com/cc65/cc65.git
synced 2025-08-08 06:25:17 +00:00
Allow optional assignments in .export and .exportzp statements.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3809 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -2158,19 +2158,25 @@ Here's a list of all control commands and a description, what they do:
|
|||||||
<sect1><tt>.EXPORT</tt><label id=".EXPORT"><p>
|
<sect1><tt>.EXPORT</tt><label id=".EXPORT"><p>
|
||||||
|
|
||||||
Make symbols accessible from other modules. Must be followed by a comma
|
Make symbols accessible from other modules. Must be followed by a comma
|
||||||
separated list of symbols to export, with each one optionally followed by
|
separated list of symbols to export, with each one optionally followed by an
|
||||||
an address specification. The default is to export the symbol with the
|
address specification and (also optional) an assignment. Using an additional
|
||||||
address size it actually has. The assembler will issue a warning, if the
|
assignment in the export statement allows to define and export a symbol in
|
||||||
symbol is exported with an address size smaller than the actual address
|
one statement. The default is to export the symbol with the address size it
|
||||||
size.
|
actually has. The assembler will issue a warning, if the symbol is exported
|
||||||
|
with an address size smaller than the actual address size.
|
||||||
|
|
||||||
Example:
|
Examples:
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
.export foo
|
.export foo
|
||||||
.export bar: far
|
.export bar: far
|
||||||
|
.export foobar: far = foo * bar
|
||||||
|
.export baz := foobar, zap: far = baz - bar
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
|
As with constant definitions, using <tt/:=/ instead of <tt/=/ marks the
|
||||||
|
symbols as a label.
|
||||||
|
|
||||||
See: <tt><ref id=".EXPORTZP" name=".EXPORTZP"></tt>
|
See: <tt><ref id=".EXPORTZP" name=".EXPORTZP"></tt>
|
||||||
|
|
||||||
|
|
||||||
@@ -2178,12 +2184,15 @@ Here's a list of all control commands and a description, what they do:
|
|||||||
|
|
||||||
Make symbols accessible from other modules. Must be followed by a comma
|
Make symbols accessible from other modules. Must be followed by a comma
|
||||||
separated list of symbols to export. The exported symbols are explicitly
|
separated list of symbols to export. The exported symbols are explicitly
|
||||||
marked as zero page symbols.
|
marked as zero page symbols. An assignment may be included in the
|
||||||
|
<tt/.EXPORTZP/ statement. This allows to define and export a symbol in one
|
||||||
|
statement.
|
||||||
|
|
||||||
Example:
|
Examples:
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
.exportzp foo, bar
|
.exportzp foo, bar
|
||||||
|
.exportzp baz := $02
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
See: <tt><ref id=".EXPORT" name=".EXPORT"></tt>
|
See: <tt><ref id=".EXPORT" name=".EXPORT"></tt>
|
||||||
|
@@ -165,6 +165,33 @@ static void SetBoolOption (unsigned char* Flag)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void ExportWithAssign (SymEntry* Sym, unsigned char AddrSize, unsigned Flags)
|
||||||
|
/* Allow to assign the value of an export in an .export statement */
|
||||||
|
{
|
||||||
|
/* The name and optional address size spec may be followed by an assignment
|
||||||
|
* or equal token.
|
||||||
|
*/
|
||||||
|
if (Tok == TOK_ASSIGN || Tok == TOK_EQ) {
|
||||||
|
|
||||||
|
/* Assignment means the symbol is a label */
|
||||||
|
if (Tok == TOK_ASSIGN) {
|
||||||
|
Flags |= SF_LABEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Skip the assignment token */
|
||||||
|
NextTok ();
|
||||||
|
|
||||||
|
/* Define the symbol with the expression following the '=' */
|
||||||
|
SymDef (Sym, Expression(), ADDR_SIZE_DEFAULT, Flags);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now export the symbol */
|
||||||
|
SymExport (Sym, AddrSize, Flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ExportImport (void (*Func) (SymEntry*, unsigned char, unsigned),
|
static void ExportImport (void (*Func) (SymEntry*, unsigned char, unsigned),
|
||||||
unsigned char DefAddrSize, unsigned Flags)
|
unsigned char DefAddrSize, unsigned Flags)
|
||||||
/* Export or import symbols */
|
/* Export or import symbols */
|
||||||
@@ -782,7 +809,7 @@ static void DoExitMacro (void)
|
|||||||
static void DoExport (void)
|
static void DoExport (void)
|
||||||
/* Export a symbol */
|
/* Export a symbol */
|
||||||
{
|
{
|
||||||
ExportImport (SymExport, ADDR_SIZE_DEFAULT, SF_NONE);
|
ExportImport (ExportWithAssign, ADDR_SIZE_DEFAULT, SF_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -790,7 +817,7 @@ static void DoExport (void)
|
|||||||
static void DoExportZP (void)
|
static void DoExportZP (void)
|
||||||
/* Export a zeropage symbol */
|
/* Export a zeropage symbol */
|
||||||
{
|
{
|
||||||
ExportImport (SymExport, ADDR_SIZE_ZP, SF_NONE);
|
ExportImport (ExportWithAssign, ADDR_SIZE_ZP, SF_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user