6502; Build smallC on 6502
authorAlan Cox <alan@linux.intel.com>
Wed, 22 Nov 2017 17:53:07 +0000 (17:53 +0000)
committerAlan Cox <alan@linux.intel.com>
Wed, 22 Nov 2017 17:53:07 +0000 (17:53 +0000)
Applications/SmallC/Makefile.6502 [new file with mode: 0644]
Applications/SmallC/copt.c
Applications/SmallC/gen.c
Applications/SmallC/prototype.h

diff --git a/Applications/SmallC/Makefile.6502 b/Applications/SmallC/Makefile.6502
new file mode 100644 (file)
index 0000000..a007d67
--- /dev/null
@@ -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
+
index b3c4546..0575514 100644 (file)
@@ -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;
index 4b61f66..0e484a4 100644 (file)
@@ -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);
 }
index de27a99..fdec3fa 100644 (file)
@@ -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);