X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Fasmcode.c;h=776e36f674e2b4efcf12693030eeac5bc5488f98;hb=9fc71c5e93f7e8270dd6f8fc3810b7b731bf1259;hp=b52987b342de3af8ebdfc78bdfa827a8248d7490;hpb=c71a80b0afd9a035dd0aab156bf1931c6aaef7fa;p=cc65 diff --git a/src/cc65/asmcode.c b/src/cc65/asmcode.c index b52987b34..776e36f67 100644 --- a/src/cc65/asmcode.c +++ b/src/cc65/asmcode.c @@ -36,35 +36,26 @@ /* common */ #include "check.h" -/* b6502 */ +/* cc65 */ #include "codeopt.h" #include "codeseg.h" #include "dataseg.h" - -/* cc65 */ +#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 */ { - return GetCodeSegEntries (CS); + return CS_GetEntryCount (CS->Code); } @@ -72,22 +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); } -static void PrintFunctionHeader (FILE* F, SymEntry* Entry) +void MoveCode (CodeMark Start, CodeMark End, CodeMark Target) +/* Move the code between Start (inclusive) and End (exclusive) to + * (before) Target. + */ { - /* Print a comment with the function signature */ - fprintf (F, - "; ---------------------------------------------------------------\n" - "; "); - PrintFuncSig (F, Entry->Name, Entry->Type); - fprintf (F, - "\n" - "; ---------------------------------------------------------------\n" - "\n"); + CS_MoveEntries (CS->Code, Start, End - Start, Target); } @@ -98,27 +84,23 @@ void WriteOutput (FILE* F) SymTable* SymTab; SymEntry* Entry; - /* Output the data segment (the global code segment should be empty) */ - OutputDataSeg (F, DS); - CHECK (GetCodeSegEntries (CS) == 0); + /* 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) && - (Entry->Flags & SC_DEF) != 0 && - (Entry->Flags & (SC_REF | SC_EXTERN)) != 0) { - /* Function which is defined and referenced or extern */ - PrintFunctionHeader (F, Entry); - MergeCodeLabels (Entry->V.F.CS); - RunOpt (Entry->V.F.CS); - fprintf (F, "; Data segment for function %s:\n", Entry->Name); - OutputDataSeg (F, Entry->V.F.DS); - fprintf (F, "; Code segment for function %s:\n", Entry->Name); - OutputCodeSeg (F, Entry->V.F.CS); - } - Entry = Entry->NextSym; + 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; } }