diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..8320b8b --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,17 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**", + "/home/franchioping/NSpire/Ndless/ndless-sdk/include/*" + ], + "defines": [], + "compilerPath": "/usr/bin/clang", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "linux-gcc-arm" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/source/main.S b/source/main.S index a78047b..af709f2 100644 --- a/source/main.S +++ b/source/main.S @@ -12,6 +12,7 @@ main: mov r9, sp sub sp, sp, #s_SIZE // Reserve space for state ADDED + mov r4, #0 mov r6, #s_SIZE 1: subs r6, r6, #4 @@ -19,6 +20,9 @@ main: bne 1b str r5, [r9, #s_saved_sp] + + + @ Get our folder path add r4, r9, #s_path mov r2, r4 diff --git a/testing/.buildver b/testing/.buildver new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/testing/.buildver @@ -0,0 +1 @@ +5 diff --git a/testing/Makefile b/testing/Makefile new file mode 100644 index 0000000..e0b1951 --- /dev/null +++ b/testing/Makefile @@ -0,0 +1,61 @@ +DEBUG = FALSE + +BLD_FILE ?= .buildver + +# Initiate BLD_FILE if not exists +buildver_create := $(shell if ! test -f $(BLD_FILE); then echo 0 > $(BLD_FILE); fi) + +# Prepare callable function. This function updates BLD_FILE +buildver = $(shell echo $$(($$(cat $(BLD_FILE)) + 1)) > $(BLD_FILE)) + +VER = buildver + +GCC = nspire-gcc +AS = nspire-as +GXX = nspire-g++ +LD = nspire-ld +GENZEHN = genzehn + +EXE = nespire_mod_$(shell cat $(BLD_FILE)) + + +GCCFLAGS = -Wall -W -marm +LDFLAGS = +ZEHNFLAGS = --name "$(EXE)" + +ifeq ($(DEBUG),FALSE) + GCCFLAGS += -Os +else + GCCFLAGS += -O0 -g +endif + +OBJS = $(patsubst %.c, %.o, $(shell find . -name \*.c)) +OBJS += $(patsubst %.cpp, %.o, $(shell find . -name \*.cpp)) +OBJS += $(patsubst %.S, %.o, $(shell find . -name \*.S)) +DISTDIR = . +vpath %.tns $(DISTDIR) +vpath %.elf $(DISTDIR) + +all: $(EXE).tns + +%.o: %.c + $(GCC) $(GCCFLAGS) -c $< -o $@ + +%.o: %.cpp + $(GXX) $(GCCFLAGS) -c $< -o $@ + +%.o: %.S + $(AS) -c $< -o $@ + +$(EXE).elf: $(OBJS) + mkdir -p $(DISTDIR) + $(LD) $^ -o $@ $(LDFLAGS) + +$(EXE).tns: $(EXE).elf + $(GENZEHN) --input $^ --output $@.zehn $(ZEHNFLAGS) + $(call buildver) + make-prg $@.zehn $@ + rm $@.zehn + +clean: + rm -f $(OBJS) $(DISTDIR)/$(EXE).tns $(DISTDIR)/$(EXE).elf $(DISTDIR)/$(EXE).zehn nespire_mod_*.elf nespire_mod_*.tns diff --git a/testing/arm_util.S b/testing/arm_util.S new file mode 100644 index 0000000..c46e942 --- /dev/null +++ b/testing/arm_util.S @@ -0,0 +1,3 @@ +.global arm_util_stuff +arm_util_stuff: + bx lr \ No newline at end of file diff --git a/testing/arm_util.o b/testing/arm_util.o new file mode 100644 index 0000000..191a51f Binary files /dev/null and b/testing/arm_util.o differ diff --git a/testing/main.S b/testing/main.S new file mode 100644 index 0000000..ace053c --- /dev/null +++ b/testing/main.S @@ -0,0 +1,17 @@ +.extern arm_util_stuff + + +.global main +main: + push {r4-r11, lr} + mov r9, sp + + + bl util_stuff + + + mov sp, r9 + pop {r4-r11, pc} + + + diff --git a/testing/main.o b/testing/main.o new file mode 100644 index 0000000..6e4780c Binary files /dev/null and b/testing/main.o differ diff --git a/testing/nespire_mod_4.elf b/testing/nespire_mod_4.elf new file mode 100755 index 0000000..420d315 Binary files /dev/null and b/testing/nespire_mod_4.elf differ diff --git a/testing/nespire_mod_4.tns b/testing/nespire_mod_4.tns new file mode 100644 index 0000000..252a048 Binary files /dev/null and b/testing/nespire_mod_4.tns differ diff --git a/testing/util.c b/testing/util.c new file mode 100644 index 0000000..3bd0c4f --- /dev/null +++ b/testing/util.c @@ -0,0 +1,16 @@ +#include +#include +#include +#include +#include + +void util_stuff(); + +void util_stuff(){ + + printf("Hello World!\n"); + + + wait_key_pressed(); + return; +} \ No newline at end of file diff --git a/testing/util.o b/testing/util.o new file mode 100644 index 0000000..0406eaf Binary files /dev/null and b/testing/util.o differ