X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Fasmcode.c;h=39092092fc4990cd60ba065dbe7f63302a1e4178;hb=0529c2044a7006eb9092d419a59916acc8522c23;hp=cf197945733945702a1a010cc6d73abf61f845f0;hpb=9d1940a124482b8c77e4c2a79c1d2a9c206bcf94;p=cc65 diff --git a/src/cc65/asmcode.c b/src/cc65/asmcode.c index cf1979457..39092092f 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 */ @@ -36,40 +36,26 @@ /* common */ #include "check.h" -/* b6502 */ +/* cc65 */ +#include "codeopt.h" #include "codeseg.h" #include "dataseg.h" - -/* cc65 */ -#include "codegen.h" -#include "global.h" +#include "segments.h" +#include "symtab.h" #include "asmcode.h" /*****************************************************************************/ -/* Code */ +/* Code */ /*****************************************************************************/ -void AddCodeHint (const char* Hint) -/* Add an optimizer hint */ -{ - /* ### AddCodeLine ("+%s", Hint); */ -} - - - CodeMark GetCodePos (void) /* Get a marker pointing to the current output position */ { - unsigned EntryCount = GetCodeSegEntries (CS); - - /* This function should never be called without any code output */ - CHECK (EntryCount > 0); - - return EntryCount; + return CS_GetEntryCount (CS->Code); } @@ -77,7 +63,17 @@ CodeMark GetCodePos (void) void RemoveCode (CodeMark M) /* Remove all code after the given code marker */ { - DelCodeSegAfter (CS, M); + CS_DelCodeAfter (CS->Code, M); +} + + + +void MoveCode (CodeMark Start, CodeMark End, CodeMark Target) +/* Move the code between Start (inclusive) and End (exclusive) to + * (before) Target. + */ +{ + CS_MoveEntries (CS->Code, Start, End - Start, Target); } @@ -85,9 +81,27 @@ void RemoveCode (CodeMark M) void WriteOutput (FILE* F) /* Write the final output to a file */ { - OutputDataSeg (F, DS); - MergeCodeLabels (CS); - OutputCodeSeg (F, CS); + SymTable* SymTab; + SymEntry* Entry; + + /* Output the global data segment */ + CHECK (CS_GetEntryCount (CS->Code) == 0); + OutputSegments (CS, F); + + /* Output all global or referenced functions */ + SymTab = GetGlobalSymTab (); + Entry = SymTab->SymHead; + while (Entry) { + if (IsTypeFunc (Entry->Type) && + (Entry->Flags & SC_DEF) != 0 && + (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; + } }