Skip to content

Commit 668d9a9

Browse files
committed
Adds libraries and scripts to use the cross-compiler.
1 parent 404aa3f commit 668d9a9

File tree

8 files changed

+98
-6
lines changed

8 files changed

+98
-6
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ bin/
33
gen/
44
disk/
55
temp/
6+
compiler/fastbasic-int
7+
compiler/fastbasic-fp
68
src/basic.asm
79
fastbasic.atr
10+
*.lib
811
.hg/
912
.hg*

Makefile

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ FPCXX=-DFASTBASIC_FP -Igen/fp
88
INTCXX=-Igen/int
99

1010
# Cross
11-
CL65OPTS=-g -tatari -Csrc/fastbasic.cfg
11+
CL65OPTS=-g -tatari -Ccompiler/fastbasic.cfg
1212

1313
ATR=fastbasic.atr
1414
PROGS=bin/fb.xex bin/fbi.xex
15-
NATIVE_INT=bin/fastbasic-int
16-
NATIVE_FP=bin/fastbasic
15+
NATIVE_INT=compiler/fastbasic-int
16+
NATIVE_FP=compiler/fastbasic-fp
1717

1818
NATIVES=$(NATIVE_INT) $(NATIVE_FP)
1919

@@ -93,6 +93,13 @@ COMMON_OBJS_INT=$(COMMON_AS_SRC:src/%.asm=obj/int/%.o)
9393
BAS_OBJS_INT=$(BAS_SRC:src/%.bas=obj/int/%.o)
9494
SAMP_OBJS=$(SAMPLE_BAS:%.bas=obj/%.o)
9595

96+
# Compiler library files
97+
COMPILER=\
98+
compiler/fastbasic-int\
99+
compiler/fastbasic-int.lib\
100+
compiler/fastbasic-fp\
101+
compiler/fastbasic-fp.lib\
102+
96103
# All Output files
97104
OBJS=$(RT_OBJS_FP) $(IDE_OBJS_FP) $(COMMON_OBJS_FP) $(BAS_OBJS_FP) \
98105
$(RT_OBJS_INT) $(IDE_OBJS_INT) $(COMMON_OBJS_INT) $(BAS_OBJS_INT) \
@@ -104,10 +111,10 @@ LBLS=$(PROGS:.xex=.lbl) $(SAMPLE_X_BAS:%.bas=bin/%.lbl)
104111
SYNT=gen/synt
105112
CSYNT=gen/csynt
106113

107-
all: $(ATR) $(NATIVES)
114+
all: $(ATR) $(NATIVES) $(COMPILER)
108115

109116
clean:
110-
rm -f $(OBJS) $(LSTS) $(FILES) $(ATR) $(PROGS) $(MAPS) $(LBLS) $(SYNT) $(CSYNT) $(NATIVES)
117+
rm -f $(OBJS) $(LSTS) $(FILES) $(ATR) $(PROGS) $(MAPS) $(LBLS) $(SYNT) $(CSYNT) $(COMPILER)
111118

112119
distclean: clean
113120
rm -f gen/int/basic.asm gen/fp/basic.asm gen/int/basic.cc gen/fp/basic.cc \
@@ -216,6 +223,15 @@ obj/int/%.o: gen/int/%.asm | obj/int
216223
gen obj obj/fp obj/int gen/fp gen/int bin:
217224
mkdir -p $@
218225

226+
# Library files
227+
compiler/fastbasic-fp.lib: $(RT_OBJS_FP) $(COMMON_OBJS_FP)
228+
rm -f $@
229+
ar65 r $@ $^
230+
231+
compiler/fastbasic-int.lib: $(RT_OBJS_INT) $(COMMON_OBJS_INT)
232+
rm -f $@
233+
ar65 r $@ $^
234+
219235
# Dependencies
220236
obj/fp/parse.o: src/parse.asm gen/fp/basic.asm
221237
obj/int/parse.o: src/parse.asm gen/int/basic.asm

compiler/LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FastBasic - Fast basic interpreter for the Atari 8-bit computers
2+
Copyright (C) 2017 Daniel Serpell
3+
4+
This program is free software; you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation, either version 2 of the License, or
7+
(at your option) any later version.
8+
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License along
15+
with this program. If not, see <http://www.gnu.org/licenses/>
16+
17+
In addition to the permissions in the GNU General Public License, the
18+
authors give you unlimited permission to link the compiled version of
19+
this file into combinations with other programs, and to distribute those
20+
combinations without any restriction coming from the use of this file.
21+
(The General Public License restrictions do apply in other respects; for
22+
example, they cover modification of the file, and distribution when not
23+
linked into a combine executable.)
24+

compiler/USAGE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
For simple compilation of BAS files to XEX (Atari DOS executable), use the included
2+
compile-fp and compile-int scripts.

compiler/compile-fp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
ASM=${1%.*}.asm
3+
XEX=${1%.*}.xex
4+
if [ -z "$1" ]; then
5+
echo "Usage: $0 <basic-file>"
6+
exit 1
7+
fi
8+
if [ "$1" -ef "$ASM" ]; then
9+
echo "Error, input file same as ASM file"
10+
exit 1
11+
fi
12+
if [ "$1" -ef "$XEX" ]; then
13+
echo "Error, input file same as XEX file"
14+
exit 1
15+
fi
16+
echo "Compiling '$1' to assembler '$ASM'."
17+
./fastbasic-fp "$1" "$ASM" || exit 1
18+
echo "Assembling '$ASM' to XEX file '$XEX'."
19+
cl65 -tatari -Cfastbasic.cfg "$ASM" -o "$XEX" fastbasic-fp.lib || exit 1
20+

compiler/compile-int

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
ASM=${1%.*}.asm
3+
XEX=${1%.*}.xex
4+
if [ -z "$1" ]; then
5+
echo "Usage: $0 <basic-file>"
6+
exit 1
7+
fi
8+
if [ "$1" -ef "$ASM" ]; then
9+
echo "Error, input file same as ASM file"
10+
exit 1
11+
fi
12+
if [ "$1" -ef "$XEX" ]; then
13+
echo "Error, input file same as XEX file"
14+
exit 1
15+
fi
16+
echo "Compiling '$1' to assembler '$ASM'."
17+
./fastbasic-int "$1" "$ASM" || exit 1
18+
echo "Assembling '$ASM' to XEX file '$XEX'."
19+
cl65 -tatari -Cfastbasic.cfg "$ASM" -o "$XEX" fastbasic-int.lib || exit 1
20+

src/fastbasic.cfg renamed to compiler/fastbasic.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ FEATURES {
2424
}
2525
SYMBOLS {
2626
__EXEHDR__: type = import;
27-
__AUTOSTART__: type = import; # force inclusion of autostart "trailer"
2827
__STARTADDRESS__: type = export, value = %S;
2928
}
3029
MEMORY {

src/exehdr.asm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
.export __EXEHDR__: absolute = 1
44
.import __MAIN_START__, __DATA_LOAD__, __DATA_SIZE__
55
.import __INTERP_START__, __INTERP_SIZE__
6+
.import start
7+
8+
.include "atari.inc"
69

710
.segment "EXEHDR"
811
.word $FFFF
@@ -15,4 +18,9 @@
1518
.word __INTERP_START__
1619
.word __INTERP_START__ + __INTERP_SIZE__- 1
1720

21+
.segment "AUTOSTRT"
22+
.word RUNAD
23+
.word RUNAD+1
24+
.word start
25+
1826
; vi:syntax=asm_ca65

0 commit comments

Comments
 (0)