diff options
author | Nao Pross <naopross@thearcway.org> | 2017-05-02 00:06:10 +0200 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2017-05-02 00:06:10 +0200 |
commit | 752e0fd9ec166ea8a513294fd44b7203af03d684 (patch) | |
tree | 94f6000ed20ef39bfdd3f85caad801a6e53ba072 | |
parent | Merge branch 'master' of https://github.com/NaoPross/z80uPC (diff) | |
download | z80uPC-752e0fd9ec166ea8a513294fd44b7203af03d684.tar.gz z80uPC-752e0fd9ec166ea8a513294fd44b7203af03d684.zip |
switch to sdcc
- update of the makefile to use sdcc, since it is more popular and
it's easier to insall on other computers
- fix of crt0.s (old loader.asm) for the new compiler
- change of the structure in the source code folder to separate
betweeen libc and kernel code
Diffstat (limited to '')
-rw-r--r-- | sw/z80/crt0.s | 30 | ||||
-rw-r--r-- | sw/z80/crt0.s.old | 43 | ||||
-rw-r--r-- | sw/z80/kernel.c | 7 | ||||
-rw-r--r-- | sw/z80/kernel/include/types.h (renamed from sw/z80/types.h) | 0 | ||||
-rw-r--r-- | sw/z80/kernel/kernel.c | 10 | ||||
-rw-r--r-- | sw/z80/loader.asm | 18 | ||||
-rw-r--r-- | sw/z80/makefile | 34 | ||||
-rw-r--r-- | sw/z80/serial.h | 15 | ||||
-rw-r--r-- | sw/z80/zcc_opt.def | 6 |
9 files changed, 62 insertions, 101 deletions
diff --git a/sw/z80/crt0.s b/sw/z80/crt0.s new file mode 100644 index 0000000..d0ae3ca --- /dev/null +++ b/sw/z80/crt0.s @@ -0,0 +1,30 @@ + .area _HEADER (ABS) + ;; reset vector + .org 0 + jp init + + .org 0x08 + reti + .org 0x10 + reti + .org 0x18 + reti + .org 0x20 + reti + .org 0x28 + reti + .org 0x30 + reti + .org 0x38 + reti + + .org 0x100 + +init: + ;; set stack + ld sp,#0xFFFF + + ;; call C main function + call _main + +.globl _main diff --git a/sw/z80/crt0.s.old b/sw/z80/crt0.s.old deleted file mode 100644 index f3bf8e8..0000000 --- a/sw/z80/crt0.s.old +++ /dev/null @@ -1,43 +0,0 @@ - .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 deleted file mode 100644 index 172eee1..0000000 --- a/sw/z80/kernel.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "types.h" - - -void main(void) -{ - -} diff --git a/sw/z80/types.h b/sw/z80/kernel/include/types.h index adde214..adde214 100644 --- a/sw/z80/types.h +++ b/sw/z80/kernel/include/types.h diff --git a/sw/z80/kernel/kernel.c b/sw/z80/kernel/kernel.c new file mode 100644 index 0000000..fe87c3d --- /dev/null +++ b/sw/z80/kernel/kernel.c @@ -0,0 +1,10 @@ +#include "types.h" + + +void main(void) +{ + int i, j = 20; + for (i = 0; i < 10; i++) { + j--; + } +} diff --git a/sw/z80/loader.asm b/sw/z80/loader.asm deleted file mode 100644 index 85f5abe..0000000 --- a/sw/z80/loader.asm +++ /dev/null @@ -1,18 +0,0 @@ -; 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 index 94646a9..ecdd9a4 100644 --- a/sw/z80/makefile +++ b/sw/z80/makefile @@ -2,26 +2,36 @@ # source code settings # OSNAME := helvetiOS - -CSOURCES := $(wildcard *.c) -BINARY := $(OSNAME).bin + +CSOURCES := $(wildcard kernel/*.c) $(wildcard libc/*.c) +HEXFILE := build/$(OSNAME).hex +BINARY := build/$(OSNAME).bin ### # compiler settings -# -CC := zcc -CARGS := -Wall -I . -DDEBUG -crt0 loader -asm z80asm -nostdlib + +CC := sdcc + +CFLAGS := -mz80 --no-std-crt0 crt0.rel \ + -I kernel/include -I libc/include -DDEBUG + +LDFLAGS := --code-loc 0x0800 --data-loc 0x8000 all: $(BINARY) # build binary -$(BINARY): $(CSOURCES) - cp loader.asm loader.opt - $(CC) $(CARGS) $(CSOURCES) -o $@ +$(BINARY): $(CSOURCES) crt0.rel + mkdir -p build + $(CC) $(CFLAGS) $(LDFLSGS) $(CSOURCES) -o $(HEXFILE) + xxd -r -p $(HEXFILE) $(BINARY) + +crt0.rel: crt0.s + sdasz80 -o $< dis: $(BINARY) - z80dasm -a -g 0h $< + z80dasm -a -g 0h $< -o $(OSNAME).s clean: - - rm $(BINARY) - - rm loader.opt + - rm build/* + - rm $(OSNAME).s + - rm crt0.rel diff --git a/sw/z80/serial.h b/sw/z80/serial.h deleted file mode 100644 index 3dc9b18..0000000 --- a/sw/z80/serial.h +++ /dev/null @@ -1,15 +0,0 @@ -#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/zcc_opt.def b/sw/z80/zcc_opt.def deleted file mode 100644 index de830a9..0000000 --- a/sw/z80/zcc_opt.def +++ /dev/null @@ -1,6 +0,0 @@ - -IF !DEFINED_startup - defc DEFINED_startup = 1 - defc startup = 1 -ENDIF - |