summaryrefslogtreecommitdiffstats
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sw/z80/crt0.s.old43
-rw-r--r--sw/z80/kernel.c7
-rw-r--r--sw/z80/loader.asm18
-rw-r--r--sw/z80/makefile27
-rw-r--r--sw/z80/serial.h15
-rw-r--r--sw/z80/types.h9
-rw-r--r--sw/z80/zcc_opt.def6
7 files changed, 125 insertions, 0 deletions
diff --git a/sw/z80/crt0.s.old b/sw/z80/crt0.s.old
new file mode 100644
index 0000000..f3bf8e8
--- /dev/null
+++ b/sw/z80/crt0.s.old
@@ -0,0 +1,43 @@
+ .module crt0
+ .globl _main
+
+ .area _HEADER (ABS)
+;; reset vector
+ .org 0x0000
+ jp init
+
+ .org 0x0100
+
+init:
+;; Stack at the top of memory.
+ ld sp,#0xffff
+
+ ;; initialise global variables
+ call gsinit
+ call _main
+ jp _exit
+
+ ;; Ordering of segments for the linker.
+ .area _HOME
+ .area _CODE
+ .area _GSINIT
+ .area _GSFINAL
+
+ .area _DATA
+ .area _BSS
+ .area _HEAP
+
+ .area _CODE
+__clock::
+ ret
+
+_exit::
+ ret
+
+ .area _GSINIT
+
+gsinit::
+
+.area _GSFINAL
+ ret
+
diff --git a/sw/z80/kernel.c b/sw/z80/kernel.c
new file mode 100644
index 0000000..172eee1
--- /dev/null
+++ b/sw/z80/kernel.c
@@ -0,0 +1,7 @@
+#include "types.h"
+
+
+void main(void)
+{
+
+}
diff --git a/sw/z80/loader.asm b/sw/z80/loader.asm
new file mode 100644
index 0000000..85f5abe
--- /dev/null
+++ b/sw/z80/loader.asm
@@ -0,0 +1,18 @@
+; C crt0 loader
+;
+ module crt0
+
+; general scope declarations
+ extern _main ; C code
+
+; startup code
+ org 0000h ; reset vector
+ jp _start
+
+_start:
+ ld sp, 0xffff
+ call _main
+ jp _exit
+
+_exit:
+ ret
diff --git a/sw/z80/makefile b/sw/z80/makefile
new file mode 100644
index 0000000..94646a9
--- /dev/null
+++ b/sw/z80/makefile
@@ -0,0 +1,27 @@
+####
+# source code settings
+#
+OSNAME := helvetiOS
+
+CSOURCES := $(wildcard *.c)
+BINARY := $(OSNAME).bin
+
+###
+# compiler settings
+#
+CC := zcc
+CARGS := -Wall -I . -DDEBUG -crt0 loader -asm z80asm -nostdlib
+
+all: $(BINARY)
+
+# build binary
+$(BINARY): $(CSOURCES)
+ cp loader.asm loader.opt
+ $(CC) $(CARGS) $(CSOURCES) -o $@
+
+dis: $(BINARY)
+ z80dasm -a -g 0h $<
+
+clean:
+ - rm $(BINARY)
+ - rm loader.opt
diff --git a/sw/z80/serial.h b/sw/z80/serial.h
new file mode 100644
index 0000000..3dc9b18
--- /dev/null
+++ b/sw/z80/serial.h
@@ -0,0 +1,15 @@
+#ifndef __SERIAL_H__
+#define __SERIAL_H__
+
+#include "types.h"
+
+// define all
+#define USART_BAUD_9600
+#define USART_BAUD_115200
+
+uint8_t usart_registers[8];
+usart_registers = 0x80FF; // TODO: set real address
+
+void usart_init(int16_t baudprescale);
+
+#endif
diff --git a/sw/z80/types.h b/sw/z80/types.h
new file mode 100644
index 0000000..adde214
--- /dev/null
+++ b/sw/z80/types.h
@@ -0,0 +1,9 @@
+#ifndef __TYPES_H__
+#define __TYPES_H__
+
+#define int8_t char
+#define uint8_t unsigned char
+#define int16_t int
+#define uint16_t unsigned int
+
+#endif
diff --git a/sw/z80/zcc_opt.def b/sw/z80/zcc_opt.def
new file mode 100644
index 0000000..de830a9
--- /dev/null
+++ b/sw/z80/zcc_opt.def
@@ -0,0 +1,6 @@
+
+IF !DEFINED_startup
+ defc DEFINED_startup = 1
+ defc startup = 1
+ENDIF
+