From: Alan Cox Date: Wed, 22 Nov 2017 17:53:07 +0000 (+0000) Subject: 6502; Build smallC on 6502 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=985f1e1b06aa35598ecdd9042908d4fe1e89bccc;p=FUZIX.git 6502; Build smallC on 6502 --- diff --git a/Applications/SmallC/Makefile.6502 b/Applications/SmallC/Makefile.6502 new file mode 100644 index 00000000..a007d673 --- /dev/null +++ b/Applications/SmallC/Makefile.6502 @@ -0,0 +1,59 @@ +PLATFORM = 6502 +CC = cl65 +ASM = ca65 +LINKER = cl65 +CFLAGS = -t none -O -D__STDC__ -c -O -I../../Library/include -I../../Library/include/6502 +LINKER_OPT = -L../../Library/libs -C ../../Library/libs/ld65-$(TARGET).cfg +ASM_OPT = -o +CRT0 = ../../Library/libs/crt0_6502.o +CRT0NS = ../../Library/libs/crt0nostdio_6502.o + +.SUFFIXES: .c .o + +SRC = initials.c data.c error.c expr.c function.c gen.c io.c \ + lex.c main.c outstack.c preproc.c primary.c stmt.c \ + struct.c sym.c while.c +OBJ = $(SRC:.c=.o) + +SRC_Z80 = codez80.c +SRC_8080 = code8080.c +SRC_6801 = code6801.c +SRC_6809 = code6809.c + +SRC_COPT = copt.c +SRC_CC = frontend.c + +OBJ_Z80 = $(SRC_Z80:.c=.o) +OBJ_8080 = $(SRC_8080:.c=.o) +OBJ_6801 = $(SRC_6801:.c=.o) +OBJ_6809 = $(SRC_6809:.c=.o) + +OBJ_COPT = $(SRC_COPT:.c=.o) +OBJ_CC = $(SRC_CC:.c=.o) + +INC = data.h defs.h prototype.h + +all: scc6801 scc6809 scc8080 sccz80 copt cc + +sccz80: $(OBJ) $(OBJ_Z80) + $(LINKER) -o $@ $(LINKER_OPT) $(CRT0) $^ c6502.lib -m $@.map + +scc8080: $(OBJ) $(OBJ_8080) + $(LINKER) -o $@ $(LINKER_OPT) $(CRT0) $^ c6502.lib -m $@.map + +scc6801: $(OBJ) $(OBJ_6801) + $(LINKER) -o $@ $(LINKER_OPT) $(CRT0) $^ c6502.lib -m $@.map + +scc6809: $(OBJ) $(OBJ_6809) + $(LINKER) -o $@ $(LINKER_OPT) $(CRT0) $^ c6502.lib -m $@.map + +copt: $(OBJ_COPT) + $(LINKER) -o $@ $(LINKER_OPT) $(CRT0) $^ c6502.lib -m $@.map + +cc: $(OBJ_CC) + $(LINKER) -o $@ $(LINKER_OPT) $(CRT0) $^ c6502.lib -m $@.map + + +clean realclean clobber: + rm -f *.o sccz80 scc8080 scc6801 copt cc + diff --git a/Applications/SmallC/copt.c b/Applications/SmallC/copt.c index b3c4546a..05755148 100644 --- a/Applications/SmallC/copt.c +++ b/Applications/SmallC/copt.c @@ -550,9 +550,10 @@ static int match(char *ins, char *pat) /* * Substitute variables in a string */ +static char buf[MAXLINE]; + static char *subst(char *pat) { - char buf[MAXLINE]; char *cp, *cp1, *cp2, *varptr; long num; int i = 0; diff --git a/Applications/SmallC/gen.c b/Applications/SmallC/gen.c index 4b61f669..0e484a44 100644 --- a/Applications/SmallC/gen.c +++ b/Applications/SmallC/gen.c @@ -79,7 +79,7 @@ int output_byte(char c) { * @param ptr the string * @return */ -void output_string(char ptr[]) { +void output_string(char *ptr) { int k; k = 0; while (output_byte (ptr[k++])); @@ -98,7 +98,7 @@ void print_tab(void) { * @param ptr * @return */ -void output_line(char ptr[]) +void output_line(char *ptr) { output_with_tab (ptr); newline (); @@ -109,7 +109,7 @@ void output_line(char ptr[]) * @param ptr * @return */ -void output_with_tab(char ptr[]) { +void output_with_tab(char *ptr) { print_tab (); output_string (ptr); } diff --git a/Applications/SmallC/prototype.h b/Applications/SmallC/prototype.h index de27a991..fdec3fae 100644 --- a/Applications/SmallC/prototype.h +++ b/Applications/SmallC/prototype.h @@ -105,11 +105,11 @@ extern void print_label(int label); extern void glabel(char *lab); extern void generate_label(int nlab); extern int output_byte(char c); -extern void output_string(char ptr[]); -extern void output_label_name(char ptr[]); +extern void output_string(char *ptr); +extern void output_label_name(char *ptr); extern void print_tab(void); -extern void output_line(char ptr[]); -extern void output_with_tab(char ptr[]); +extern void output_line(char *ptr); +extern void output_with_tab(char *ptr); extern void output_decimal(int number); extern void store(LVALUE *lval); extern int rvalue(LVALUE *lval, int reg);