Skip to content

Commit

Permalink
6800: start to put bits together for 6800 testing
Browse files Browse the repository at this point in the history
  • Loading branch information
EtchedPixels committed Dec 3, 2024
1 parent cc09ac2 commit 0f1b9e1
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 93 deletions.
8 changes: 4 additions & 4 deletions Kernel/cpu-6800/rules.mk
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export CROSS_AS=as68
export CROSS_LD= ld68
export CROSS_CC = cc68
export CROSS_AS=fcc -x -m6800 -c
export CROSS_LD=ld6800
export CROSS_CC=fcc
export CROSS_CCOPTS= -m6800 -X -c -I$(ROOT_DIR)/cpu-6800 -I$(ROOT_DIR)/platform/platform-$(TARGET) -I$(ROOT_DIR)/include
export CROSS_CC_SEG1=
export CROSS_CC_SEG2=
export CROSS_CC_SEG3=
export CROSS_CC_SEGDISC= --code-name discard --rodata-name discard
export CROSS_CC_SEGDISC= -Tdiscard
export CROSS_CC_VIDEO=
export CROSS_CC_FONT=
export CROSS_CC_NETWORK=
Expand Down
8 changes: 8 additions & 0 deletions Library/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ ifeq ($(USERCPU),6303)
install -m 0644 ../Kernel/include/userstructs.h include/sys/
install -m 0644 ../Kernel/include/drivewire.h include/sys/
endif
ifeq ($(USERCPU),6800)
install -m 0644 ../Kernel/include/userstructs.h include/sys/
install -m 0644 ../Kernel/include/drivewire.h include/sys/
endif
ifeq ($(USERCPU),6803)
install -m 0644 ../Kernel/include/userstructs.h include/sys/
install -m 0644 ../Kernel/include/drivewire.h include/sys/
endif
ifeq ($(USERCPU),ns32k)
install -m 0644 ../Kernel/include/userstructs.h include/sys/
endif
Expand Down
2 changes: 1 addition & 1 deletion Library/include/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

extern int signgam;

#if !defined(double) && !defined(__m6809__)
#if !defined(double) && !defined(__m6809__) && !defined(NO_64BIT)

/* Compiler with full float/double support */

Expand Down
197 changes: 122 additions & 75 deletions Library/libs/Makefile.6800
Original file line number Diff line number Diff line change
@@ -1,52 +1,53 @@
CC = cc68 -X -m6800
ASM = as68
CC = fcc -m6800
ASM = fcc -m6800
AR = ar
LINKER = ld68
CC_OPT = -D__STDC__ -c -I../include/ -I../include/6800/
CC_NOOPT = -D__STDC__ -c -I../include/ -I../include/6800/
ASM_OPT =
LINKER_OPT =
SRC_CRT0 = crt0_6800.s crt0nostdio_6800.s
PLATFORM = 6800
export PLATFORM
CC_OPT = -c -I$(shell pwd)/../include -I$(shell pwd)/../include/$(PLATFORM) -X -Os
ASM_OPT = -c -o
# copied in from kernel tree
KRN_HEADERS = userstructs.h drivewire.h
KRN_HEADERS_SRC = $(addprefix ../../Kernel/include/,$(KRN_HEADERS))
KRN_HEADERS_COPY = $(addprefix ../include/sys/,$(KRN_HEADERS))
SRC_CRT0 = crt0_$(PLATFORM).s crt0nostdio_$(PLATFORM).s
OBJ_CRT0 = $(SRC_CRT0:.s=.o)
SRC_ASM = longjmp_6800.s setjmp_6800.s
SRC_ASM = setjmp_$(PLATFORM).s longjmp_$(PLATFORM).s
OBJ_ASM = $(SRC_ASM:.s=.o)
#
# Library routines.
#
SRC_C = __argv.c abort.c accept.c aes256.c asctime.c asctime_r.c assert.c atexit.c
SRC_C += basename.c bcmp.c bcopy.c bind.c bsearch.c bzero.c
SRC_C += calloc.c cfree.c clock.c closedir.c
SRC_C += closedir_r.c clock_gettime.c clock_getres.c clock_settime.c
SRC_C += calloc.c cfree.c clock.c closedir.c closedir_r.c
SRC_C += clock_gettime.c clock_getres.c clock_settime.c
SRC_C += connect.c creat.c crypt.c ctermid.c ctime.c cuserid.c
SRC_C += dirname.c
SRC_C += err.c errno.c error.c
SRC_C += execl.c execv.c execvp.c exit.c
SRC_C += fclose.c fgetc.c fgetgrent.c fgetpwent.c
SRC_C += fclose.c fdatasync.c fgetc.c fgetgrent.c fgetpwent.c
SRC_C += fgetpos.c fgets.c fopen.c fork.c fprintf.c fputc.c fputs.c fread.c
SRC_C += fsetpos.c ftell.c ftruncate.c fwrite.c getcwd.c
SRC_C += getenv.c __getgrent.c getgrgid.c getgrnam.c getloadavg.c getopt.c
SRC_C += getpeername.c getpw.c __getpwent.c getpwnam.c getpwuid.c
SRC_C += fsetpos.c fsync.c ftell.c ftruncate.c fwrite.c getcwd.c
SRC_C += getenv.c __getgrent.c getgrgid.c getgrnam.c getloadavg.c getlogin.c
SRC_C += getopt.c getpeername.c
SRC_C += getpw.c __getpwent.c getpwnam.c getpwuid.c
SRC_C += gets.c getsockname.c gettimeofday.c
SRC_C += getw.c gmtime.c gmtime_r.c grent.c htons.c htonl.c index.c
SRC_C += getw.c gmtime.c gmtime_r.c grent.c htons.c htonl.c
SRC_C += inet_addr.c inet_aton.c inet_network.c inet_ntoa.c inet_ntop.c inet_pton.c
SRC_C += initgroups.c isatty.c killpg.c libintl.c
SRC_C += index.c initgroups.c isatty.c killpg.c
SRC_C += libintl.c listen.c
SRC_C += localtim.c localtim_r.c lseek.c lsearch.c lstat.c ltoa.c ltostr.c
SRC_C += malloc.c memmove.c mkfifo.c mkstemps.c mntent.o nanosleep.c
SRC_C += malloc.c mkfifo.c mkstemps.c mntent.o nanosleep.c
SRC_C += opendir.c opendir_r.c pause.c perror.c
SRC_C += popen.c printf.c putenv.c putgetch.c putpwent.c putw.c pwent.c qsort.c
SRC_C += popen.c printf.c putenv.c putchar.c putpwent.c putw.c pwent.c qsort.c
SRC_C += raise.c rand.c readdir.c readlink.c realloc.c recvfrom.c regerror.c
SRC_C += regsub.c remove.c remount.c rewind.c rindex.c rootmntent.c
SRC_C += seekdir.c setbuffer.c setenv.c
SRC_C += setlocale.c sendto.c setvbuf.c settimeofday.c sgetl.c
SRC_C += shutdown.c sigdisp.c sleep.c socket.c sprintf.c
SRC_C += sputl.c stat.c statvfs.c stdio0.c stime.c
SRC_C += regsub.c remount.c remove.c rewind.c rewinddir.c rindex.c rootmntent.c
SRC_C += seekdir.c sendto.c setbuffer.c setenv.c
SRC_C += setlocale.c setvbuf.c settimeofday.c sgetl.c shutdown.c sigdisp.c sleep.c
SRC_C += socket.c sprintf.c sputl.c stat.c statvfs.c stdio0.c stime.c
SRC_C += strcasecmp.c strcasestr.c strdup.c stricmp.c strlcpy.c strncasecmp.c
SRC_C += strnicmp.c strnlen.c strsep.c strsignal.c swab.c swapon.c
SRC_C += system.c telldir.c time.c tmpfile.c tmpnam.c ttyname.c
SRC_C += strnlen.c strnicmp.c strsep.c strxfrm.c strcoll.c strsignal.c
SRC_C += strtod.c strtol.c swab.c swapon.c system.c
SRC_C += telldir.c time.c tmpfile.c tmpnam.c ttyname.c
SRC_C += tzset.c umount.c ungetc.c usleep.c utent.c utimes.c utsname.c
SRC_C += vfork.c vfprintf.c vprintf.c wait.c xitoa.c pathconf.c
SRC_C += gethostname.c sysconf.c confstr.c memccpy.c getpass.c
SRC_C += strtok_r.c strtol.c
# ctype
SRC_C += isalnum.c isalpha.c isascii.c isblank.c iscntrl.c isdigit.c
SRC_C += isgraph.c islower.c isprint.c ispunct.c isspace.c isupper.c
Expand All @@ -56,80 +57,126 @@ SRC_C += tcgetattr.c tcsetattr.c tcdrain.c tcflow.c tcflush.c
SRC_C += cfmakeraw.c cfspeed.c revoke.c
# scanf
SRC_C += fscanf.c scanf.c sscanf.c vfscanf.c vscanf.c vsscanf.c
# regexp is a good compiler test!
SRC_C += regexp.c
SRC_C += strcpy.c strlen.c abs.c atoi.c atol.c labs.c
# Pieces we inherit in this case from the compiler library instead
SRC_C += strcpy.c strlen.c abs.c atof.c atoi.c atol.c labs.c
SRC_C += strcat.c strchr.c strcmp.c strcspn.c strncat.c strncmp.c
SRC_C += strncpy.c strpbrk.c strrchr.c strspn.c strstr.c strtok.c
SRC_C += memchr.c memcmp.c memcpy.c memset.c
SRC_C += strncpy.c strpbrk.c strrchr.c strspn.c strstr.c strtok.c strtok_r.c
SRC_C += memchr.c memcmp.c memcpy.c memset.c memmove.c

SRC_CT += termcap.c tgetent.c

SRC_TC += termcap.c tgetent.c
SRC_CURS = $(shell find curses -name '*.c')

SRC_RL = readline.c readline_fn.c

SRC_LM += acosf.c acoshf.c asinf.c asinhf.c atan2f.c atanf.c atanhf.c
SRC_LM += cbrtf.c ceilf.c copysignf.c erff.c expf.c expm1f.c
SRC_LM += fabsf.c fdimf.c floorf.c fmaxf.c fminf.c fmodf.c frexpf.c
SRC_LM += hypotf.c ilogbf.c j0f.c j1f.c jnf.c
SRC_LM += ldexpf.c lgammaf.c lgammaf_r.c logf.c log2f.c log10f.c logbf.c
SRC_LM += lrintf.c lroundf.c
SRC_LM += modff.c nearbyintf.c nextafterf.c powf.c
SRC_LM += remainderf.c remquof.c rintf.c roundf.c
SRC_LM += scalbnf.c scalbln.c
SRC_LM += sinf.c sincosf.c sinhf.c
SRC_LM += sqrtf.c tgammaf.c
SRC_LM += vfscanf_m.c vfprintf_m.c
SRC_LM += __expo2f.c __float_bits.c __fpclassifyf.c __log1pf.c __signgam.c
SRC_LM += mathhelper.c

OBJ_C = $(SRC_C:.c=.o)
OBJ_CURS = $(SRC_CURS:.c=.o)
OBJ_TC = $(SRC_TC:.c=.o)
OBJ_CT = $(SRC_CT:.c=.o)
OBJ_RL = $(SRC_RL:.c=.o)
OBJ_LM = $(SRC_LM:.c=.o)
OBJ_ALL = $(OBJ_ASM) $(OBJ_C) $(OBJ_LM) $(OBJ_RL)

OBJ_C = $(SRC_C:.c=.o)
OBJ_HARD = $(SRC_HARD:.c=.o)
OBJ_ALL = $(OBJ_ASM) $(OBJ_C) $(OBJ_HARD) $(OBJ_TC) $(OBJ_RL) $(OBJ_CURS)
all: syslib$(PLATFORM).lib liberror.txt $(OBJ_CRT0) curses$(PLATFORM).lib \
termcap$(PLATFORM).lib readline$(PLATFORM).lib m$(PLATFORM).lib crt0.o

# $(OBJ_ALL): $(KRN_HEADERS_COPY)

$(KRN_HEADERS_COPY): $(KRN_HEADERS_SRC)
cp ../../Kernel/include/$(notdir $@) $@

libc.l:%.l:$(OBJ_C) $(OBJ_ASM)
ls $(OBJ_C) $(OBJ_ASM) > libc.l

syscall.l: fuzix$(PLATFORM)/syslib.l
../tools/syscall_$(PLATFORM)
(cd fuzix$(PLATFORM); make)
cat fuzix$(PLATFORM)/syslib.l | tr " " "\\n" | sed -e "s/^/fuzix$(PLATFORM)\//" >syscall.l

syslib$(PLATFORM).lib: syscall.l libc.l
cat libc.l syscall.l >syslib.l
$(AR) rc syslib$(PLATFORM).lib `lorder$(PLATFORM) $$(cat syslib.l) | tsort`
ln -sf syslib$(PLATFORM).lib libc$(PLATFORM).a
cp libc$(PLATFORM).a libc.a

all: syslib.lib termcap.lib curses.lib readline.lib liberror.txt \
crt0_6800.o crt0nostdio_6800.o
crt0.o: crt0_$(PLATFORM).o
cp crt0_$(PLATFORM).o crt0.o

.PHONY: fuzix6800/Makefile
fuzix$(PLATFORM)/syslib.l: ../tools/syscall_$(PLATFORM)
$<
make -C fuzix$(PLATFORM)

fuzix6800/Makefile: ../tools/syscall_6800.c ../../Kernel/include/syscall_name.h
(cd ..; make tools/syscall_6800)
../tools/syscall_6800
../tools/syscall_$(PLATFORM): ../tools/syscall_$(PLATFORM).c
make -C .. tools/syscall_$(PLATFORM)

syslib.lib: fuzix6800/Makefile $(OBJ_ALL)
(cd fuzix6800; make)
$(AR) cr syslib.lib $(OBJ_ALL)
ln -sf syslib.lib libc6800.a
liberror.txt: ../tools/liberror
$< > $@

termcap.lib: fuzix6800/Makefile $(OBJ_TC)
$(AR) cr termcap.lib $(OBJ_TC)
ln -sf termcap.lib libtermcap6800.a
../tools/liberror: ../tools/liberror.c
make -C .. tools/liberror

readline.lib: fuzix6800/Makefile $(OBJ_RL)
$(AR) cr readline.lib $(OBJ_RL)
ln -sf readline.lib libreadline6800.a
curses$(PLATFORM).lib: $(OBJ_CURS)
$(AR) rc curses$(PLATFORM).lib `lorder$(PLATFORM) $(OBJ_CURS) | tsort`
ln -sf curses$(PLATFORM).lib libcurses$(PLATFORM).a
cp libcurses$(PLATFORM).a libcurses.a

curses.lib: fuzix6800/Makefile $(OBJ_CURS)
$(AR) cr curses.lib $(OBJ_CURS)
ln -sf curses.lib libcurses6800.a
termcap$(PLATFORM).lib: $(OBJ_CT)
$(AR) rc termcap$(PLATFORM).lib `lorder$(PLATFORM) $(OBJ_CT) | tsort`
ln -sf termcap$(PLATFORM).lib libtermcap$(PLATFORM).a
cp libtermcap$(PLATFORM).a libtermcap.a

liberror.txt:
../tools/liberror -X > liberror.txt
m$(PLATFORM).lib: $(OBJ_LM)
$(AR) rc m$(PLATFORM).lib `lorder$(PLATFORM) $(OBJ_LM) | tsort`
ln -sf m$(PLATFORM).lib libm$(PLATFORM).a
cp libm$(PLATFORM).a libm.a

readline$(PLATFORM).lib: $(OBJ_RL)
$(AR) rc readline$(PLATFORM).lib `lorder$(PLATFORM) $(OBJ_RL) | tsort`
ln -sf readline$(PLATFORM).lib libreadline$(PLATFORM).a
cp libreadline$(PLATFORM).a libreadline.a

$(OBJ_ASM):%.o: %.s
$(ASM) $(ASM_OPT) $(@:.o=.s)
$(ASM) $(ASM_OPT) $@ $(@:.o=.s)

$(OBJ_CRT0):%.o: %.s
$(ASM) $(ASM_OPT) $(@:.o=.s)
$(ASM) $(ASM_OPT) $@ $(@:.o=.s)

$(OBJ_C):%.o: %.c
$(CC) $(CC_OPT) $(@:.o=.c)

$(OBJ_TC):%.o: %.c
$(CC) $(CC_OPT) $(@:.o=.c)

$(OBJ_RL):%.o: %.c
$(OBJ_CT):%.o: %.c
$(CC) $(CC_OPT) $(@:.o=.c)

$(OBJ_CURS):%.o: %.c
$(CC) $(CC_OPT) $(@:.o=.c)
$(CC) $(CC_OPT) $(@:.o=.c) -o $@

$(OBJ_HARD):%.o: %.c
$(CC) $(CC_NOOPT) $(@:.o=.c)
$(OBJ_LM):%.o: %.c
$(CC) $(CC_OPT) -DBUILD_LIBM $(@:.o=.c) -o $@

clean:
rm -rf *.o *.lib *~ syscall.l libc.l syslib.l liberror.txt *.a
(cd curses; rm -rf *.rel *.asm *.sym *.lst *~ *.o)
(cd fuzix6800; make clean)
$(OBJ_RL):%.o: %.c
$(CC) $(CC_OPT) $(@:.o=.c)

# Blank for now until we sort stuff out properly for 6800
install:
clean:
rm -rf *.o *.lib *~ syscall.l libc.l syslib.l \
lib*.a liberror.txt
-cd fuzix$(PLATFORM) && make clean
rm -rf fuzix$(PLATFORM)/Makefile
rm -f $(KRN_HEADERS_COPY)
-cd curses && rm -rf *.o *~

install: ;
2 changes: 0 additions & 2 deletions Library/libs/crt0_6800.s
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ start:
stab @zero+1
incb
stab @one+1
ldab #0x7E
stab @jmptmp
jsr ___stdio_init_vars
tsx
inx
Expand Down
2 changes: 1 addition & 1 deletion Library/link/ld6800
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ done
set -e
#
# With
cc68 -m6800 -tfuzix -s $ARGS -o "$TARGET" -M
fcc -s -m6800 $ARGS -o "$TARGET" -M
2 changes: 1 addition & 1 deletion Library/tools/syscall_6800.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static void write_makefile(void)
fprintf(fp, "\techo $(AOBJS) >syslib.l\n");
fprintf(fp, "\tar rc ../syslib.lib $(AOBJS)\n\n");
fprintf(fp, "$(AOBJS): %%.o: %%.s\n");
fprintf(fp, "\tas68 $<\n\n");
fprintf(fp, "\tfcc -m6800 -c -o $*.o $<\n\n");
fprintf(fp, "clean:\n");
fprintf(fp, "\trm -f $(AOBJS) $(ASRCS) *~\n\n");
fclose(fp);
Expand Down
4 changes: 2 additions & 2 deletions Target/rules.6800
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CC = cc68
AS = as68
CC = fcc -m6800
AS = fcc -m6800
LINKER = $(FUZIX_ROOT)/Library/link/ld6800
CFLAGS = -X -m6800 -D__STDC__ -c -I$(FUZIX_ROOT)/Library/include -I$(FUZIX_ROOT)/Library/include/6800
LINKER_OPT =
Expand Down
9 changes: 2 additions & 7 deletions Tools/build-6800
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
#!/bin/sh

X=`which as68`
X=`which fcc`
if [ "$X" = "" ]; then
(cd ../Applications/assembler; make -f Cross.6800)
fi

X=`which cc68`
if [ "$X" = "" ]; then
echo "CC68 is required: see https://github.com/EtchedPixels/CC6303/"
echo "fcc is required: see https://github.com/EtchedPixels/FuzixCompilerKit/"
exit 1
fi

0 comments on commit 0f1b9e1

Please sign in to comment.