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);
}
#include "cpu.h"
#include "error.h"
#include "global.h"
-#include "litpool.h"
-/* ### #include "optimize.h" */
#include "segname.h"
#include "util.h"
#include "codegen.h"
/* 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");
}
+/*****************************************************************************/
+/* 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 */
/*****************************************************************************/
#define CODEGEN_H
-
+
/* ##### */
#include "dataseg.h"
#include "codeseg.h"
void g_preamble (void);
/* Generate the assembler code preamble */
-void g_postamble (void);
-/* Generate assembler code postamble */
-
/*****************************************************************************/
+/*****************************************************************************/
+/* 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 */
/*****************************************************************************/
/* 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) {
* 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 ();
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
/* Closing paren needed */
ConsumeRParen ();
-#endif
}
/* */
/* */
/* */
-/* (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 */