From fd67284b4d1cc3b759da4a00ae175f68c01bd00f Mon Sep 17 00:00:00 2001 From: AIDA Shinra Date: Tue, 12 Jun 2018 02:06:01 +0900 Subject: [PATCH] Followed the discussions in the Pull request #682. * Fixed a misspelling * Fixed styles * Added sample codes --- doc/da65.sgml | 2 +- src/da65/global.c | 1 + src/da65/global.h | 1 + src/da65/main.c | 2 +- src/da65/scanner.c | 17 ++++++++--------- src/da65/scanner.h | 2 -- testcode/disasm/.gitignore | 2 ++ testcode/disasm/bank0.da | 16 ++++++++++++++++ testcode/disasm/bank0.dai | 33 +++++++++++++++++++++++++++++++++ testcode/disasm/bank1.da | 16 ++++++++++++++++ testcode/disasm/bank1.dai | 33 +++++++++++++++++++++++++++++++++ testcode/disasm/fixed.da | 30 ++++++++++++++++++++++++++++++ testcode/disasm/fixed.dai | 25 +++++++++++++++++++++++++ testcode/disasm/sample-unix.mk | 28 ++++++++++++++++++++++++++++ 14 files changed, 195 insertions(+), 13 deletions(-) create mode 100644 testcode/disasm/.gitignore create mode 100644 testcode/disasm/bank0.da create mode 100644 testcode/disasm/bank0.dai create mode 100644 testcode/disasm/bank1.da create mode 100644 testcode/disasm/bank1.dai create mode 100644 testcode/disasm/fixed.da create mode 100644 testcode/disasm/fixed.dai create mode 100644 testcode/disasm/sample-unix.mk diff --git a/doc/da65.sgml b/doc/da65.sgml index c59840389..05154ffd8 100644 --- a/doc/da65.sgml +++ b/doc/da65.sgml @@ -312,7 +312,7 @@ anything). Each attribute is terminated by a semicolon. Comments

-Comments start with a hash mark (//); +Comments start with a hash mark (//); and, extend from the position of the mark to the end of the current line. Hash marks or double slashes inside of strings will [""] (C preprocessor input) - * - # "" []... (gcc preprocessor output) - * - # - */ +** - #line [""] (C preprocessor input) +** - # "" []... (gcc preprocessor output) +** - # +*/ { unsigned long LineNo = 0; int LineDirective = 0; StrBuf SrcNameBuf = AUTO_STRBUF_INITIALIZER; - + /* Skip the first "# " */ NextChar (); SkipBlanks (1); @@ -440,7 +439,7 @@ Again: case '#': /* # lineno "sourcefile" or # comment */ - if (InfoSyncLines && InputCol == 1) { + if (SyncLines && InputCol == 1) { LineMarkerOrComment (); } else { do { diff --git a/src/da65/scanner.h b/src/da65/scanner.h index b1dc75279..d4e38177b 100644 --- a/src/da65/scanner.h +++ b/src/da65/scanner.h @@ -138,8 +138,6 @@ extern long InfoIVal; extern unsigned InfoErrorLine; extern unsigned InfoErrorCol; -/* Options */ -extern unsigned char InfoSyncLines; /*****************************************************************************/ diff --git a/testcode/disasm/.gitignore b/testcode/disasm/.gitignore new file mode 100644 index 000000000..46c4eca80 --- /dev/null +++ b/testcode/disasm/.gitignore @@ -0,0 +1,2 @@ +*.s +image.bin diff --git a/testcode/disasm/bank0.da b/testcode/disasm/bank0.da new file mode 100644 index 000000000..4fb96ce93 --- /dev/null +++ b/testcode/disasm/bank0.da @@ -0,0 +1,16 @@ +// 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; }; diff --git a/testcode/disasm/bank0.dai b/testcode/disasm/bank0.dai new file mode 100644 index 000000000..2d865e77c --- /dev/null +++ b/testcode/disasm/bank0.dai @@ -0,0 +1,33 @@ +# 1 "bank0.da" +# 1 "" +# 1 "" +# 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; }; diff --git a/testcode/disasm/bank1.da b/testcode/disasm/bank1.da new file mode 100644 index 000000000..fd5e324a9 --- /dev/null +++ b/testcode/disasm/bank1.da @@ -0,0 +1,16 @@ +// 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"; }; diff --git a/testcode/disasm/bank1.dai b/testcode/disasm/bank1.dai new file mode 100644 index 000000000..2b5b68532 --- /dev/null +++ b/testcode/disasm/bank1.dai @@ -0,0 +1,33 @@ +# 1 "bank1.da" +# 1 "" +# 1 "" +# 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"; }; diff --git a/testcode/disasm/fixed.da b/testcode/disasm/fixed.da new file mode 100644 index 000000000..e8aa03427 --- /dev/null +++ b/testcode/disasm/fixed.da @@ -0,0 +1,30 @@ +// 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) */ diff --git a/testcode/disasm/fixed.dai b/testcode/disasm/fixed.dai new file mode 100644 index 000000000..d73155cf0 --- /dev/null +++ b/testcode/disasm/fixed.dai @@ -0,0 +1,25 @@ +# 1 "fixed.da" +# 1 "" +# 1 "" +# 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; }; diff --git a/testcode/disasm/sample-unix.mk b/testcode/disasm/sample-unix.mk new file mode 100644 index 000000000..0ef64a5e5 --- /dev/null +++ b/testcode/disasm/sample-unix.mk @@ -0,0 +1,28 @@ +# 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 -- 2.39.5