Skip to content

Commit

Permalink
Adds libraries and scripts to use the cross-compiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsc committed Oct 18, 2017
1 parent 404aa3f commit 668d9a9
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ bin/
gen/
disk/
temp/
compiler/fastbasic-int
compiler/fastbasic-fp
src/basic.asm
fastbasic.atr
*.lib
.hg/
.hg*
26 changes: 21 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ FPCXX=-DFASTBASIC_FP -Igen/fp
INTCXX=-Igen/int

# Cross
CL65OPTS=-g -tatari -Csrc/fastbasic.cfg
CL65OPTS=-g -tatari -Ccompiler/fastbasic.cfg

ATR=fastbasic.atr
PROGS=bin/fb.xex bin/fbi.xex
NATIVE_INT=bin/fastbasic-int
NATIVE_FP=bin/fastbasic
NATIVE_INT=compiler/fastbasic-int
NATIVE_FP=compiler/fastbasic-fp

NATIVES=$(NATIVE_INT) $(NATIVE_FP)

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

# Compiler library files
COMPILER=\
compiler/fastbasic-int\
compiler/fastbasic-int.lib\
compiler/fastbasic-fp\
compiler/fastbasic-fp.lib\

# All Output files
OBJS=$(RT_OBJS_FP) $(IDE_OBJS_FP) $(COMMON_OBJS_FP) $(BAS_OBJS_FP) \
$(RT_OBJS_INT) $(IDE_OBJS_INT) $(COMMON_OBJS_INT) $(BAS_OBJS_INT) \
Expand All @@ -104,10 +111,10 @@ LBLS=$(PROGS:.xex=.lbl) $(SAMPLE_X_BAS:%.bas=bin/%.lbl)
SYNT=gen/synt
CSYNT=gen/csynt

all: $(ATR) $(NATIVES)
all: $(ATR) $(NATIVES) $(COMPILER)

clean:
rm -f $(OBJS) $(LSTS) $(FILES) $(ATR) $(PROGS) $(MAPS) $(LBLS) $(SYNT) $(CSYNT) $(NATIVES)
rm -f $(OBJS) $(LSTS) $(FILES) $(ATR) $(PROGS) $(MAPS) $(LBLS) $(SYNT) $(CSYNT) $(COMPILER)

distclean: clean
rm -f gen/int/basic.asm gen/fp/basic.asm gen/int/basic.cc gen/fp/basic.cc \
Expand Down Expand Up @@ -216,6 +223,15 @@ obj/int/%.o: gen/int/%.asm | obj/int
gen obj obj/fp obj/int gen/fp gen/int bin:
mkdir -p $@

# Library files
compiler/fastbasic-fp.lib: $(RT_OBJS_FP) $(COMMON_OBJS_FP)
rm -f $@
ar65 r $@ $^

compiler/fastbasic-int.lib: $(RT_OBJS_INT) $(COMMON_OBJS_INT)
rm -f $@
ar65 r $@ $^

# Dependencies
obj/fp/parse.o: src/parse.asm gen/fp/basic.asm
obj/int/parse.o: src/parse.asm gen/int/basic.asm
Expand Down
24 changes: 24 additions & 0 deletions compiler/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FastBasic - Fast basic interpreter for the Atari 8-bit computers
Copyright (C) 2017 Daniel Serpell

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>

In addition to the permissions in the GNU General Public License, the
authors give you unlimited permission to link the compiled version of
this file into combinations with other programs, and to distribute those
combinations without any restriction coming from the use of this file.
(The General Public License restrictions do apply in other respects; for
example, they cover modification of the file, and distribution when not
linked into a combine executable.)

2 changes: 2 additions & 0 deletions compiler/USAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
For simple compilation of BAS files to XEX (Atari DOS executable), use the included
compile-fp and compile-int scripts.
20 changes: 20 additions & 0 deletions compiler/compile-fp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
ASM=${1%.*}.asm
XEX=${1%.*}.xex
if [ -z "$1" ]; then
echo "Usage: $0 <basic-file>"
exit 1
fi
if [ "$1" -ef "$ASM" ]; then
echo "Error, input file same as ASM file"
exit 1
fi
if [ "$1" -ef "$XEX" ]; then
echo "Error, input file same as XEX file"
exit 1
fi
echo "Compiling '$1' to assembler '$ASM'."
./fastbasic-fp "$1" "$ASM" || exit 1
echo "Assembling '$ASM' to XEX file '$XEX'."
cl65 -tatari -Cfastbasic.cfg "$ASM" -o "$XEX" fastbasic-fp.lib || exit 1

20 changes: 20 additions & 0 deletions compiler/compile-int
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
ASM=${1%.*}.asm
XEX=${1%.*}.xex
if [ -z "$1" ]; then
echo "Usage: $0 <basic-file>"
exit 1
fi
if [ "$1" -ef "$ASM" ]; then
echo "Error, input file same as ASM file"
exit 1
fi
if [ "$1" -ef "$XEX" ]; then
echo "Error, input file same as XEX file"
exit 1
fi
echo "Compiling '$1' to assembler '$ASM'."
./fastbasic-int "$1" "$ASM" || exit 1
echo "Assembling '$ASM' to XEX file '$XEX'."
cl65 -tatari -Cfastbasic.cfg "$ASM" -o "$XEX" fastbasic-int.lib || exit 1

1 change: 0 additions & 1 deletion src/fastbasic.cfg → compiler/fastbasic.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ FEATURES {
}
SYMBOLS {
__EXEHDR__: type = import;
__AUTOSTART__: type = import; # force inclusion of autostart "trailer"
__STARTADDRESS__: type = export, value = %S;
}
MEMORY {
Expand Down
8 changes: 8 additions & 0 deletions src/exehdr.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
.export __EXEHDR__: absolute = 1
.import __MAIN_START__, __DATA_LOAD__, __DATA_SIZE__
.import __INTERP_START__, __INTERP_SIZE__
.import start

.include "atari.inc"

.segment "EXEHDR"
.word $FFFF
Expand All @@ -15,4 +18,9 @@
.word __INTERP_START__
.word __INTERP_START__ + __INTERP_SIZE__- 1

.segment "AUTOSTRT"
.word RUNAD
.word RUNAD+1
.word start

; vi:syntax=asm_ca65

0 comments on commit 668d9a9

Please sign in to comment.