mirror of
https://github.com/cc65/cc65.git
synced 2025-08-11 11:25:08 +00:00
Working on the backend
git-svn-id: svn://svn.cc65.org/cc65/trunk@702 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -64,12 +64,7 @@ void AddCodeHint (const char* Hint)
|
|||||||
CodeMark GetCodePos (void)
|
CodeMark GetCodePos (void)
|
||||||
/* Get a marker pointing to the current output position */
|
/* Get a marker pointing to the current output position */
|
||||||
{
|
{
|
||||||
unsigned EntryCount = GetCodeSegEntries (CS);
|
return GetCodeSegEntries (CS);
|
||||||
|
|
||||||
/* This function should never be called without any code output */
|
|
||||||
CHECK (EntryCount > 0);
|
|
||||||
|
|
||||||
return EntryCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -49,8 +49,6 @@
|
|||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "litpool.h"
|
|
||||||
/* ### #include "optimize.h" */
|
|
||||||
#include "segname.h"
|
#include "segname.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "codegen.h"
|
#include "codegen.h"
|
||||||
@@ -191,18 +189,6 @@ void g_preamble (void)
|
|||||||
|
|
||||||
/* Define long branch macros */
|
/* Define long branch macros */
|
||||||
AddCodeLine (".macpack\tlongbranch");
|
AddCodeLine (".macpack\tlongbranch");
|
||||||
|
|
||||||
/* Tell the optimizer that this is the end of the preamble */
|
|
||||||
AddCodeHint ("end_of_preamble");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void g_postamble (void)
|
|
||||||
/* Generate assembler code postamble */
|
|
||||||
{
|
|
||||||
/* Tell the optimizer that this is the start of the postamble */
|
|
||||||
AddCodeHint ("start_of_postamble");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3938,6 +3924,26 @@ void g_zerobytes (unsigned n)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* User supplied assembler code */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void g_asmcode (const char* Line, int Len)
|
||||||
|
/* Output one line of assembler code. If Len is greater than zero, it is used
|
||||||
|
* as the maximum number of characters to use from Line.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
if (Len >= 0) {
|
||||||
|
AddCodeSegLine (CS, "%.*s", Len, Line);
|
||||||
|
} else {
|
||||||
|
AddCodeSegLine (CS, "%s", Line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Inlined known functions */
|
/* Inlined known functions */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@@ -37,7 +37,7 @@
|
|||||||
#define CODEGEN_H
|
#define CODEGEN_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ##### */
|
/* ##### */
|
||||||
#include "dataseg.h"
|
#include "dataseg.h"
|
||||||
#include "codeseg.h"
|
#include "codeseg.h"
|
||||||
@@ -101,9 +101,6 @@ extern CodeSeg* CS;
|
|||||||
void g_preamble (void);
|
void g_preamble (void);
|
||||||
/* Generate the assembler code preamble */
|
/* Generate the assembler code preamble */
|
||||||
|
|
||||||
void g_postamble (void);
|
|
||||||
/* Generate assembler code postamble */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -450,6 +447,19 @@ void g_zerobytes (unsigned n);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* User supplied assembler code */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void g_asmcode (const char* Line, int Len);
|
||||||
|
/* Output one line of assembler code. If Len is greater than zero, it is used
|
||||||
|
* as the maximum number of characters to use from Line.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Inlined known functions */
|
/* Inlined known functions */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@@ -486,9 +486,6 @@ void DelCodeSegAfter (CodeSeg* S, unsigned Last)
|
|||||||
/* Get the number of entries in this segment */
|
/* Get the number of entries in this segment */
|
||||||
unsigned Count = CollCount (&S->Entries);
|
unsigned Count = CollCount (&S->Entries);
|
||||||
|
|
||||||
/* Must not be called with count zero */
|
|
||||||
CHECK (Count > 0 && Count >= Last);
|
|
||||||
|
|
||||||
/* Remove all entries after the given one */
|
/* Remove all entries after the given one */
|
||||||
while (Last < Count) {
|
while (Last < Count) {
|
||||||
|
|
||||||
|
@@ -744,11 +744,7 @@ void doasm (void)
|
|||||||
* looks like the one defined for C++ (C has no ASM directive), that is,
|
* looks like the one defined for C++ (C has no ASM directive), that is,
|
||||||
* a string literal in parenthesis.
|
* a string literal in parenthesis.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
/* ########## */
|
|
||||||
Error ("Currently unavailable");
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Skip the ASM */
|
/* Skip the ASM */
|
||||||
NextToken ();
|
NextToken ();
|
||||||
|
|
||||||
@@ -759,8 +755,25 @@ void doasm (void)
|
|||||||
if (curtok != TOK_SCONST) {
|
if (curtok != TOK_SCONST) {
|
||||||
Error ("String literal expected");
|
Error ("String literal expected");
|
||||||
} else {
|
} else {
|
||||||
/* Write the string directly into the output, followed by a newline */
|
|
||||||
AddCodeLine (GetLiteral (curval));
|
/* The string literal may consist of more than one line of assembler
|
||||||
|
* code. Separate the single lines and output the code.
|
||||||
|
*/
|
||||||
|
const char* S = GetLiteral (curval);
|
||||||
|
while (*S) {
|
||||||
|
|
||||||
|
/* Allow lines up to 256 bytes */
|
||||||
|
const char* E = strchr (S, '\n');
|
||||||
|
if (E) {
|
||||||
|
/* Found a newline */
|
||||||
|
g_asmcode (S, E-S);
|
||||||
|
S = E+1;
|
||||||
|
} else {
|
||||||
|
int Len = strlen (S);
|
||||||
|
g_asmcode (S, Len);
|
||||||
|
S += Len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Reset the string pointer, effectivly clearing the string from the
|
/* Reset the string pointer, effectivly clearing the string from the
|
||||||
* string table. Since we're working with one token lookahead, this
|
* string table. Since we're working with one token lookahead, this
|
||||||
@@ -775,7 +788,6 @@ void doasm (void)
|
|||||||
|
|
||||||
/* Closing paren needed */
|
/* Closing paren needed */
|
||||||
ConsumeRParen ();
|
ConsumeRParen ();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998 Ullrich von Bassewitz */
|
/* (C) 1998-2001 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* Wacholderweg 14 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70597 Stuttgart */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
|
Reference in New Issue
Block a user