004
22.02.2014, 12:30 Uhr
Hobi
|
Ich habe die Makefiles aufgeräumt, Startupcode angepasst und alles mal zusammengebaut. Am besten man benutzt Cygwin als Entwicklungsumgebung.
Z1013 Bibliotheken und Beispiele
sdasz80 mit Bugfix
Makefile:
Quellcode: | OUT=printf OBJECTS=printf.rel
include ../lib/z1013_app.make |
printf.c:
Quellcode: | #include <stdio.h>
void main() { printf("Hello World!\n"); } |
app.make:
Quellcode: | obj/$(OUT).z80 : ../lib/z1013/crt0.rel ../lib/z1013/z1013.lib $(OBJS) $(LINK) -mjwx -b _CODE=0x0100 -i "obj/$(OUT).ihx" -k ../lib/z1013 -l z80 $^ objcopy -Iihex -Obinary "obj/$(OUT).ihx" "$@" echo -n $(OUT) >obj/filename.txt dd bs=1 if=obj/filename.txt of="$@" seek=16 conv=notrunc hexdump -C "$@" obj/%.rel : src/%.c obj sdcc -mz80 -c -o "$@" -Iinclude -I../include $(CFLAGS) "$<"
obj/%.rel : src/%.s obj $(AS) -plosgff "$@" "$<"
|
startup code:
Quellcode: | .module crt0 .globl _main
.area _HEADER (ABS) ;preparing "headersave" file header attached to the final rom image as loadable .z80 format .org 0xe0 .dw s__CODE .dw start_of_stackframe .dw init .ascii 'sdccz80' .db 0xd3,0xd3,0xd3 .ascii ' ' ;; Ordering of segments for the linker. .area _HOME .area _CODE .area _INITIALIZER .area _GSINIT .area _GSFINAL .area _GSEXIT .area _GSEXITFINAL .area _DATA .area _INITIALIZED .area _BSEG .area _BSS .area _STACK .area _HEAP .area _CODE _monitor_entry .equ 0xf05f init: ;; Stack at the top of memory. ld sp,#end_of_stackframe ; mark stack frame ld hl,#0xbbbb ld (#start_of_stackframe),hl push hl ;; Initialise global variables call gsinit call _main call gsexit ld sp,#0x00b0 jp _monitor_entry rst 0x38
.area _GSINIT gsinit:: ld bc, #l__INITIALIZER ld a, b or a, c jr Z, gsinit_next ld de, #s__INITIALIZED ld hl, #s__INITIALIZER ldir gsinit_next:
.area _GSFINAL ret
.area _GSEXIT gsexit::
.area _GSEXITFINAL ret
.area _STACK ;For now just allocate 1k for stack. ; stack frame marker - top start_of_stackframe: .ds 2 .ds 1024 ; stack frame marker - bottom .ds 2 ; z1013 has predecrement stack end_of_stackframe:
.include "rst8.s" |
z1013.lib
Quellcode: | #define PRST7(X) \ __asm__("rst 0x20"); \ __asm__(".db 2 ;PRST7"); \ __asm__(".ascis "#X);
void OUTCH(unsigned char c) { __asm__("ld hl, #2+0"); __asm__("add hl, sp"); __asm__("ld a, (hl)"); __asm__("rst 0x20"); __asm__(".db 0"); }
unsigned char INCH() { __asm__("rst 0x20"); __asm__(".db 1"); __asm__("ld l,a"); }
|
-- ------------------------------------------- Corontäne ------------------------------------------- Dieser Beitrag wurde am 22.02.2014 um 12:32 Uhr von Hobi editiert. |