1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-11 11:30:13 +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:
cuz 2001-05-01 16:57:43 +00:00
parent 88792854a6
commit 239cbdcb2b
6 changed files with 59 additions and 39 deletions

View File

@ -64,12 +64,7 @@ void AddCodeHint (const char* 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 GetCodeSegEntries (CS);
}

View File

@ -49,8 +49,6 @@
#include "cpu.h"
#include "error.h"
#include "global.h"
#include "litpool.h"
/* ### #include "optimize.h" */
#include "segname.h"
#include "util.h"
#include "codegen.h"
@ -191,18 +189,6 @@ void g_preamble (void)
/* Define long branch macros */
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 */
/*****************************************************************************/

View File

@ -37,7 +37,7 @@
#define CODEGEN_H
/* ##### */
#include "dataseg.h"
#include "codeseg.h"
@ -101,9 +101,6 @@ extern CodeSeg* CS;
void g_preamble (void);
/* 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 */
/*****************************************************************************/

View File

@ -486,9 +486,6 @@ void DelCodeSegAfter (CodeSeg* S, unsigned Last)
/* Get the number of entries in this segment */
unsigned Count = CollCount (&S->Entries);
/* Must not be called with count zero */
CHECK (Count > 0 && Count >= Last);
/* Remove all entries after the given one */
while (Last < Count) {

View File

@ -744,11 +744,7 @@ void doasm (void)
* looks like the one defined for C++ (C has no ASM directive), that is,
* a string literal in parenthesis.
*/
{
/* ########## */
Error ("Currently unavailable");
#if 0
{
/* Skip the ASM */
NextToken ();
@ -759,8 +755,25 @@ void doasm (void)
if (curtok != TOK_SCONST) {
Error ("String literal expected");
} 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
* string table. Since we're working with one token lookahead, this
@ -775,7 +788,6 @@ void doasm (void)
/* Closing paren needed */
ConsumeRParen ();
#endif
}

View File

@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 1998 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* (C) 1998-2001 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */