mirror of
https://github.com/cc65/cc65.git
synced 2024-11-19 06:31:31 +00:00
Working on the new backend
git-svn-id: svn://svn.cc65.org/cc65/trunk@705 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
b9677becc1
commit
cd956115fa
@ -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,16 +33,11 @@
|
||||
|
||||
|
||||
|
||||
/* common */
|
||||
#include "check.h"
|
||||
|
||||
/* b6502 */
|
||||
#include "codeseg.h"
|
||||
#include "dataseg.h"
|
||||
|
||||
/* cc65 */
|
||||
#include "codegen.h"
|
||||
#include "global.h"
|
||||
#include "asmcode.h"
|
||||
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -1,180 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* asmline.h */
|
||||
/* */
|
||||
/* Internal assembler line structure */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
/* warranty. In no event will the authors be held liable for any damages */
|
||||
/* arising from the use of this software. */
|
||||
/* */
|
||||
/* Permission is granted to anyone to use this software for any purpose, */
|
||||
/* including commercial applications, and to alter it and redistribute it */
|
||||
/* freely, subject to the following restrictions: */
|
||||
/* */
|
||||
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||
/* claim that you wrote the original software. If you use this software */
|
||||
/* in a product, an acknowledgment in the product documentation would be */
|
||||
/* appreciated but is not required. */
|
||||
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||
/* be misrepresented as being the original software. */
|
||||
/* 3. This notice may not be removed or altered from any source */
|
||||
/* distribution. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* common */
|
||||
#include "xmalloc.h"
|
||||
#include "xsprintf.h"
|
||||
|
||||
/* cc65 */
|
||||
#include "error.h"
|
||||
#include "asmline.h"
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
/* Number used to index lines */
|
||||
static unsigned long LineIndex = 0;
|
||||
|
||||
/* The line list */
|
||||
Line* FirstLine = 0; /* Pointer to first line */
|
||||
Line* LastLine = 0; /* Pointer to last line */
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
static Line* NewLine (const char* Format, va_list ap)
|
||||
/* Interal routine to create a new line from the given text */
|
||||
{
|
||||
char Buf [8192];
|
||||
unsigned Len;
|
||||
Line* L;
|
||||
|
||||
|
||||
/* Make a string from the given format and arguments */
|
||||
xvsprintf (Buf, sizeof (Buf), Format, ap);
|
||||
|
||||
/* Get the length of the line */
|
||||
Len = strlen (Buf);
|
||||
|
||||
/* Allocate memory */
|
||||
L = (Line*) xmalloc (sizeof (Line) + Len);
|
||||
|
||||
/* Partially initialize the struct (the remaining fields are initialized
|
||||
* by the caller).
|
||||
*/
|
||||
L->Flags = 0;
|
||||
L->Size = 0;
|
||||
L->Len = Len;
|
||||
memcpy (L->Line, Buf, Len+1);
|
||||
|
||||
/* Return the new line */
|
||||
return L;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Line* NewCodeLine (const char* Format, va_list ap)
|
||||
/* Create a new code line and return it */
|
||||
{
|
||||
/* Create a new line struct */
|
||||
Line* L = NewLine (Format, ap);
|
||||
|
||||
/* Initialize struct fields */
|
||||
L->Index = LineIndex++;
|
||||
|
||||
/* Insert the line into the list */
|
||||
if (FirstLine == 0) {
|
||||
/* The list is empty */
|
||||
L->Next = L->Prev = 0;
|
||||
FirstLine = LastLine = L;
|
||||
} else {
|
||||
/* There are entries in the list, add the new one at the end */
|
||||
LastLine->Next = L;
|
||||
L->Prev = LastLine;
|
||||
L->Next = 0;
|
||||
LastLine = L;
|
||||
}
|
||||
|
||||
/* Return the new line */
|
||||
return L;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Line* NewCodeLineAfter (Line* LineBefore, const char* Format, va_list ap)
|
||||
/* Create a new line, insert it after L and return it. */
|
||||
{
|
||||
/* Create a new line struct */
|
||||
Line* L = NewLine (Format, ap);
|
||||
|
||||
/* Initialize struct fields. We use the same index for the inserted line
|
||||
* as for its predecessor, since we cannot create new numbers on the
|
||||
* fly and the index is only used to determine sort order.
|
||||
*/
|
||||
L->Index = LineBefore->Index;
|
||||
|
||||
/* Insert the line after its predecessor */
|
||||
L->Next = LineBefore->Next;
|
||||
LineBefore->Next = L;
|
||||
L->Prev = LineBefore;
|
||||
if (L->Next) {
|
||||
L->Next->Prev = L;
|
||||
} else {
|
||||
/* This is the last line */
|
||||
LastLine = L;
|
||||
}
|
||||
|
||||
/* Return the new line */
|
||||
return L;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FreeCodeLine (Line* L)
|
||||
/* Remove a line from the list and free it */
|
||||
{
|
||||
/* Unlink the line */
|
||||
if (L->Prev == 0) {
|
||||
/* No line before this one */
|
||||
FirstLine = L->Next;
|
||||
} else {
|
||||
L->Prev->Next = L->Next;
|
||||
}
|
||||
if (L->Next == 0) {
|
||||
/* No line after this one */
|
||||
LastLine = L->Prev;
|
||||
} else {
|
||||
L->Next->Prev = L->Prev;
|
||||
}
|
||||
|
||||
/* Free the struct */
|
||||
xfree (L);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,93 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* asmline.h */
|
||||
/* */
|
||||
/* Internal assembler line structure */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
/* warranty. In no event will the authors be held liable for any damages */
|
||||
/* arising from the use of this software. */
|
||||
/* */
|
||||
/* Permission is granted to anyone to use this software for any purpose, */
|
||||
/* including commercial applications, and to alter it and redistribute it */
|
||||
/* freely, subject to the following restrictions: */
|
||||
/* */
|
||||
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||
/* claim that you wrote the original software. If you use this software */
|
||||
/* in a product, an acknowledgment in the product documentation would be */
|
||||
/* appreciated but is not required. */
|
||||
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||
/* be misrepresented as being the original software. */
|
||||
/* 3. This notice may not be removed or altered from any source */
|
||||
/* distribution. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifndef ASMLINE_H
|
||||
#define ASMLINE_H
|
||||
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
/* common */
|
||||
#include "attrib.h"
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
/* Structure that contains one line */
|
||||
typedef struct Line Line;
|
||||
struct Line {
|
||||
Line* Next; /* Next line on double linked list */
|
||||
Line* Prev; /* Revious line in list */
|
||||
unsigned Flags; /* Flags for this line */
|
||||
unsigned long Index; /* Index of this line */
|
||||
unsigned Size; /* Size of this code */
|
||||
unsigned Len; /* Length of the line */
|
||||
char Line [1]; /* The line itself */
|
||||
};
|
||||
|
||||
/* The line list */
|
||||
extern Line* FirstLine; /* Pointer to first line */
|
||||
extern Line* LastLine; /* Pointer to last line */
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
Line* NewCodeLine (const char* Format, va_list ap) attribute((format(printf,1,0)));
|
||||
/* Create a new code line and return it */
|
||||
|
||||
Line* NewCodeLineAfter (Line* LineBefore, const char* Format, va_list ap) attribute((format(printf,2,0)));
|
||||
/* Create a new line, insert it after L and return it. */
|
||||
|
||||
void FreeCodeLine (Line* L);
|
||||
/* Remove a line from the list and free it */
|
||||
|
||||
|
||||
|
||||
/* End of asmline.h */
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -43,6 +43,10 @@
|
||||
#include "xmalloc.h"
|
||||
#include "xsprintf.h"
|
||||
|
||||
/* b6502 */
|
||||
#include "codeseg.h"
|
||||
#include "dataseg.h"
|
||||
|
||||
/* cc65 */
|
||||
#include "asmcode.h"
|
||||
#include "asmlabel.h"
|
||||
@ -64,10 +68,6 @@
|
||||
/* Compiler relative stack pointer */
|
||||
int oursp = 0;
|
||||
|
||||
/* Segments */
|
||||
DataSeg* DS = 0;
|
||||
CodeSeg* CS = 0;
|
||||
|
||||
/* Current segment */
|
||||
segment_t CurSeg = SEG_INV;
|
||||
|
||||
@ -79,22 +79,6 @@ segment_t CurSeg = SEG_INV;
|
||||
|
||||
|
||||
|
||||
static void AddCodeLine (const char* Format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char Buf [1024];
|
||||
va_start (ap, Format);
|
||||
xvsprintf (Buf, sizeof (Buf), Format, ap);
|
||||
va_end (ap);
|
||||
if (CurSeg == SEG_CODE) {
|
||||
AddCodeSegLine (CS, "%s", Buf);
|
||||
} else {
|
||||
AddDataSegLine (DS, "%s", Buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void typeerror (unsigned type)
|
||||
/* Print an error message about an invalid operand type */
|
||||
{
|
||||
@ -108,7 +92,6 @@ static void CheckLocalOffs (unsigned Offs)
|
||||
{
|
||||
if (Offs >= 256) {
|
||||
/* Too many local vars */
|
||||
AddCodeLine (";*** Too many locals");
|
||||
Error ("Too many local variables");
|
||||
}
|
||||
}
|
||||
@ -153,7 +136,7 @@ static char* GetLabelName (unsigned flags, unsigned long label, unsigned offs)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Pre- and postamble */
|
||||
/* Pre- and postamble */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
@ -161,34 +144,37 @@ static char* GetLabelName (unsigned flags, unsigned long label, unsigned offs)
|
||||
void g_preamble (void)
|
||||
/* Generate the assembler code preamble */
|
||||
{
|
||||
/* ### */
|
||||
CS = NewCodeSeg ("CODE");
|
||||
DS = NewDataSeg ();
|
||||
|
||||
AddCodeLine ("; File generated by cc65 v %u.%u.%u", VER_MAJOR, VER_MINOR, VER_PATCH);
|
||||
/* Generate the global segments and push them */
|
||||
PushCodeSeg (NewCodeSeg (""));
|
||||
PushDataSeg (NewDataSeg (""));
|
||||
|
||||
/* Identify the compiler version */
|
||||
AddDataSegLine (DS, "; File generated by cc65 v %u.%u.%u",
|
||||
VER_MAJOR, VER_MINOR, VER_PATCH);
|
||||
|
||||
/* Insert some object file options */
|
||||
AddCodeLine (".fopt\t\tcompiler,\"cc65 v %u.%u.%u\"", VER_MAJOR, VER_MINOR, VER_PATCH);
|
||||
AddDataSegLine (DS, ".fopt\t\tcompiler,\"cc65 v %u.%u.%u\"",
|
||||
VER_MAJOR, VER_MINOR, VER_PATCH);
|
||||
|
||||
/* If we're producing code for some other CPU, switch the command set */
|
||||
if (CPU == CPU_65C02) {
|
||||
AddCodeLine (".pc02");
|
||||
AddDataSegLine (DS, ".pc02");
|
||||
}
|
||||
|
||||
/* Allow auto import for runtime library routines */
|
||||
AddCodeLine (".autoimport\ton");
|
||||
AddDataSegLine (DS, ".autoimport\ton");
|
||||
|
||||
/* Switch the assembler into case sensitive mode */
|
||||
AddCodeLine (".case\t\ton");
|
||||
AddDataSegLine (DS, ".case\t\ton");
|
||||
|
||||
/* Tell the assembler if we want to generate debug info */
|
||||
AddCodeLine (".debuginfo\t%s", (DebugInfo != 0)? "on" : "off");
|
||||
AddDataSegLine (DS, ".debuginfo\t%s", (DebugInfo != 0)? "on" : "off");
|
||||
|
||||
/* Import the stack pointer for direct auto variable access */
|
||||
AddCodeLine (".importzp\tsp, sreg, regsave, regbank, tmp1, ptr1");
|
||||
AddDataSegLine (DS, ".importzp\tsp, sreg, regsave, regbank, tmp1, ptr1");
|
||||
|
||||
/* Define long branch macros */
|
||||
AddCodeLine (".macpack\tlongbranch");
|
||||
AddDataSegLine (DS, ".macpack\tlongbranch");
|
||||
}
|
||||
|
||||
|
||||
@ -205,7 +191,7 @@ static void UseSeg (int NewSeg)
|
||||
if (CurSeg != NewSeg) {
|
||||
CurSeg = (segment_t) NewSeg;
|
||||
if (CurSeg != SEG_CODE) {
|
||||
AddCodeLine (".segment\t\"%s\"", SegmentNames [CurSeg]);
|
||||
AddDataSegLine (DS, ".segment\t\"%s\"", SegmentNames [CurSeg]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -557,7 +543,7 @@ void g_leave (int flags, int val)
|
||||
}
|
||||
|
||||
/* Output the jump */
|
||||
AddCodeLine (buf);
|
||||
AddCodeSegLine (CS, buf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3910,7 +3896,7 @@ void g_defbytes (const void* Bytes, unsigned Count)
|
||||
} while (Chunk);
|
||||
|
||||
/* Output the line */
|
||||
AddCodeLine (Buf);
|
||||
AddCodeSegLine (CS, Buf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3920,7 +3906,7 @@ void g_zerobytes (unsigned n)
|
||||
/* Output n bytes of data initialized with zero */
|
||||
{
|
||||
AddDataSegLine (DS, "\t.res\t%u,$00", n);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -38,12 +38,6 @@
|
||||
|
||||
|
||||
|
||||
/* ##### */
|
||||
#include "dataseg.h"
|
||||
#include "codeseg.h"
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* data */
|
||||
/*****************************************************************************/
|
||||
@ -86,10 +80,6 @@
|
||||
/* Compiler relative stackpointer */
|
||||
extern int oursp;
|
||||
|
||||
/* Segments */
|
||||
extern DataSeg* DS;
|
||||
extern CodeSeg* CS;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -55,7 +55,18 @@
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
/* Pointer to current code segment */
|
||||
CodeSeg* CS = 0;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Functions for parsing instructions */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
@ -292,6 +303,12 @@ static CodeEntry* ParseInsn (CodeSeg* S, const char* L)
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
CodeSeg* NewCodeSeg (const char* Name)
|
||||
/* Create a new code segment, initialize and return it */
|
||||
{
|
||||
@ -301,6 +318,7 @@ CodeSeg* NewCodeSeg (const char* Name)
|
||||
CodeSeg* S = xmalloc (sizeof (CodeSeg));
|
||||
|
||||
/* Initialize the fields */
|
||||
S->Next = 0;
|
||||
S->Name = xstrdup (Name);
|
||||
InitCollection (&S->Entries);
|
||||
InitCollection (&S->Labels);
|
||||
@ -348,6 +366,33 @@ void FreeCodeSeg (CodeSeg* S)
|
||||
|
||||
|
||||
|
||||
void PushCodeSeg (CodeSeg* S)
|
||||
/* Push the given code segment onto the stack */
|
||||
{
|
||||
S->Next = CS;
|
||||
CS = S;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CodeSeg* PopCodeSeg (void)
|
||||
/* Remove the current code segment from the stack and return it */
|
||||
{
|
||||
/* Remember the current code segment */
|
||||
CodeSeg* S = CS;
|
||||
|
||||
/* Cannot pop on empty stack */
|
||||
PRECONDITION (S != 0);
|
||||
|
||||
/* Pop */
|
||||
CS = S->Next;
|
||||
|
||||
/* Return the popped code segment */
|
||||
return S;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AddCodeSegLine (CodeSeg* S, const char* Format, ...)
|
||||
/* Add a line to the given code segment */
|
||||
{
|
||||
|
@ -61,12 +61,16 @@
|
||||
/* Code segment structure */
|
||||
typedef struct CodeSeg CodeSeg;
|
||||
struct CodeSeg {
|
||||
CodeSeg* Next; /* Pointer to next CodeSeg */
|
||||
char* Name; /* Segment name */
|
||||
Collection Entries; /* List of code entries */
|
||||
Collection Labels; /* Labels for next insn */
|
||||
CodeLabel* LabelHash [CS_LABEL_HASH_SIZE]; /* Label hash table */
|
||||
};
|
||||
|
||||
/* Pointer to current code segment */
|
||||
extern CodeSeg* CS;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -81,6 +85,12 @@ CodeSeg* NewCodeSeg (const char* Name);
|
||||
void FreeCodeSeg (CodeSeg* S);
|
||||
/* Free a code segment including all code entries */
|
||||
|
||||
void PushCodeSeg (CodeSeg* S);
|
||||
/* Push the given code segment onto the stack */
|
||||
|
||||
CodeSeg* PopCodeSeg (void);
|
||||
/* Remove the current code segment from the stack and return it */
|
||||
|
||||
void AddCodeSegLine (CodeSeg* S, const char* Format, ...) attribute ((format(printf,2,3)));
|
||||
/* Add a line to the given code segment */
|
||||
|
||||
@ -109,7 +119,7 @@ void MergeCodeLabels (CodeSeg* S);
|
||||
|
||||
unsigned GetCodeSegEntries (const CodeSeg* S);
|
||||
/* Return the number of entries for the given code segment */
|
||||
|
||||
|
||||
|
||||
|
||||
/* End of codeseg.h */
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
|
||||
/* common */
|
||||
#include "check.h"
|
||||
#include "xmalloc.h"
|
||||
#include "xsprintf.h"
|
||||
|
||||
@ -42,19 +43,32 @@
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
/* Pointer to current data segment */
|
||||
DataSeg* DS = 0;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
DataSeg* NewDataSeg (void)
|
||||
DataSeg* NewDataSeg (const char* Name)
|
||||
/* Create a new data segment, initialize and return it */
|
||||
{
|
||||
/* Allocate memory */
|
||||
DataSeg* S = xmalloc (sizeof (DataSeg));
|
||||
|
||||
/* Initialize the fields */
|
||||
S->Next = 0;
|
||||
S->Name = xstrdup (Name);
|
||||
InitCollection (&S->Lines);
|
||||
|
||||
/* Return the new struct */
|
||||
@ -67,6 +81,9 @@ void FreeDataSeg (DataSeg* S)
|
||||
/* Free a data segment including all line entries */
|
||||
{
|
||||
unsigned I, Count;
|
||||
|
||||
/* Free the name */
|
||||
xfree (S->Name);
|
||||
|
||||
/* Free the lines */
|
||||
Count = CollCount (&S->Lines);
|
||||
@ -83,6 +100,34 @@ void FreeDataSeg (DataSeg* S)
|
||||
|
||||
|
||||
|
||||
void PushDataSeg (DataSeg* S)
|
||||
/* Push the given data segment onto the stack */
|
||||
{
|
||||
/* Push */
|
||||
S->Next = DS;
|
||||
DS = S;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DataSeg* PopDataSeg (void)
|
||||
/* Remove the current data segment from the stack and return it */
|
||||
{
|
||||
/* Remember the current data segment */
|
||||
DataSeg* S = DS;
|
||||
|
||||
/* Cannot pop on empty stack */
|
||||
PRECONDITION (S != 0);
|
||||
|
||||
/* Pop */
|
||||
DS = S->Next;
|
||||
|
||||
/* Return the popped data segment */
|
||||
return S;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AppendDataSeg (DataSeg* Target, const DataSeg* Source)
|
||||
/* Append the data from Source to Target */
|
||||
{
|
||||
|
@ -54,9 +54,14 @@
|
||||
|
||||
typedef struct DataSeg DataSeg;
|
||||
struct DataSeg {
|
||||
DataSeg* Next; /* Pointer to next DataSeg */
|
||||
char* Name; /* Segment name */
|
||||
Collection Lines; /* List of code lines */
|
||||
};
|
||||
|
||||
/* Pointer to current data segment */
|
||||
extern DataSeg* DS;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -65,12 +70,18 @@ struct DataSeg {
|
||||
|
||||
|
||||
|
||||
DataSeg* NewDataSeg (void);
|
||||
DataSeg* NewDataSeg (const char* Name);
|
||||
/* Create a new data segment, initialize and return it */
|
||||
|
||||
void FreeDataSeg (DataSeg* S);
|
||||
/* Free a data segment including all line entries */
|
||||
|
||||
void PushDataSeg (DataSeg* S);
|
||||
/* Push the given data segment onto the stack */
|
||||
|
||||
DataSeg* PopDataSeg (void);
|
||||
/* Remove the current data segment from the stack and return it */
|
||||
|
||||
void AppendDataSeg (DataSeg* Target, const DataSeg* Source);
|
||||
/* Append the data from Source to Target. */
|
||||
|
||||
|
4767
src/cc65/optimize.c
4767
src/cc65/optimize.c
File diff suppressed because it is too large
Load Diff
@ -1,68 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* optimize.h */
|
||||
/* */
|
||||
/* An optimizer for the cc65 C compiler */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
/* warranty. In no event will the authors be held liable for any damages */
|
||||
/* arising from the use of this software. */
|
||||
/* */
|
||||
/* Permission is granted to anyone to use this software for any purpose, */
|
||||
/* including commercial applications, and to alter it and redistribute it */
|
||||
/* freely, subject to the following restrictions: */
|
||||
/* */
|
||||
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||
/* claim that you wrote the original software. If you use this software */
|
||||
/* in a product, an acknowledgment in the product documentation would be */
|
||||
/* appreciated but is not required. */
|
||||
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||
/* be misrepresented as being the original software. */
|
||||
/* 3. This notice may not be removed or altered from any source */
|
||||
/* distribution. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifndef OPTIMIZE_H
|
||||
#define OPTIMIZE_H
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
/* Bitset of flags that switch the different optimizer passes */
|
||||
extern unsigned long OptDisable;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
void OptDoOpt (void);
|
||||
/* Run the optimizer over the collected stuff */
|
||||
|
||||
|
||||
|
||||
/* End of optimize.h */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user