From 81c86f0d2db5702bbea9fba2ced299f85f9aa99b Mon Sep 17 00:00:00 2001 From: mpabi Date: Wed, 3 Jul 2024 16:14:36 +0000 Subject: [PATCH] init --- makefile | 7 ++++--- src/main.cpp | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/makefile b/makefile index 33b7f24..551c235 100644 --- a/makefile +++ b/makefile @@ -5,7 +5,8 @@ MULDIV=no SRCS = $(wildcard src/*.c) \ $(wildcard src/*.cpp) \ - $(wildcard src/*.S) + $(wildcard src/*.S) \ + src/stub_stdlib.c OBJDIR = build @@ -39,8 +40,8 @@ ifeq ($(COMPRESSED),yes) MARCH := $(MARCH)ac endif -CFLAGS += -march=$(MARCH) -mabi=$(MABI) -DNDEBUG -LDFLAGS += -march=$(MARCH) -mabi=$(MABI) +CFLAGS += -march=$(MARCH) -mabi=$(MABI) -DNDEBUG -std=c++11 -fno-pic -ffreestanding +LDFLAGS += -march=$(MARCH) -mabi=$(MABI) -lc -lgcc -nostdlib -nostartfiles -nostartfiles diff --git a/src/main.cpp b/src/main.cpp index aa04a57..e087ca3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,6 +14,8 @@ #include "murax.h" #include +#include +#include void print(const char*str){ while(*str){ @@ -46,6 +48,14 @@ private: }; const Timer_Reg* TimeR::ptr = reinterpret_cast(0xF0020040); + + + + + + + + // --- @@ -64,8 +74,32 @@ int len( const char * str) { */ int32_t ile = 0; +int myfunc(const char *s) +{ + int i = 0; + + // sum up all the character codes in the string + while (*s) + i += *s++; + + return i; +} + + +void test (std::initializer_list vals) { + char buffer[50]; + + for (auto p = vals.begin(); p != vals.end(); ++p) { + std::sprintf(buffer, "%d\n", *p); + // printf("%s", buffer); + } + +} + int main() { + char str[10] = {1,2,3}; + myfunc(str); // println("hello world arty a7 v1");