From 668d9a9a0fecaa707dd9d2ca052c9c6e732e6f3c Mon Sep 17 00:00:00 2001 From: Daniel Serpell Date: Wed, 18 Oct 2017 13:51:09 -0300 Subject: [PATCH] Adds libraries and scripts to use the cross-compiler. --- .gitignore | 3 +++ Makefile | 26 +++++++++++++++++++++----- compiler/LICENSE | 24 ++++++++++++++++++++++++ compiler/USAGE | 2 ++ compiler/compile-fp | 20 ++++++++++++++++++++ compiler/compile-int | 20 ++++++++++++++++++++ {src => compiler}/fastbasic.cfg | 1 - src/exehdr.asm | 8 ++++++++ 8 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 compiler/LICENSE create mode 100644 compiler/USAGE create mode 100755 compiler/compile-fp create mode 100755 compiler/compile-int rename {src => compiler}/fastbasic.cfg (96%) diff --git a/.gitignore b/.gitignore index 0dcb177..c51cf70 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,10 @@ bin/ gen/ disk/ temp/ +compiler/fastbasic-int +compiler/fastbasic-fp src/basic.asm fastbasic.atr +*.lib .hg/ .hg* diff --git a/Makefile b/Makefile index fa3926f..0fffc31 100644 --- a/Makefile +++ b/Makefile @@ -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) @@ -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) \ @@ -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 \ @@ -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 diff --git a/compiler/LICENSE b/compiler/LICENSE new file mode 100644 index 0000000..e159c86 --- /dev/null +++ b/compiler/LICENSE @@ -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 + +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.) + diff --git a/compiler/USAGE b/compiler/USAGE new file mode 100644 index 0000000..fc1a2ce --- /dev/null +++ b/compiler/USAGE @@ -0,0 +1,2 @@ +For simple compilation of BAS files to XEX (Atari DOS executable), use the included +compile-fp and compile-int scripts. diff --git a/compiler/compile-fp b/compiler/compile-fp new file mode 100755 index 0000000..7cbf366 --- /dev/null +++ b/compiler/compile-fp @@ -0,0 +1,20 @@ +#!/bin/sh +ASM=${1%.*}.asm +XEX=${1%.*}.xex +if [ -z "$1" ]; then + echo "Usage: $0 " + 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 + diff --git a/compiler/compile-int b/compiler/compile-int new file mode 100755 index 0000000..3a4a5e6 --- /dev/null +++ b/compiler/compile-int @@ -0,0 +1,20 @@ +#!/bin/sh +ASM=${1%.*}.asm +XEX=${1%.*}.xex +if [ -z "$1" ]; then + echo "Usage: $0 " + 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 + diff --git a/src/fastbasic.cfg b/compiler/fastbasic.cfg similarity index 96% rename from src/fastbasic.cfg rename to compiler/fastbasic.cfg index ee24b94..5bf105f 100644 --- a/src/fastbasic.cfg +++ b/compiler/fastbasic.cfg @@ -24,7 +24,6 @@ FEATURES { } SYMBOLS { __EXEHDR__: type = import; - __AUTOSTART__: type = import; # force inclusion of autostart "trailer" __STARTADDRESS__: type = export, value = %S; } MEMORY { diff --git a/src/exehdr.asm b/src/exehdr.asm index a9f148f..f38fdd4 100644 --- a/src/exehdr.asm +++ b/src/exehdr.asm @@ -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 @@ -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