X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Fasmcode.c;h=776e36f674e2b4efcf12693030eeac5bc5488f98;hb=9fc71c5e93f7e8270dd6f8fc3810b7b731bf1259;hp=b62d36dcdc6d207e825af8df07c11dd9288254c6;hpb=53dd513176425872128ef26031d00952ef7a0628;p=cc65 diff --git a/src/cc65/asmcode.c b/src/cc65/asmcode.c index b62d36dcd..776e36f67 100644 --- a/src/cc65/asmcode.c +++ b/src/cc65/asmcode.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 2000 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ +/* (C) 2000-2001 Ullrich von Bassewitz */ +/* Wacholderweg 14 */ +/* D-70597 Stuttgart */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -33,63 +33,47 @@ -#include "asmline.h" +/* common */ #include "check.h" -#include "global.h" + +/* cc65 */ +#include "codeopt.h" +#include "codeseg.h" +#include "dataseg.h" +#include "segments.h" +#include "symtab.h" #include "asmcode.h" /*****************************************************************************/ -/* Code */ +/* Code */ /*****************************************************************************/ -void AddCodeLine (const char* Format, ...) -/* Add a new line of code to the output */ -{ - va_list ap; - va_start (ap, Format); - NewCodeLine (Format, ap); - va_end (ap); -} - - - -void AddCodeHint (const char* Hint) -/* Add an optimizer hint */ -{ - AddCodeLine ("+%s", Hint); -} - - - -void AddEmptyLine (void) -/* Add an empty line for formatting purposes */ +CodeMark GetCodePos (void) +/* Get a marker pointing to the current output position */ { - AddCodeLine (""); + return CS_GetEntryCount (CS->Code); } -CodeMark GetCodePos (void) -/* Get a marker pointing to the current output position */ +void RemoveCode (CodeMark M) +/* Remove all code after the given code marker */ { - /* This function should never be called without any code output */ - CHECK (LastLine != 0); - - return LastLine; + CS_DelCodeAfter (CS->Code, M); } -void RemoveCode (CodeMark M) -/* Remove all code after the given code marker */ +void MoveCode (CodeMark Start, CodeMark End, CodeMark Target) +/* Move the code between Start (inclusive) and End (exclusive) to + * (before) Target. + */ { - while (LastLine != M) { - FreeCodeLine (LastLine); - } + CS_MoveEntries (CS->Code, Start, End - Start, Target); } @@ -97,17 +81,26 @@ void RemoveCode (CodeMark M) void WriteOutput (FILE* F) /* Write the final output to a file */ { - Line* L = FirstLine; - while (L) { - /* Don't write optimizer hints if not requested to do so */ - if (L->Line[0] == '+') { - if (Debug) { - fprintf (F, ";%s\n", L->Line); - } - } else { - fprintf (F, "%s\n", L->Line); - } - L = L->Next; + SymTable* SymTab; + SymEntry* Entry; + + /* Output the global data segment */ + CHECK (!HaveGlobalCode ()); + OutputSegments (CS, F); + + /* Output all global or referenced functions */ + SymTab = GetGlobalSymTab (); + Entry = SymTab->SymHead; + while (Entry) { + if (IsTypeFunc (Entry->Type) && + SymIsDef (Entry) && + (Entry->Flags & (SC_REF | SC_EXTERN)) != 0) { + /* Function which is defined and referenced or extern */ + CS_MergeLabels (Entry->V.F.Seg->Code); + RunOpt (Entry->V.F.Seg->Code); + OutputSegments (Entry->V.F.Seg, F); + } + Entry = Entry->NextSym; } }