<sect1>Comments<p>
-Comments start with a hash mark (<tt/#/) or a double slashe (<tt>//</tt>);
+Comments start with a hash mark (<tt/#/) or a double slash (<tt>//</tt>);
and, extend from the position of the mark to the end of the current line.
Hash marks or double slashes inside of strings will <em/not/ start a comment,
of course.
signed char NewlineAfterJMP = -1; /* Add a newline after a JMP insn? */
signed char NewlineAfterRTS = -1; /* Add a newline after a RTS insn? */
long StartAddr = -1L; /* Start/load address of the program */
+unsigned char SyncLines = 0; /* Accept line markers in the info file */
long InputOffs = -1L; /* Offset into input file */
long InputSize = -1L; /* Number of bytes to read from input */
extern signed char NewlineAfterJMP;/* Add a newline after a JMP insn? */
extern signed char NewlineAfterRTS;/* Add a newline after a RTS insn? */
extern long StartAddr; /* Start/load address of the program */
+extern unsigned char SyncLines; /* Accept line markers in the info file */
extern long InputOffs; /* Offset into input file */
extern long InputSize; /* Number of bytes to read from input */
const char* Arg attribute ((unused)))
/* Handle the --sync-lines option */
{
- InfoSyncLines = 1;
+ SyncLines = 1;
}
static FILE* InputFile = 0;
static char* InputSrcName = 0;
-/* Options */
-unsigned char InfoSyncLines = 0;
/*****************************************************************************/
+
/*****************************************************************************/
/* Code */
/*****************************************************************************/
}
}
-static long GetDecimalToken ()
+static long GetDecimalToken (void)
{
long Value = 0;
static void LineMarkerOrComment ()
/* Handle a line beginning with '#'. Possible interpretations are:
- * - #line <lineno> ["<filename>"] (C preprocessor input)
- * - # <lineno> "<filename>" [<flag>]... (gcc preprocessor output)
- * - #<comment>
- */
+** - #line <lineno> ["<filename>"] (C preprocessor input)
+** - # <lineno> "<filename>" [<flag>]... (gcc preprocessor output)
+** - #<comment>
+*/
{
unsigned long LineNo = 0;
int LineDirective = 0;
StrBuf SrcNameBuf = AUTO_STRBUF_INITIALIZER;
-
+
/* Skip the first "# " */
NextChar ();
SkipBlanks (1);
case '#':
/* # lineno "sourcefile" or # comment */
- if (InfoSyncLines && InputCol == 1) {
+ if (SyncLines && InputCol == 1) {
LineMarkerOrComment ();
} else {
do {
extern unsigned InfoErrorLine;
extern unsigned InfoErrorCol;
-/* Options */
-extern unsigned char InfoSyncLines;
/*****************************************************************************/
--- /dev/null
+*.s
+image.bin
--- /dev/null
+// Da65 input file before preprocessed by cpp
+// Bank0 ROM map
+
+#define TARGET_BANK 0
+global {
+ inputoffs $00010;
+ inputsize $4000;
+ startaddr $8000;
+ cpu "6502";
+};
+
+#include "fixed.da"
+
+label { addr $8000; name "Bank0ProcA"; };
+label { addr $8123; name "Bank0ProcB"; };
+range { start $A000; end $BFFF; name "Bank0Data"; type ByteTable; };
--- /dev/null
+# 1 "bank0.da"
+# 1 "<built-in>"
+# 1 "<command-line>"
+# 1 "bank0.da"
+
+
+
+
+global {
+ inputoffs $00010;
+ inputsize $4000;
+ startaddr $8000;
+ cpu "6502";
+};
+
+# 1 "fixed.da" 1
+# 18 "fixed.da"
+label { addr $00; name "VariableA"; };
+label { addr $01; name "VariableB"; };
+label { addr $0100; name "Stack"; size $0100; };
+
+
+
+
+
+label { addr $C000; name "CommonProcA"; };
+label { addr $C123; name "CommonProcB"; };
+range { start $E123; end $FFFF; name "CommonData"; type ByteTable; };
+# 13 "bank0.da" 2
+
+label { addr $8000; name "Bank0ProcA"; };
+label { addr $8123; name "Bank0ProcB"; };
+range { start $A000; end $BFFF; name "Bank0Data"; type ByteTable; };
--- /dev/null
+// Da65 input file before preprocessed by cpp
+// Bank1 ROM map
+
+#define TARGET_BANK 1
+global {
+ inputoffs $04010;
+ inputsize $4000;
+ startaddr $8000;
+ cpu "6502";
+};
+
+#include "fixed.da"
+
+range { start $8000; end $AFFF; name "Bank1Data"; type ByteTable; };
+label { addr $B000; name "Bank1ProcA"; };
+label { addr $B123; name "Bank1ProcB"; };
--- /dev/null
+# 1 "bank1.da"
+# 1 "<built-in>"
+# 1 "<command-line>"
+# 1 "bank1.da"
+
+
+
+
+global {
+ inputoffs $04010;
+ inputsize $4000;
+ startaddr $8000;
+ cpu "6502";
+};
+
+# 1 "fixed.da" 1
+# 18 "fixed.da"
+label { addr $00; name "VariableA"; };
+label { addr $01; name "VariableB"; };
+label { addr $0100; name "Stack"; size $0100; };
+
+
+
+
+
+label { addr $C000; name "CommonProcA"; };
+label { addr $C123; name "CommonProcB"; };
+range { start $E123; end $FFFF; name "CommonData"; type ByteTable; };
+# 13 "bank1.da" 2
+
+range { start $8000; end $AFFF; name "Bank1Data"; type ByteTable; };
+label { addr $B000; name "Bank1ProcA"; };
+label { addr $B123; name "Bank1ProcB"; };
--- /dev/null
+// Da65 input file before preprocessed by cpp
+// RAM and Fixed ROM map
+
+#ifndef FIXED_DA_INCLUDED
+#define FIXED_DA_INCLUDED
+
+#ifndef TARGET_BANK
+#define TARGET_BANK -1
+global {
+ inputoffs $1C010;
+ inputsize $4000;
+ startaddr $C000;
+ cpu "6502";
+};
+#endif /* !defined(TARGET_BANK) */
+
+// ---- RAM map ----
+label { addr $00; name "VariableA"; };
+label { addr $01; name "VariableB"; };
+label { addr $0100; name "Stack"; size $0100; };
+#if defined(TEST_ERROR) && TARGET_BANK == 0
+erroneous_line;
+#endif
+
+// ---- Fixed ROM map ----
+label { addr $C000; name "CommonProcA"; };
+label { addr $C123; name "CommonProcB"; };
+range { start $E123; end $FFFF; name "CommonData"; type ByteTable; };
+
+#endif /* !defined(FIXED_DA_INCLUDED) */
--- /dev/null
+# 1 "fixed.da"
+# 1 "<built-in>"
+# 1 "<command-line>"
+# 1 "fixed.da"
+# 9 "fixed.da"
+global {
+ inputoffs $1C010;
+ inputsize $4000;
+ startaddr $C000;
+ cpu "6502";
+};
+
+
+
+label { addr $00; name "VariableA"; };
+label { addr $01; name "VariableB"; };
+label { addr $0100; name "Stack"; size $0100; };
+
+
+
+
+
+label { addr $C000; name "CommonProcA"; };
+label { addr $C123; name "CommonProcB"; };
+range { start $E123; end $FFFF; name "CommonData"; type ByteTable; };
--- /dev/null
+# Sample makefile using a preprocessor against info files
+# and the --sync-lines option
+
+CPP = env LANG=C cpp
+CPPFLAGS = # -DTEST_ERROR
+
+ASMS = fixed.s bank0.s bank1.s
+DAIS = fixed.dai bank0.dai bank1.dai
+
+.SUFFIXES: .da .dai .s
+.PHONY: all clean maintainer-clean
+.SECONDARY: $(DAIS)
+
+.da.dai:
+ $(CPP) -o $@ $(CPPFLAGS) $<
+
+.dai.s:
+ da65 --sync-lines -o $@ -i $< image.bin
+
+all: $(ASMS)
+
+clean:
+ rm -f $(ASMS)
+
+maintainer-clean: clean
+ rm -f $(DAIS)
+
+$(DAIS): fixed.da