summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--doc/coding_rules.txt (renamed from sw/z80/coding_rules.txt)0
-rw-r--r--sw/programmer/linux/src/flash.c2
-rw-r--r--sw/z80/TODO.txt1
-rw-r--r--sw/z80/arch/addresses.h (renamed from sw/z80_tests/usart/devices.h)4
-rw-r--r--sw/z80/crt0.rel86
-rw-r--r--sw/z80/drivers/build/ctc.asm (renamed from sw/z80_tests/usart/build/ctc.asm)0
-rw-r--r--sw/z80/drivers/build/ctc.lst (renamed from sw/z80_tests/usart/build/ctc.lst)0
-rw-r--r--sw/z80/drivers/build/ctc.rel (renamed from sw/z80_tests/usart/build/ctc.rel)0
-rw-r--r--sw/z80/drivers/build/ctc.sym (renamed from sw/z80_tests/usart/build/ctc.sym)0
-rw-r--r--sw/z80/drivers/build/pio.asm (renamed from sw/z80_tests/usart/build/pio.asm)40
-rw-r--r--sw/z80/drivers/build/pio.lst234
-rw-r--r--sw/z80/drivers/build/pio.rel (renamed from sw/z80_tests/usart/build/pio.rel)18
-rw-r--r--sw/z80/drivers/build/pio.sym (renamed from sw/z80_tests/usart/build/pio.sym)5
-rw-r--r--sw/z80/drivers/build/usart.asm (renamed from sw/z80_tests/usart/build/usart.asm)29
-rw-r--r--sw/z80/drivers/build/usart.lst (renamed from sw/z80_tests/usart/build/usart.lst)85
-rw-r--r--sw/z80/drivers/build/usart.rel (renamed from sw/z80_tests/usart/build/usart.rel)26
-rw-r--r--sw/z80/drivers/build/usart.sym (renamed from sw/z80_tests/usart/build/usart.sym)2
-rw-r--r--sw/z80/drivers/ctc.c (renamed from sw/z80/kernel/drivers/ctc.c)2
-rw-r--r--sw/z80/drivers/include/ctc.h (renamed from sw/z80/kernel/include/drivers/ctc.h)0
-rw-r--r--sw/z80/drivers/include/pio.h (renamed from sw/z80/kernel/include/drivers/pio.h)7
-rw-r--r--sw/z80/drivers/include/usart.h (renamed from sw/z80/kernel/include/drivers/usart.h)9
-rw-r--r--sw/z80/drivers/makefile22
-rw-r--r--sw/z80/drivers/pio.c (renamed from sw/z80/kernel/drivers/pio.c)14
-rw-r--r--sw/z80/drivers/usart.c (renamed from sw/z80/kernel/drivers/usart.c)2
-rw-r--r--sw/z80/kernel/crt0.s (renamed from sw/z80/crt0.s)0
-rw-r--r--sw/z80/kernel/makefile (renamed from sw/z80/makefile)18
-rw-r--r--sw/z80/libc/include/stdint.h (renamed from sw/z80_tests/usart/types.h)14
-rw-r--r--sw/z80/libc/include/stdlib.h7
-rw-r--r--sw/z80/libc/include/types.h60
-rw-r--r--sw/z80/tests/pio/build/crt0.rel (renamed from sw/z80_tests/usart/build/crt0.rel)0
-rw-r--r--sw/z80/tests/pio/build/main.asm (renamed from sw/z80_tests/usart/build/main.asm)54
-rw-r--r--sw/z80/tests/pio/build/main.lst (renamed from sw/z80_tests/usart/build/main.lst)78
-rw-r--r--sw/z80/tests/pio/build/main.rel29
-rw-r--r--sw/z80/tests/pio/build/main.sym (renamed from sw/z80_tests/usart/build/main.sym)9
-rw-r--r--sw/z80/tests/pio/build/pio_test.lk (renamed from sw/z80_tests/usart/build/sample.lk)5
-rw-r--r--sw/z80/tests/pio/build/pio_test.map (renamed from sw/z80_tests/usart/build/sample.map)57
-rw-r--r--sw/z80/tests/pio/build/pio_test.noi (renamed from sw/z80_tests/usart/build/sample.noi)41
-rw-r--r--sw/z80/tests/pio/crt0.s (renamed from sw/z80_tests/usart/crt0.s)0
-rw-r--r--sw/z80/tests/pio/main.c12
-rw-r--r--sw/z80/tests/pio/makefile (renamed from sw/z80_tests/usart/makefile)22
-rw-r--r--sw/z80/tests/ram/build/crt0.rel (renamed from sw/z80_tests/ram/build/crt0.rel)17
-rw-r--r--sw/z80/tests/ram/build/main.asm (renamed from sw/z80_tests/ram/build/main.asm)0
-rw-r--r--sw/z80/tests/ram/build/main.lst (renamed from sw/z80_tests/ram/build/main.lst)0
-rw-r--r--sw/z80/tests/ram/build/main.rel (renamed from sw/z80_tests/ram/build/main.rel)0
-rw-r--r--sw/z80/tests/ram/build/main.sym (renamed from sw/z80_tests/ram/build/main.sym)0
-rw-r--r--sw/z80/tests/ram/build/ram_test.lk11
-rw-r--r--sw/z80/tests/ram/build/ram_test.map174
-rw-r--r--sw/z80/tests/ram/build/ram_test.noi50
-rw-r--r--sw/z80/tests/ram/build/test.lk (renamed from sw/z80_tests/ram/build/test.lk)0
-rw-r--r--sw/z80/tests/ram/build/test.map (renamed from sw/z80_tests/ram/build/test.map)0
-rw-r--r--sw/z80/tests/ram/build/test.noi (renamed from sw/z80_tests/ram/build/test.noi)0
-rw-r--r--sw/z80/tests/ram/build/test.z80 (renamed from sw/z80_tests/ram/build/test.z80)0
-rw-r--r--sw/z80/tests/ram/crt0.s (renamed from sw/z80_tests/ram/crt0.s)1
-rw-r--r--sw/z80/tests/ram/main.c (renamed from sw/z80_tests/ram/main.c)0
-rw-r--r--sw/z80/tests/ram/makefile (renamed from sw/z80_tests/ram/makefile)2
-rw-r--r--sw/z80_tests/usart/build/main.rel41
-rw-r--r--sw/z80_tests/usart/build/pio.lst194
-rw-r--r--sw/z80_tests/usart/build/sample.z80558
-rw-r--r--sw/z80_tests/usart/main.c11
l---------sw/z80_tests/usart/usart.c1
l---------sw/z80_tests/usart/usart.h1
61 files changed, 907 insertions, 1148 deletions
diff --git a/sw/z80/coding_rules.txt b/doc/coding_rules.txt
index e5c11f0..e5c11f0 100644
--- a/sw/z80/coding_rules.txt
+++ b/doc/coding_rules.txt
diff --git a/sw/programmer/linux/src/flash.c b/sw/programmer/linux/src/flash.c
index 6fcd09f..24d5269 100644
--- a/sw/programmer/linux/src/flash.c
+++ b/sw/programmer/linux/src/flash.c
@@ -32,7 +32,7 @@ int flash_write(const char *romfile, void (*log)(const char *))
log("[!] Error while reading from file\n");
break;
}
-
+
head.addr = (uint16_t) lseek(romfd, 0, SEEK_CUR);
written = write(flash_serial_fd, &head, sizeof(struct flash_blk));
diff --git a/sw/z80/TODO.txt b/sw/z80/TODO.txt
new file mode 100644
index 0000000..67be671
--- /dev/null
+++ b/sw/z80/TODO.txt
@@ -0,0 +1 @@
+- fix kernel makefile (currently broken)
diff --git a/sw/z80_tests/usart/devices.h b/sw/z80/arch/addresses.h
index a846f9b..07ab473 100644
--- a/sw/z80_tests/usart/devices.h
+++ b/sw/z80/arch/addresses.h
@@ -1,5 +1,5 @@
-#ifndef __DEVICES_H__
-#define __DEVICES_H__
+#ifndef __ADDRESSES_H__
+#define __ADDRESSES_H__
#define ADDR_DEV_ROM_L 0x0000
#define ADDR_DEV_ROM_H 0x2000
diff --git a/sw/z80/crt0.rel b/sw/z80/crt0.rel
deleted file mode 100644
index 880fd57..0000000
--- a/sw/z80/crt0.rel
+++ /dev/null
@@ -1,86 +0,0 @@
-XL2
-H 14 areas 5 global symbols
-M crt0
-S .__.ABS. Def0000
-S _kmain Ref0000
-A _CODE size A flags 0 addr 0
-S __clock Def0000
-S _exit Def0004
-A _HEADER size 0 flags 8 addr 0
-A _HEADER0 size 3 flags 8 addr 0
-A _HEADER1 size 2 flags 8 addr 8
-A _HEADER2 size 2 flags 8 addr 10
-A _HEADER3 size 2 flags 8 addr 18
-A _HEADER4 size 2 flags 8 addr 20
-A _HEADER5 size 2 flags 8 addr 28
-A _HEADER6 size 2 flags 8 addr 30
-A _HEADER7 size 2 flags 8 addr 38
-A _HEADER8 size C flags 8 addr 100
-A _HOME size 0 flags 0 addr 0
-A _INITIALIZER size 0 flags 0 addr 0
-A _GSINIT size 6 flags 0 addr 0
-S gsinit Def0000
-A _GSFINAL size 1 flags 0 addr 0
-A _DATA size 0 flags 0 addr 0
-A _INITIALIZED size 0 flags 0 addr 0
-A _BSEG size 0 flags 0 addr 0
-A _BSS size 0 flags 0 addr 0
-A _HEAP size 0 flags 0 addr 0
-T 00 00
-R 00 00 02 00
-T 00 00 C3 00 01
-R 00 00 02 00 00 03 0A 00
-T 08 00
-R 00 00 03 00
-T 08 00 ED 4D
-R 00 00 03 00
-T 10 00
-R 00 00 04 00
-T 10 00 ED 4D
-R 00 00 04 00
-T 18 00
-R 00 00 05 00
-T 18 00 ED 4D
-R 00 00 05 00
-T 20 00
-R 00 00 06 00
-T 20 00 ED 4D
-R 00 00 06 00
-T 28 00
-R 00 00 07 00
-T 28 00 ED 4D
-R 00 00 07 00
-T 30 00
-R 00 00 08 00
-T 30 00 ED 4D
-R 00 00 08 00
-T 38 00
-R 00 00 09 00
-T 38 00 ED 4D
-R 00 00 09 00
-T 00 01
-R 00 00 0A 00
-T 00 01
-R 00 00 0A 00
-T 00 01 31 FF FF CD 00 00 CD 00 00 C3 04 00
-R 00 00 0A 00 00 06 0D 00 02 09 01 00 00 0C 00 00
-T 00 00
-R 00 00 00 00
-T 00 00 3E 02 CF C9
-R 00 00 00 00
-T 04 00
-R 00 00 00 00
-T 04 00 3E 00 CF
-R 00 00 00 00
-T 07 00
-R 00 00 00 00
-T 07 00 76 18 FD
-R 00 00 00 00
-T 00 00
-R 00 00 0D 00
-T 00 00 78 B1 28 02 ED B0
-R 00 00 0D 00
-T 06 00
-R 00 00 0D 00
-T 00 00 C9
-R 00 00 0E 00
diff --git a/sw/z80_tests/usart/build/ctc.asm b/sw/z80/drivers/build/ctc.asm
index 838756a..838756a 100644
--- a/sw/z80_tests/usart/build/ctc.asm
+++ b/sw/z80/drivers/build/ctc.asm
diff --git a/sw/z80_tests/usart/build/ctc.lst b/sw/z80/drivers/build/ctc.lst
index e758d8a..e758d8a 100644
--- a/sw/z80_tests/usart/build/ctc.lst
+++ b/sw/z80/drivers/build/ctc.lst
diff --git a/sw/z80_tests/usart/build/ctc.rel b/sw/z80/drivers/build/ctc.rel
index 50a8b42..50a8b42 100644
--- a/sw/z80_tests/usart/build/ctc.rel
+++ b/sw/z80/drivers/build/ctc.rel
diff --git a/sw/z80_tests/usart/build/ctc.sym b/sw/z80/drivers/build/ctc.sym
index 82ca00e..82ca00e 100644
--- a/sw/z80_tests/usart/build/ctc.sym
+++ b/sw/z80/drivers/build/ctc.sym
diff --git a/sw/z80_tests/usart/build/pio.asm b/sw/z80/drivers/build/pio.asm
index ee1fcc6..3045492 100644
--- a/sw/z80_tests/usart/build/pio.asm
+++ b/sw/z80/drivers/build/pio.asm
@@ -13,6 +13,8 @@
.globl _pio_set_mode
.globl _pio_set_interrupts
.globl _pio_set_interrupts_mask
+ .globl _pio_read
+ .globl _pio_write
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
@@ -185,6 +187,44 @@ _pio_set_interrupts_mask::
ld (hl),c
;pio.c:39: _pio_control(port, mask);
ret
+;pio.c:42: uint8_t pio_read(int port)
+; ---------------------------------
+; Function pio_read
+; ---------------------------------
+_pio_read::
+;pio.c:44: return *(pio_port + port);
+ ld hl,#2
+ add hl,sp
+ ld iy,#_pio_port
+ ld a,0 (iy)
+ add a, (hl)
+ ld c,a
+ ld a,1 (iy)
+ inc hl
+ adc a, (hl)
+ ld b,a
+ ld a,(bc)
+ ld l,a
+ ret
+;pio.c:47: void pio_write(int port, uint8_t data)
+; ---------------------------------
+; Function pio_write
+; ---------------------------------
+_pio_write::
+;pio.c:49: _pio_data(port, data);
+ ld hl, #4+0
+ add hl, sp
+ ld c, (hl)
+ pop de
+ pop hl
+ push hl
+ push de
+;pio.c:8: *(pio_port + port) = data;
+ ld de,(_pio_port)
+ add hl,de
+ ld (hl),c
+;pio.c:49: _pio_data(port, data);
+ ret
.area _CODE
.area _INITIALIZER
__xinit__pio_port:
diff --git a/sw/z80/drivers/build/pio.lst b/sw/z80/drivers/build/pio.lst
new file mode 100644
index 0000000..0b83616
--- /dev/null
+++ b/sw/z80/drivers/build/pio.lst
@@ -0,0 +1,234 @@
+ 1 ;--------------------------------------------------------
+ 2 ; File Created by SDCC : free open source ANSI-C Compiler
+ 3 ; Version 3.6.0 #9615 (Linux)
+ 4 ;--------------------------------------------------------
+ 5 .module pio
+ 6 .optsdcc -mz80
+ 7
+ 8 ;--------------------------------------------------------
+ 9 ; Public variables in this module
+ 10 ;--------------------------------------------------------
+ 11 .globl __pio_data
+ 12 .globl __pio_control
+ 13 .globl _pio_set_mode
+ 14 .globl _pio_set_interrupts
+ 15 .globl _pio_set_interrupts_mask
+ 16 .globl _pio_read
+ 17 .globl _pio_write
+ 18 ;--------------------------------------------------------
+ 19 ; special function registers
+ 20 ;--------------------------------------------------------
+ 21 ;--------------------------------------------------------
+ 22 ; ram data
+ 23 ;--------------------------------------------------------
+ 24 .area _DATA
+ 25 ;--------------------------------------------------------
+ 26 ; ram data
+ 27 ;--------------------------------------------------------
+ 28 .area _INITIALIZED
+ 0000 29 _pio_port:
+ 0000 30 .ds 2
+ 0002 31 _pio_ctrl:
+ 0002 32 .ds 2
+ 33 ;--------------------------------------------------------
+ 34 ; absolute external ram data
+ 35 ;--------------------------------------------------------
+ 36 .area _DABS (ABS)
+ 37 ;--------------------------------------------------------
+ 38 ; global & static initialisations
+ 39 ;--------------------------------------------------------
+ 40 .area _HOME
+ 41 .area _GSINIT
+ 42 .area _GSFINAL
+ 43 .area _GSINIT
+ 44 ;--------------------------------------------------------
+ 45 ; Home
+ 46 ;--------------------------------------------------------
+ 47 .area _HOME
+ 48 .area _HOME
+ 49 ;--------------------------------------------------------
+ 50 ; code
+ 51 ;--------------------------------------------------------
+ 52 .area _CODE
+ 53 ;pio.c:6: inline void _pio_data(int port, uint8_t data)
+ 54 ; ---------------------------------
+ 55 ; Function _pio_data
+ 56 ; ---------------------------------
+ 0000 57 __pio_data::
+ 58 ;pio.c:8: *(pio_port + port) = data;
+ 0000 21 02 00 [10] 59 ld hl,#2
+ 0003 39 [11] 60 add hl,sp
+ 0004 FD 21r00r00 [14] 61 ld iy,#_pio_port
+ 0008 FD 7E 00 [19] 62 ld a,0 (iy)
+ 000B 86 [ 7] 63 add a, (hl)
+ 000C 4F [ 4] 64 ld c,a
+ 000D FD 7E 01 [19] 65 ld a,1 (iy)
+ 0010 23 [ 6] 66 inc hl
+ 0011 8E [ 7] 67 adc a, (hl)
+ 0012 47 [ 4] 68 ld b,a
+ 0013 21 04 00 [10] 69 ld hl, #4+0
+ 0016 39 [11] 70 add hl, sp
+ 0017 7E [ 7] 71 ld a, (hl)
+ 0018 02 [ 7] 72 ld (bc),a
+ 0019 C9 [10] 73 ret
+ 74 ;pio.c:11: inline void _pio_control(int port, uint8_t cmd)
+ 75 ; ---------------------------------
+ 76 ; Function _pio_control
+ 77 ; ---------------------------------
+ 001A 78 __pio_control::
+ 79 ;pio.c:13: *(pio_ctrl + port) = cmd;
+ 001A 21 02 00 [10] 80 ld hl,#2
+ 001D 39 [11] 81 add hl,sp
+ 001E FD 21r02r00 [14] 82 ld iy,#_pio_ctrl
+ 0022 FD 7E 00 [19] 83 ld a,0 (iy)
+ 0025 86 [ 7] 84 add a, (hl)
+ 0026 4F [ 4] 85 ld c,a
+ 0027 FD 7E 01 [19] 86 ld a,1 (iy)
+ 002A 23 [ 6] 87 inc hl
+ 002B 8E [ 7] 88 adc a, (hl)
+ 002C 47 [ 4] 89 ld b,a
+ 002D 21 04 00 [10] 90 ld hl, #4+0
+ 0030 39 [11] 91 add hl, sp
+ 0031 7E [ 7] 92 ld a, (hl)
+ 0032 02 [ 7] 93 ld (bc),a
+ 0033 C9 [10] 94 ret
+ 95 ;pio.c:16: void pio_set_mode(int port, int mode, uint8_t io)
+ 96 ; ---------------------------------
+ 97 ; Function pio_set_mode
+ 98 ; ---------------------------------
+ 0034 99 _pio_set_mode::
+ 100 ;pio.c:19: _pio_control(port, ((mode << 6) | 0x0F));
+ 0034 21 04 00 [10] 101 ld hl, #4+0
+ 0037 39 [11] 102 add hl, sp
+ 0038 7E [ 7] 103 ld a, (hl)
+ 0039 0F [ 4] 104 rrca
+ 003A 0F [ 4] 105 rrca
+ 003B E6 C0 [ 7] 106 and a,#0xc0
+ 003D F6 0F [ 7] 107 or a, #0x0f
+ 003F 4F [ 4] 108 ld c,a
+ 0040 D1 [10] 109 pop de
+ 0041 E1 [10] 110 pop hl
+ 0042 E5 [11] 111 push hl
+ 0043 D5 [11] 112 push de
+ 113 ;pio.c:13: *(pio_ctrl + port) = cmd;
+ 0044 FD 2Ar02r00 [20] 114 ld iy,(_pio_ctrl)
+ 0048 5D [ 4] 115 ld e, l
+ 0049 54 [ 4] 116 ld d, h
+ 004A FD 19 [15] 117 add iy, de
+ 004C FD 71 00 [19] 118 ld 0 (iy), c
+ 119 ;pio.c:23: if (mode == PIO_MODE_BIT_IO) {
+ 004F FD 21 04 00 [14] 120 ld iy,#4
+ 0053 FD 39 [15] 121 add iy,sp
+ 0055 FD 7E 00 [19] 122 ld a,0 (iy)
+ 0058 D6 03 [ 7] 123 sub a, #0x03
+ 005A C0 [11] 124 ret NZ
+ 005B FD 7E 01 [19] 125 ld a,1 (iy)
+ 005E B7 [ 4] 126 or a, a
+ 005F C0 [11] 127 ret NZ
+ 128 ;pio.c:24: _pio_control(port, io);
+ 0060 FD 21 06 00 [14] 129 ld iy,#6
+ 0064 FD 39 [15] 130 add iy,sp
+ 0066 FD 4E 00 [19] 131 ld c,0 (iy)
+ 132 ;pio.c:13: *(pio_ctrl + port) = cmd;
+ 0069 ED 5Br02r00 [20] 133 ld de,(_pio_ctrl)
+ 006D 19 [11] 134 add hl,de
+ 006E 71 [ 7] 135 ld (hl),c
+ 136 ;pio.c:24: _pio_control(port, io);
+ 006F C9 [10] 137 ret
+ 138 ;pio.c:28: void pio_set_interrupts(int port, int control)
+ 139 ; ---------------------------------
+ 140 ; Function pio_set_interrupts
+ 141 ; ---------------------------------
+ 0070 142 _pio_set_interrupts::
+ 143 ;pio.c:31: _pio_control(port, (control | 0x07));
+ 0070 21 04 00 [10] 144 ld hl, #4+0
+ 0073 39 [11] 145 add hl, sp
+ 0074 7E [ 7] 146 ld a, (hl)
+ 0075 F6 07 [ 7] 147 or a, #0x07
+ 0077 4F [ 4] 148 ld c,a
+ 0078 D1 [10] 149 pop de
+ 0079 E1 [10] 150 pop hl
+ 007A E5 [11] 151 push hl
+ 007B D5 [11] 152 push de
+ 153 ;pio.c:13: *(pio_ctrl + port) = cmd;
+ 007C ED 5Br02r00 [20] 154 ld de,(_pio_ctrl)
+ 0080 19 [11] 155 add hl,de
+ 0081 71 [ 7] 156 ld (hl),c
+ 157 ;pio.c:31: _pio_control(port, (control | 0x07));
+ 0082 C9 [10] 158 ret
+ 159 ;pio.c:34: void pio_set_interrupts_mask(int port, int control, uint8_t mask)
+ 160 ; ---------------------------------
+ 161 ; Function pio_set_interrupts_mask
+ 162 ; ---------------------------------
+ 0083 163 _pio_set_interrupts_mask::
+ 164 ;pio.c:38: _pio_control(port, (control | 0x17));
+ 0083 21 04 00 [10] 165 ld hl, #4+0
+ 0086 39 [11] 166 add hl, sp
+ 0087 7E [ 7] 167 ld a, (hl)
+ 0088 F6 17 [ 7] 168 or a, #0x17
+ 008A 4F [ 4] 169 ld c,a
+ 008B D1 [10] 170 pop de
+ 008C E1 [10] 171 pop hl
+ 008D E5 [11] 172 push hl
+ 008E D5 [11] 173 push de
+ 174 ;pio.c:13: *(pio_ctrl + port) = cmd;
+ 008F FD 2Ar02r00 [20] 175 ld iy,(_pio_ctrl)
+ 0093 5D [ 4] 176 ld e, l
+ 0094 54 [ 4] 177 ld d, h
+ 0095 FD 19 [15] 178 add iy, de
+ 0097 FD 71 00 [19] 179 ld 0 (iy), c
+ 180 ;pio.c:39: _pio_control(port, mask);
+ 009A FD 21 06 00 [14] 181 ld iy,#6
+ 009E FD 39 [15] 182 add iy,sp
+ 00A0 FD 4E 00 [19] 183 ld c,0 (iy)
+ 184 ;pio.c:13: *(pio_ctrl + port) = cmd;
+ 00A3 ED 5Br02r00 [20] 185 ld de,(_pio_ctrl)
+ 00A7 19 [11] 186 add hl,de
+ 00A8 71 [ 7] 187 ld (hl),c
+ 188 ;pio.c:39: _pio_control(port, mask);
+ 00A9 C9 [10] 189 ret
+ 190 ;pio.c:42: uint8_t pio_read(int port)
+ 191 ; ---------------------------------
+ 192 ; Function pio_read
+ 193 ; ---------------------------------
+ 00AA 194 _pio_read::
+ 195 ;pio.c:44: return *(pio_port + port);
+ 00AA 21 02 00 [10] 196 ld hl,#2
+ 00AD 39 [11] 197 add hl,sp
+ 00AE FD 21r00r00 [14] 198 ld iy,#_pio_port
+ 00B2 FD 7E 00 [19] 199 ld a,0 (iy)
+ 00B5 86 [ 7] 200 add a, (hl)
+ 00B6 4F [ 4] 201 ld c,a
+ 00B7 FD 7E 01 [19] 202 ld a,1 (iy)
+ 00BA 23 [ 6] 203 inc hl
+ 00BB 8E [ 7] 204 adc a, (hl)
+ 00BC 47 [ 4] 205 ld b,a
+ 00BD 0A [ 7] 206 ld a,(bc)
+ 00BE 6F [ 4] 207 ld l,a
+ 00BF C9 [10] 208 ret
+ 209 ;pio.c:47: void pio_write(int port, uint8_t data)
+ 210 ; ---------------------------------
+ 211 ; Function pio_write
+ 212 ; ---------------------------------
+ 00C0 213 _pio_write::
+ 214 ;pio.c:49: _pio_data(port, data);
+ 00C0 21 04 00 [10] 215 ld hl, #4+0
+ 00C3 39 [11] 216 add hl, sp
+ 00C4 4E [ 7] 217 ld c, (hl)
+ 00C5 D1 [10] 218 pop de
+ 00C6 E1 [10] 219 pop hl
+ 00C7 E5 [11] 220 push hl
+ 00C8 D5 [11] 221 push de
+ 222 ;pio.c:8: *(pio_port + port) = data;
+ 00C9 ED 5Br00r00 [20] 223 ld de,(_pio_port)
+ 00CD 19 [11] 224 add hl,de
+ 00CE 71 [ 7] 225 ld (hl),c
+ 226 ;pio.c:49: _pio_data(port, data);
+ 00CF C9 [10] 227 ret
+ 228 .area _CODE
+ 229 .area _INITIALIZER
+ 0000 230 __xinit__pio_port:
+ 0000 00 42 231 .dw #0x4200
+ 0002 232 __xinit__pio_ctrl:
+ 0002 02 42 233 .dw #0x4202
+ 234 .area _CABS (ABS)
diff --git a/sw/z80_tests/usart/build/pio.rel b/sw/z80/drivers/build/pio.rel
index 90210a9..d9b1ac3 100644
--- a/sw/z80_tests/usart/build/pio.rel
+++ b/sw/z80/drivers/build/pio.rel
@@ -1,13 +1,15 @@
XL2
-H 9 areas 6 global symbols
+H 9 areas 8 global symbols
M pio
O -mz80
S .__.ABS. Def0000
-A _CODE size AA flags 0 addr 0
+A _CODE size D0 flags 0 addr 0
S _pio_set_interrupts Def0070
S _pio_set_mode Def0034
S _pio_set_interrupts_mask Def0083
+S _pio_read Def00AA
S __pio_control Def001A
+S _pio_write Def00C0
S __pio_data Def0000
A _DATA size 0 flags 0 addr 0
A _INITIALIZED size 4 flags 0 addr 0
@@ -63,6 +65,18 @@ T 91 00 02 00 5D 54 FD 19 FD 71 00 FD 21 06 00 FD
R 00 00 00 00 00 02 02 00
T 9F 00 39 FD 4E 00 ED 5B 02 00 19 71 C9
R 00 00 00 00 00 08 02 00
+T AA 00
+R 00 00 00 00
+T AA 00 21 02 00 39 FD 21 00 00 FD 7E 00 86 4F FD
+R 00 00 00 00 00 08 02 00
+T B8 00 7E 01 23 8E 47 0A 6F C9
+R 00 00 00 00
+T C0 00
+R 00 00 00 00
+T C0 00 21 04 00 39 4E D1 E1 E5 D5 ED 5B 00 00 19
+R 00 00 00 00 00 0D 02 00
+T CE 00 71 C9
+R 00 00 00 00
T 00 00
R 00 00 07 00
T 00 00 00 42
diff --git a/sw/z80_tests/usart/build/pio.sym b/sw/z80/drivers/build/pio.sym
index 3cf582f..52f787c 100644
--- a/sw/z80_tests/usart/build/pio.sym
+++ b/sw/z80/drivers/build/pio.sym
@@ -13,17 +13,18 @@ Symbol Table
7 __xinit__pio_port 0000 R
2 _pio_ctrl 0002 R
2 _pio_port 0000 R
+ 0 _pio_read 00AA GR
0 _pio_set_interrupts 0070 GR
0 _pio_set_interrupts_mask 0083 GR
0 _pio_set_mode 0034 GR
-
+ 0 _pio_write 00C0 GR
ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180), page 2.
Hexadecimal [16-Bits]
Area Table
- 0 _CODE size AA flags 0
+ 0 _CODE size D0 flags 0
1 _DATA size 0 flags 0
2 _INITIALIZED size 4 flags 0
3 _DABS size 0 flags 8
diff --git a/sw/z80_tests/usart/build/usart.asm b/sw/z80/drivers/build/usart.asm
index 58d6fdf..fb65d62 100644
--- a/sw/z80_tests/usart/build/usart.asm
+++ b/sw/z80/drivers/build/usart.asm
@@ -366,14 +366,14 @@ _usart_read::
ld sp,hl
;usart.c:77: uint8_t *bp = buffer;
ld a,4 (ix)
- ld -6 (ix),a
+ ld -4 (ix),a
ld a,5 (ix)
- ld -5 (ix),a
+ ld -3 (ix),a
;usart.c:80: while (count--) {
ld c,6 (ix)
ld b,7 (ix)
- ld -4 (ix),#0x00
- ld -3 (ix),#0x00
+ ld hl,#0x0000
+ ex (sp), hl
00105$:
ld e, c
ld d, b
@@ -384,12 +384,12 @@ _usart_read::
;usart.c:81: *(bp++) = _usart->buffer;
ld hl,(__usart)
ld e,(hl)
- pop hl
- push hl
+ ld l,-4 (ix)
+ ld h,-3 (ix)
ld (hl),e
- inc -6 (ix)
+ inc -4 (ix)
jr NZ,00123$
- inc -5 (ix)
+ inc -3 (ix)
00123$:
ld de,(__usart)
;usart.c:83: if (_usart->LSR.framing_error || _usart->LSR.parity_error) {
@@ -414,23 +414,22 @@ _usart_read::
jr Z,00102$
00101$:
;usart.c:84: bp--; // delete last byte (?)
- pop hl
- push hl
+ ld l,-4 (ix)
+ ld h,-3 (ix)
dec hl
- ex (sp), hl
+ ld -4 (ix),l
+ ld -3 (ix),h
jr 00105$
00102$:
;usart.c:86: read_count++;
- inc -4 (ix)
+ inc -6 (ix)
jr NZ,00105$
- inc -3 (ix)
+ inc -5 (ix)
jr 00105$
00107$:
;usart.c:90: return read_count;
- pop bc
pop hl
push hl
- push bc
ld sp, ix
pop ix
ret
diff --git a/sw/z80_tests/usart/build/usart.lst b/sw/z80/drivers/build/usart.lst
index 7706cff..65365fe 100644
--- a/sw/z80_tests/usart/build/usart.lst
+++ b/sw/z80/drivers/build/usart.lst
@@ -366,30 +366,30 @@
01A4 F9 [ 6] 366 ld sp,hl
367 ;usart.c:77: uint8_t *bp = buffer;
01A5 DD 7E 04 [19] 368 ld a,4 (ix)
- 01A8 DD 77 FA [19] 369 ld -6 (ix),a
+ 01A8 DD 77 FC [19] 369 ld -4 (ix),a
01AB DD 7E 05 [19] 370 ld a,5 (ix)
- 01AE DD 77 FB [19] 371 ld -5 (ix),a
+ 01AE DD 77 FD [19] 371 ld -3 (ix),a
372 ;usart.c:80: while (count--) {
01B1 DD 4E 06 [19] 373 ld c,6 (ix)
01B4 DD 46 07 [19] 374 ld b,7 (ix)
- 01B7 DD 36 FC 00 [19] 375 ld -4 (ix),#0x00
- 01BB DD 36 FD 00 [19] 376 ld -3 (ix),#0x00
- 01BF 377 00105$:
- 01BF 59 [ 4] 378 ld e, c
- 01C0 50 [ 4] 379 ld d, b
- 01C1 0B [ 6] 380 dec bc
- 01C2 7A [ 4] 381 ld a,d
- 01C3 B3 [ 4] 382 or a,e
- 01C4 28 48 [12] 383 jr Z,00107$
+ 01B7 21 00 00 [10] 375 ld hl,#0x0000
+ 01BA E3 [19] 376 ex (sp), hl
+ 01BB 377 00105$:
+ 01BB 59 [ 4] 378 ld e, c
+ 01BC 50 [ 4] 379 ld d, b
+ 01BD 0B [ 6] 380 dec bc
+ 01BE 7A [ 4] 381 ld a,d
+ 01BF B3 [ 4] 382 or a,e
+ 01C0 28 55 [12] 383 jr Z,00107$
384 ;usart.c:81: *(bp++) = _usart->buffer;
- 01C6 2Ar00r00 [16] 385 ld hl,(__usart)
- 01C9 5E [ 7] 386 ld e,(hl)
- 01CA E1 [10] 387 pop hl
- 01CB E5 [11] 388 push hl
+ 01C2 2Ar00r00 [16] 385 ld hl,(__usart)
+ 01C5 5E [ 7] 386 ld e,(hl)
+ 01C6 DD 6E FC [19] 387 ld l,-4 (ix)
+ 01C9 DD 66 FD [19] 388 ld h,-3 (ix)
01CC 73 [ 7] 389 ld (hl),e
- 01CD DD 34 FA [23] 390 inc -6 (ix)
+ 01CD DD 34 FC [23] 390 inc -4 (ix)
01D0 20 03 [12] 391 jr NZ,00123$
- 01D2 DD 34 FB [23] 392 inc -5 (ix)
+ 01D2 DD 34 FD [23] 392 inc -3 (ix)
01D5 393 00123$:
01D5 ED 5Br00r00 [20] 394 ld de,(__usart)
395 ;usart.c:83: if (_usart->LSR.framing_error || _usart->LSR.parity_error) {
@@ -411,31 +411,30 @@
01F8 0F [ 4] 411 rrca
01F9 0F [ 4] 412 rrca
01FA E6 01 [ 7] 413 and a,#0x01
- 01FC 28 06 [12] 414 jr Z,00102$
+ 01FC 28 0F [12] 414 jr Z,00102$
01FE 415 00101$:
416 ;usart.c:84: bp--; // delete last byte (?)
- 01FE E1 [10] 417 pop hl
- 01FF E5 [11] 418 push hl
- 0200 2B [ 6] 419 dec hl
- 0201 E3 [19] 420 ex (sp), hl
- 0202 18 BB [12] 421 jr 00105$
- 0204 422 00102$:
- 423 ;usart.c:86: read_count++;
- 0204 DD 34 FC [23] 424 inc -4 (ix)
- 0207 20 B6 [12] 425 jr NZ,00105$
- 0209 DD 34 FD [23] 426 inc -3 (ix)
- 020C 18 B1 [12] 427 jr 00105$
- 020E 428 00107$:
- 429 ;usart.c:90: return read_count;
- 020E C1 [10] 430 pop bc
- 020F E1 [10] 431 pop hl
- 0210 E5 [11] 432 push hl
- 0211 C5 [11] 433 push bc
- 0212 DD F9 [10] 434 ld sp, ix
- 0214 DD E1 [14] 435 pop ix
- 0216 C9 [10] 436 ret
- 437 .area _CODE
- 438 .area _INITIALIZER
- 0000 439 __xinit___usart:
- 0000 00 40 440 .dw #0x4000
- 441 .area _CABS (ABS)
+ 01FE DD 6E FC [19] 417 ld l,-4 (ix)
+ 0201 DD 66 FD [19] 418 ld h,-3 (ix)
+ 0204 2B [ 6] 419 dec hl
+ 0205 DD 75 FC [19] 420 ld -4 (ix),l
+ 0208 DD 74 FD [19] 421 ld -3 (ix),h
+ 020B 18 AE [12] 422 jr 00105$
+ 020D 423 00102$:
+ 424 ;usart.c:86: read_count++;
+ 020D DD 34 FA [23] 425 inc -6 (ix)
+ 0210 20 A9 [12] 426 jr NZ,00105$
+ 0212 DD 34 FB [23] 427 inc -5 (ix)
+ 0215 18 A4 [12] 428 jr 00105$
+ 0217 429 00107$:
+ 430 ;usart.c:90: return read_count;
+ 0217 E1 [10] 431 pop hl
+ 0218 E5 [11] 432 push hl
+ 0219 DD F9 [10] 433 ld sp, ix
+ 021B DD E1 [14] 434 pop ix
+ 021D C9 [10] 435 ret
+ 436 .area _CODE
+ 437 .area _INITIALIZER
+ 0000 438 __xinit___usart:
+ 0000 00 40 439 .dw #0x4000
+ 440 .area _CABS (ABS)
diff --git a/sw/z80_tests/usart/build/usart.rel b/sw/z80/drivers/build/usart.rel
index 480c037..29ad600 100644
--- a/sw/z80_tests/usart/build/usart.rel
+++ b/sw/z80/drivers/build/usart.rel
@@ -3,7 +3,7 @@ H 9 areas B global symbols
M usart
O -mz80
S .__.ABS. Def0000
-A _CODE size 217 flags 0 addr 0
+A _CODE size 21E flags 0 addr 0
S _usart_read Def0198
S _usart_set_autoflow Def00CE
S _usart_word_length Def00B5
@@ -146,15 +146,15 @@ T 98 01
R 00 00 00 00
T 98 01 DD E5 DD 21 00 00 DD 39 21 FA FF 39 F9 DD
R 00 00 00 00
-T A6 01 7E 04 DD 77 FA DD 7E 05 DD 77 FB DD 4E 06
+T A6 01 7E 04 DD 77 FC DD 7E 05 DD 77 FD DD 4E 06
R 00 00 00 00
-T B4 01 DD 46 07 DD 36 FC 00 DD 36 FD 00
+T B4 01 DD 46 07 21 00 00 E3
R 00 00 00 00
-T BF 01
+T BB 01
R 00 00 00 00
-T BF 01 59 50 0B 7A B3 28 48 2A 00 00 5E E1 E5 73
+T BB 01 59 50 0B 7A B3 28 55 2A 00 00 5E DD 6E FC
R 00 00 00 00 00 0A 02 00
-T CD 01 DD 34 FA 20 03 DD 34 FB
+T C9 01 DD 66 FD 73 DD 34 FC 20 03 DD 34 FD
R 00 00 00 00
T D5 01
R 00 00 00 00
@@ -162,19 +162,21 @@ T D5 01 ED 5B 00 00 21 0D 00 19 DD 75 FE DD 74 FF
R 00 00 00 00 00 04 02 00
T E3 01 DD 6E FE DD 66 FF 7E 0F 0F 0F E6 01 20 0D
R 00 00 00 00
-T F1 01 DD 6E FE DD 66 FF 7E 0F 0F E6 01 28 06
+T F1 01 DD 6E FE DD 66 FF 7E 0F 0F E6 01 28 0F
R 00 00 00 00
T FE 01
R 00 00 00 00
-T FE 01 E1 E5 2B E3 18 BB
+T FE 01 DD 6E FC DD 66 FD 2B DD 75 FC DD 74 FD 18
R 00 00 00 00
-T 04 02
+T 0C 02 AE
R 00 00 00 00
-T 04 02 DD 34 FC 20 B6 DD 34 FD 18 B1
+T 0D 02
R 00 00 00 00
-T 0E 02
+T 0D 02 DD 34 FA 20 A9 DD 34 FB 18 A4
R 00 00 00 00
-T 0E 02 C1 E1 E5 C5 DD F9 DD E1 C9
+T 17 02
+R 00 00 00 00
+T 17 02 E1 E5 DD F9 DD E1 C9
R 00 00 00 00
T 00 00
R 00 00 07 00
diff --git a/sw/z80_tests/usart/build/usart.sym b/sw/z80/drivers/build/usart.sym
index a6e3c38..71004e3 100644
--- a/sw/z80_tests/usart/build/usart.sym
+++ b/sw/z80/drivers/build/usart.sym
@@ -26,7 +26,7 @@ Hexadecimal [16-Bits]
Area Table
- 0 _CODE size 217 flags 0
+ 0 _CODE size 21E flags 0
1 _DATA size 0 flags 0
2 _INITIALIZED size 2 flags 0
3 _DABS size 0 flags 8
diff --git a/sw/z80/kernel/drivers/ctc.c b/sw/z80/drivers/ctc.c
index 841202a..5ac4254 100644
--- a/sw/z80/kernel/drivers/ctc.c
+++ b/sw/z80/drivers/ctc.c
@@ -1,4 +1,4 @@
-#include "drivers/ctc.h"
+#include "ctc.h"
void ctc_control()
{
diff --git a/sw/z80/kernel/include/drivers/ctc.h b/sw/z80/drivers/include/ctc.h
index 80e8b4b..80e8b4b 100644
--- a/sw/z80/kernel/include/drivers/ctc.h
+++ b/sw/z80/drivers/include/ctc.h
diff --git a/sw/z80/kernel/include/drivers/pio.h b/sw/z80/drivers/include/pio.h
index 0df2ed0..e91029c 100644
--- a/sw/z80/kernel/include/drivers/pio.h
+++ b/sw/z80/drivers/include/pio.h
@@ -1,8 +1,8 @@
#ifndef __PIO_H__
#define __PIO_H__
-#include "devices.h"
-#include "types.h"
+#include "addresses.h"
+#include <stdint.h>
#define PIO_A 0
#define PIO_B 1
@@ -20,6 +20,7 @@
inline void _pio_data(int port, uint8_t data);
inline void _pio_control(int port, uint8_t cmd);
+/* the last argument is needed only for IO mode */
void pio_set_mode(int port, int mode, uint8_t io);
void pio_set_interrupts(int port, int control);
@@ -34,4 +35,4 @@ inline void pio_write_pin(int port, uint8_t pin);
// TODO: implement mode (in/out/both) and interrupt vector
-#endif // __PIO_H__
+#endif /* __PIO_H__ */
diff --git a/sw/z80/kernel/include/drivers/usart.h b/sw/z80/drivers/include/usart.h
index b85ee3e..bb06aab 100644
--- a/sw/z80/kernel/include/drivers/usart.h
+++ b/sw/z80/drivers/include/usart.h
@@ -1,10 +1,10 @@
#ifndef __USART_H__
#define __USART_H__
-#include "types.h"
-#include "devices.h"
+#include "addresses.h"
-#include "string.h"
+#include <stdint.h>
+#include <string.h>
// baudrate clock divisors
// values from TL16C550C datasheet (table 9 for 1.8432 MHz crystal)
@@ -48,6 +48,9 @@
#define USART_AUTOFLOW_CTS 2
#define USART_AUTOFLOW_OFF 0
+typedef unsigned int uint;
+typedef uint8_t register_t;
+
/* stuctures for usart registers */
struct IER
{
diff --git a/sw/z80/drivers/makefile b/sw/z80/drivers/makefile
new file mode 100644
index 0000000..5d6d8ee
--- /dev/null
+++ b/sw/z80/drivers/makefile
@@ -0,0 +1,22 @@
+# Drivers library
+
+LIB := build/drivers.a
+SOURCES := $(wildcard *.c)
+OBJECTS := $(patsubst %.c,build/%.rel,$(SOURCES))
+
+CC := sdcc
+AR := sdar
+CFLAGS := -mz80 -Iinclude -I../arch -DDEBUG
+
+.PHONY: dirs clean
+$(LIB): $(OBJECTS)
+ $(AR) rcs $@ $(OBJECTS)
+
+$(OBJECTS): build/%.rel: %.c $(SOURCES) dirs
+ $(CC) $(CFLAGS) -c $< -o $@
+
+dirs:
+ mkdir -p build
+
+clean:
+ - rm -rd build/*
diff --git a/sw/z80/kernel/drivers/pio.c b/sw/z80/drivers/pio.c
index 4321fb8..bdbe1c3 100644
--- a/sw/z80/kernel/drivers/pio.c
+++ b/sw/z80/drivers/pio.c
@@ -1,4 +1,4 @@
-#include "drivers/pio.h"
+#include "pio.h"
static uint8_t *pio_port = (uint8_t *) ADDR_DEV_PIO;
static uint8_t *pio_ctrl = (uint8_t *) (ADDR_DEV_PIO + 2);
@@ -34,7 +34,17 @@ void pio_set_interrupts(int port, int control)
void pio_set_interrupts_mask(int port, int control, uint8_t mask)
{
// 0x17 is a control sequence to set interrupts
- // and to interpret the next byte as a mask
+ // AND interpret the next byte as a bitmask
_pio_control(port, (control | 0x17));
_pio_control(port, mask);
}
+
+uint8_t pio_read(int port)
+{
+ return *(pio_port + port);
+}
+
+void pio_write(int port, uint8_t data)
+{
+ _pio_data(port, data);
+}
diff --git a/sw/z80/kernel/drivers/usart.c b/sw/z80/drivers/usart.c
index c54fe37..9ec6dbd 100644
--- a/sw/z80/kernel/drivers/usart.c
+++ b/sw/z80/drivers/usart.c
@@ -1,4 +1,4 @@
-#include "drivers/usart.h"
+#include "usart.h"
static struct _usart_device *_usart = (struct _usart_device *) ADDR_DEV_USART;
diff --git a/sw/z80/crt0.s b/sw/z80/kernel/crt0.s
index 00c7da1..00c7da1 100644
--- a/sw/z80/crt0.s
+++ b/sw/z80/kernel/crt0.s
diff --git a/sw/z80/makefile b/sw/z80/kernel/makefile
index 5ab7e93..be8eed4 100644
--- a/sw/z80/makefile
+++ b/sw/z80/kernel/makefile
@@ -3,9 +3,8 @@
#
OSNAME := helvetiOS
-CSOURCES := $(wildcard kernel/*.c) \
- $(wildcard kernel/drivers/*.c) \
- $(wildcard libc/*.c)
+CSOURCES := $(wildcard *.c) \
+ $(wildcard drivers/*.c)
OBJECTS := $(patsubst %.c,build/%.rel,$(CSOURCES))
HEXFILE := build/$(OSNAME).hex
@@ -17,13 +16,13 @@ BINARY := build/$(OSNAME).bin
CC := sdcc
CFLAGS := -mz80 \
- -I kernel/include \
- -I kernel/include/drivers \
+ -I include \
+ -I include/drivers \
-I libc/include \
--opt-code-size \
-DDEBUG
-LDFLAGS := -mz80 --no-std-crt0 crt0.rel \
+LDFLAGS := -mz80 --no-std-crt0 build/crt0.rel \
--std-c89 -pedantic \
--code-loc 0x0800 --data-loc 0x8000
@@ -33,21 +32,20 @@ all: $(BINARY)
# build binary
$(BINARY): $(OBJECTS) dirs
$(CC) $(LDFLAGS) $(OBJECTS) -o $(HEXFILE)
- @# xxd -r -p $(HEXFILE) $(BINARY)
makebin -s 16384 $(HEXFILE) $(BINARY)
-$(OBJECTS): build/%.rel : %.c $(CSOURCES) dirs crt0.rel
+$(OBJECTS): build/%.rel : %.c $(CSOURCES) dirs build/crt0.rel
@printf "\n"
$(CC) $(CFLAGS) -c $< -o $@
-crt0.rel: crt0.s
+build/crt0.rel: crt0.s
sdasz80 -o $<
+ @mv crt0.rel build
dirs:
mkdir -p build build/kernel build/libc build/kernel/drivers
dis: $(BINARY)
- @# z80dasm -a -l -g 0h $< -o build/$(OSNAME).s
dz80 -b -n $<
clean:
diff --git a/sw/z80_tests/usart/types.h b/sw/z80/libc/include/stdint.h
index 815fc68..5e8caf3 100644
--- a/sw/z80_tests/usart/types.h
+++ b/sw/z80/libc/include/stdint.h
@@ -1,13 +1,13 @@
-#ifndef __TYPES_H__
-#define __TYPES_H__
-
-/* only types from primitive types are defined in this file */
-
-typedef volatile unsigned char register_t;
+#ifndef __STDINT_H__
+#define __STDINT_H__
typedef unsigned int uint;
+
typedef char int8_t;
typedef unsigned char uint8_t;
typedef int int16_t;
typedef unsigned int uint16_t;
-#endif
+typedef long int int32_t;
+typedef unsigned long int uint32_t;
+
+#endif // __STDINT_H__ \ No newline at end of file
diff --git a/sw/z80/libc/include/stdlib.h b/sw/z80/libc/include/stdlib.h
new file mode 100644
index 0000000..c69f573
--- /dev/null
+++ b/sw/z80/libc/include/stdlib.h
@@ -0,0 +1,7 @@
+#ifndef __STDLIB_H__
+#define __STDLIB_H__
+
+#include "stdint.h"
+
+
+#endif // __STDLIB_H__ \ No newline at end of file
diff --git a/sw/z80/libc/include/types.h b/sw/z80/libc/include/types.h
new file mode 100644
index 0000000..a083bfe
--- /dev/null
+++ b/sw/z80/libc/include/types.h
@@ -0,0 +1,60 @@
+#ifndef __TYPES_H__
+#define __TYPES_H__
+
+/* only types from primitive types are defined in this file */
+
+typedef volatile unsigned char register_t;
+
+typedef unsigned int uint;
+
+typedef char int8_t;
+typedef unsigned char uint8_t;
+typedef int int16_t;
+typedef unsigned int uint16_t;
+typedef long int int32_t;
+typedef unsigned long int uint32_t;
+
+typedef uint16_t size_t;
+typedef int16_t ssize_t;
+
+typedef uint8_t pid_t;
+typedef uint16_t ino_t;
+
+typedef uint8_t dev_t;
+typedef uint32_t devsize_t;
+typedef uint8_t fd_t;
+typedef uint16_t blk_t;
+typedef uint8_t user_t;
+typedef struct {
+ uint8_t member[3];
+} uint24_t;
+
+typedef uint32_t fsize_t;
+
+typedef struct
+{
+ dev_t dev; // device id, global in the fs
+ ino_t inode; // inode id relative to the volume
+
+} inode_t;
+
+typedef struct time_s
+{
+ struct
+ {
+ uint minutes :6;
+ uint hour :5;
+
+ } time;
+
+ struct
+ {
+ uint day :5;
+ uint month :4;
+ uint year :12;
+
+ } date;
+
+} time_t;
+
+#endif
diff --git a/sw/z80_tests/usart/build/crt0.rel b/sw/z80/tests/pio/build/crt0.rel
index 809c0e6..809c0e6 100644
--- a/sw/z80_tests/usart/build/crt0.rel
+++ b/sw/z80/tests/pio/build/crt0.rel
diff --git a/sw/z80_tests/usart/build/main.asm b/sw/z80/tests/pio/build/main.asm
index 44f199a..453eead 100644
--- a/sw/z80_tests/usart/build/main.asm
+++ b/sw/z80/tests/pio/build/main.asm
@@ -9,8 +9,8 @@
; Public variables in this module
;--------------------------------------------------------
.globl _main
- .globl _usart_write
- .globl _usart_init
+ .globl _pio_write
+ .globl _pio_set_mode
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
@@ -47,44 +47,34 @@
; Function main
; ---------------------------------
_main::
-;main.c:5: usart_init(USART_BAUDRATE_1200, USART_PARITY_EVEN, USART_STOP_BITS_1);
- ld hl,#0x000a
+;main.c:7: pio_set_mode(PIO_A, PIO_MODE_BYTE_OUT, 0);
+ xor a, a
+ push af
+ inc sp
+ ld hl,#0x0001
push hl
- ld l, #0x01
+ ld l, #0x00
push hl
- ld l, #0x60
- push hl
- call _usart_init
- ld hl,#6
- add hl,sp
- ld sp,hl
-;main.c:6: usart_write("Hello, World!\n", 13);
- ld hl,#0x000d
- push hl
- ld hl,#___str_0
- push hl
- call _usart_write
+ call _pio_set_mode
pop af
pop af
-;main.c:8: while(1) {
+ inc sp
+;main.c:9: while (1) {
+ ld c,#0x00
00102$:
-;main.c:9: usart_write("done\n", 5);
- ld hl,#0x0005
+;main.c:10: pio_write(PIO_A, j++);
+ ld b,c
+ inc c
+ push bc
+ push bc
+ inc sp
+ ld hl,#0x0000
push hl
- ld hl,#___str_1
- push hl
- call _usart_write
- pop af
+ call _pio_write
pop af
+ inc sp
+ pop bc
jr 00102$
-___str_0:
- .ascii "Hello, World!"
- .db 0x0a
- .db 0x00
-___str_1:
- .ascii "done"
- .db 0x0a
- .db 0x00
.area _CODE
.area _INITIALIZER
.area _CABS (ABS)
diff --git a/sw/z80_tests/usart/build/main.lst b/sw/z80/tests/pio/build/main.lst
index c7b4201..4a1a872 100644
--- a/sw/z80_tests/usart/build/main.lst
+++ b/sw/z80/tests/pio/build/main.lst
@@ -9,8 +9,8 @@
9 ; Public variables in this module
10 ;--------------------------------------------------------
11 .globl _main
- 12 .globl _usart_write
- 13 .globl _usart_init
+ 12 .globl _pio_write
+ 13 .globl _pio_set_mode
14 ;--------------------------------------------------------
15 ; special function registers
16 ;--------------------------------------------------------
@@ -47,46 +47,34 @@
47 ; Function main
48 ; ---------------------------------
0000 49 _main::
- 50 ;main.c:5: usart_init(USART_BAUDRATE_1200, USART_PARITY_EVEN, USART_STOP_BITS_1);
- 0000 21 0A 00 [10] 51 ld hl,#0x000a
- 0003 E5 [11] 52 push hl
- 0004 2E 01 [ 7] 53 ld l, #0x01
- 0006 E5 [11] 54 push hl
- 0007 2E 60 [ 7] 55 ld l, #0x60
- 0009 E5 [11] 56 push hl
- 000A CDr00r00 [17] 57 call _usart_init
- 000D 21 06 00 [10] 58 ld hl,#6
- 0010 39 [11] 59 add hl,sp
- 0011 F9 [ 6] 60 ld sp,hl
- 61 ;main.c:6: usart_write("Hello, World!\n", 13);
- 0012 21 0D 00 [10] 62 ld hl,#0x000d
- 0015 E5 [11] 63 push hl
- 0016 21r2Er00 [10] 64 ld hl,#___str_0
- 0019 E5 [11] 65 push hl
- 001A CDr00r00 [17] 66 call _usart_write
- 001D F1 [10] 67 pop af
- 001E F1 [10] 68 pop af
- 69 ;main.c:8: while(1) {
- 001F 70 00102$:
- 71 ;main.c:9: usart_write("done\n", 5);
- 001F 21 05 00 [10] 72 ld hl,#0x0005
- 0022 E5 [11] 73 push hl
- 0023 21r3Dr00 [10] 74 ld hl,#___str_1
- 0026 E5 [11] 75 push hl
- 0027 CDr00r00 [17] 76 call _usart_write
- 002A F1 [10] 77 pop af
- 002B F1 [10] 78 pop af
- 002C 18 F1 [12] 79 jr 00102$
- 002E 80 ___str_0:
- 002E 48 65 6C 6C 6F 2C 81 .ascii "Hello, World!"
- 20 57 6F 72 6C 64
- 21
- 003B 0A 82 .db 0x0a
- 003C 00 83 .db 0x00
- 003D 84 ___str_1:
- 003D 64 6F 6E 65 85 .ascii "done"
- 0041 0A 86 .db 0x0a
- 0042 00 87 .db 0x00
- 88 .area _CODE
- 89 .area _INITIALIZER
- 90 .area _CABS (ABS)
+ 50 ;main.c:7: pio_set_mode(PIO_A, PIO_MODE_BYTE_OUT, 0);
+ 0000 AF [ 4] 51 xor a, a
+ 0001 F5 [11] 52 push af
+ 0002 33 [ 6] 53 inc sp
+ 0003 21 01 00 [10] 54 ld hl,#0x0001
+ 0006 E5 [11] 55 push hl
+ 0007 2E 00 [ 7] 56 ld l, #0x00
+ 0009 E5 [11] 57 push hl
+ 000A CDr00r00 [17] 58 call _pio_set_mode
+ 000D F1 [10] 59 pop af
+ 000E F1 [10] 60 pop af
+ 000F 33 [ 6] 61 inc sp
+ 62 ;main.c:9: while (1) {
+ 0010 0E 00 [ 7] 63 ld c,#0x00
+ 0012 64 00102$:
+ 65 ;main.c:10: pio_write(PIO_A, j++);
+ 0012 41 [ 4] 66 ld b,c
+ 0013 0C [ 4] 67 inc c
+ 0014 C5 [11] 68 push bc
+ 0015 C5 [11] 69 push bc
+ 0016 33 [ 6] 70 inc sp
+ 0017 21 00 00 [10] 71 ld hl,#0x0000
+ 001A E5 [11] 72 push hl
+ 001B CDr00r00 [17] 73 call _pio_write
+ 001E F1 [10] 74 pop af
+ 001F 33 [ 6] 75 inc sp
+ 0020 C1 [10] 76 pop bc
+ 0021 18 EF [12] 77 jr 00102$
+ 78 .area _CODE
+ 79 .area _INITIALIZER
+ 80 .area _CABS (ABS)
diff --git a/sw/z80/tests/pio/build/main.rel b/sw/z80/tests/pio/build/main.rel
new file mode 100644
index 0000000..bc2bd98
--- /dev/null
+++ b/sw/z80/tests/pio/build/main.rel
@@ -0,0 +1,29 @@
+XL2
+H 9 areas 4 global symbols
+M main
+O -mz80
+S _pio_set_mode Ref0000
+S .__.ABS. Def0000
+S _pio_write Ref0000
+A _CODE size 23 flags 0 addr 0
+S _main Def0000
+A _DATA size 0 flags 0 addr 0
+A _INITIALIZED size 0 flags 0 addr 0
+A _DABS size 0 flags 8 addr 0
+A _HOME size 0 flags 0 addr 0
+A _GSINIT size 0 flags 0 addr 0
+A _GSFINAL size 0 flags 0 addr 0
+A _INITIALIZER size 0 flags 0 addr 0
+A _CABS size 0 flags 8 addr 0
+T 00 00
+R 00 00 00 00
+T 00 00 AF F5 33 21 01 00 E5 2E 00 E5 CD 00 00 F1
+R 00 00 00 00 02 0D 00 00
+T 0E 00 F1 33 0E 00
+R 00 00 00 00
+T 12 00
+R 00 00 00 00
+T 12 00 41 0C C5 C5 33 21 00 00 E5 CD 00 00 F1 33
+R 00 00 00 00 02 0C 02 00
+T 20 00 C1 18 EF
+R 00 00 00 00
diff --git a/sw/z80_tests/usart/build/main.sym b/sw/z80/tests/pio/build/main.sym
index df02e0d..08d28a3 100644
--- a/sw/z80_tests/usart/build/main.sym
+++ b/sw/z80/tests/pio/build/main.sym
@@ -7,18 +7,17 @@ Symbol Table
.__.ABS. = 0000 G
.__.CPU. = 0000 L
.__.H$L. = 0000 L
- 0 ___str_0 002E R
- 0 ___str_1 003D R
0 _main 0000 GR
- _usart_init **** GX
- _usart_write **** GX
+ _pio_set_mode **** GX
+ _pio_write **** GX
+
ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180), page 2.
Hexadecimal [16-Bits]
Area Table
- 0 _CODE size 43 flags 0
+ 0 _CODE size 23 flags 0
1 _DATA size 0 flags 0
2 _INITIALIZED size 0 flags 0
3 _DABS size 0 flags 8
diff --git a/sw/z80_tests/usart/build/sample.lk b/sw/z80/tests/pio/build/pio_test.lk
index dc99ff1..20c32cc 100644
--- a/sw/z80_tests/usart/build/sample.lk
+++ b/sw/z80/tests/pio/build/pio_test.lk
@@ -1,12 +1,13 @@
-mjwx
--i build/sample.hex
+-i build/pio_test.hex
-b _CODE = 0x0800
-b _DATA = 0x2000
+-k ../../drivers/build/
-k /usr/libexec/../share/sdcc/lib/z80
-k /usr/share/sdcc/lib/z80
+-l drivers.a
-l z80
build/crt0.rel
build/main.rel
-build/usart.rel
-e
diff --git a/sw/z80_tests/usart/build/sample.map b/sw/z80/tests/pio/build/pio_test.map
index e812f09..e91ef69 100644
--- a/sw/z80_tests/usart/build/sample.map
+++ b/sw/z80/tests/pio/build/pio_test.map
@@ -7,7 +7,7 @@ Area Addr Size Decimal Bytes (A
Value Global Global Defined In Module
----- -------------------------------- ------------------------
- 00000000 .__.ABS. usart
+ 00000000 .__.ABS. pio
00000000 l__BSEG
00000000 l__BSS
00000000 l__CABS
@@ -36,44 +36,41 @@ Area Addr Size Decimal Bytes (A
00000002 l__HEADER5
00000002 l__HEADER6
00000002 l__HEADER7
- 00000002 l__INITIALIZED
- 00000002 l__INITIALIZER
00000003 l__HEADER0
+ 00000004 l__INITIALIZED
+ 00000004 l__INITIALIZER
00000006 l__GSINIT
0000000C l__HEADER8
- 00000264 l__CODE
+ 000000FD l__CODE
00000800 s__CODE
- 00000A64 s__HOME
- 00000A64 s__INITIALIZER
- 00000A66 s__GSINIT
- 00000A6C s__GSFINAL
+ 000008FD s__HOME
+ 000008FD s__INITIALIZER
+ 00000901 s__GSINIT
+ 00000907 s__GSFINAL
00002000 s__DATA
00002000 s__INITIALIZED
- 00002002 s__BSEG
- 00002002 s__BSS
- 00002002 s__HEAP
+ 00002004 s__BSEG
+ 00002004 s__BSS
+ 00002004 s__HEAP
ASxxxx Linker V03.00 + NoICE + sdld, page 2.
Hexadecimal [32-Bits]
Area Addr Size Decimal Bytes (Attributes)
-------------------------------- ---- ---- ------- ----- ------------
-_CODE 00000800 00000264 = 612. bytes (REL,CON)
+_CODE 00000800 000000FD = 253. bytes (REL,CON)
Value Global Global Defined In Module
----- -------------------------------- ------------------------
00000800 __clock crt0
00000804 _exit crt0
0000080A _main main
- 0000084D _usart_set_baudrate usart
- 00000881 _usart_set_parity usart
- 000008D5 _usart_set_stop_bits usart
- 00000902 _usart_word_length usart
- 0000091B _usart_set_autoflow usart
- 00000955 _usart_init usart
- 0000097E _usart_transmit usart
- 00000999 _usart_receive usart
- 0000099E _usart_write usart
- 000009E5 _usart_read usart
+ 0000082D __pio_data pio
+ 00000847 __pio_control pio
+ 00000861 _pio_set_mode pio
+ 0000089D _pio_set_interrupts pio
+ 000008B0 _pio_set_interrupts_mask pio
+ 000008D7 _pio_read pio
+ 000008ED _pio_write pio
ASxxxx Linker V03.00 + NoICE + sdld, page 3.
Hexadecimal [32-Bits]
@@ -161,7 +158,7 @@ Hexadecimal [32-Bits]
Area Addr Size Decimal Bytes (Attributes)
-------------------------------- ---- ---- ------- ----- ------------
-_INITIALIZER 00000A64 00000002 = 2. bytes (REL,CON)
+_INITIALIZER 000008FD 00000004 = 4. bytes (REL,CON)
Value Global Global Defined In Module
----- -------------------------------- ------------------------
@@ -170,18 +167,18 @@ Hexadecimal [32-Bits]
Area Addr Size Decimal Bytes (Attributes)
-------------------------------- ---- ---- ------- ----- ------------
-_GSINIT 00000A66 00000006 = 6. bytes (REL,CON)
+_GSINIT 00000901 00000006 = 6. bytes (REL,CON)
Value Global Global Defined In Module
----- -------------------------------- ------------------------
- 00000A66 gsinit crt0
+ 00000901 gsinit crt0
ASxxxx Linker V03.00 + NoICE + sdld, page 14.
Hexadecimal [32-Bits]
Area Addr Size Decimal Bytes (Attributes)
-------------------------------- ---- ---- ------- ----- ------------
-_GSFINAL 00000A6C 00000001 = 1. bytes (REL,CON)
+_GSFINAL 00000907 00000001 = 1. bytes (REL,CON)
Value Global Global Defined In Module
----- -------------------------------- ------------------------
@@ -190,7 +187,7 @@ Hexadecimal [32-Bits]
Area Addr Size Decimal Bytes (Attributes)
-------------------------------- ---- ---- ------- ----- ------------
-_INITIALIZED 00002000 00000002 = 2. bytes (REL,CON)
+_INITIALIZED 00002000 00000004 = 4. bytes (REL,CON)
Value Global Global Defined In Module
----- -------------------------------- ------------------------
@@ -200,7 +197,11 @@ Files Linked [ module(s) ]
build/crt0.rel [ crt0 ]
build/main.rel [ main ]
-build/usart.rel [ usart ]
+
+
+Libraries Linked [ object file ]
+
+../../drivers/build/drivers.a [ pio.rel ]
ASxxxx Linker V03.00 + NoICE + sdld, page 17.
diff --git a/sw/z80_tests/usart/build/sample.noi b/sw/z80/tests/pio/build/pio_test.noi
index 6d97288..3ddefe7 100644
--- a/sw/z80_tests/usart/build/sample.noi
+++ b/sw/z80/tests/pio/build/pio_test.noi
@@ -27,34 +27,31 @@ DEF l__HEADER4 0x2
DEF l__HEADER5 0x2
DEF l__HEADER6 0x2
DEF l__HEADER7 0x2
-DEF l__INITIALIZED 0x2
-DEF l__INITIALIZER 0x2
DEF l__HEADER0 0x3
+DEF l__INITIALIZED 0x4
+DEF l__INITIALIZER 0x4
DEF l__GSINIT 0x6
DEF l__HEADER8 0xC
-DEF l__CODE 0x264
+DEF l__CODE 0xFD
DEF s__CODE 0x800
-DEF s__HOME 0xA64
-DEF s__INITIALIZER 0xA64
-DEF s__GSINIT 0xA66
-DEF s__GSFINAL 0xA6C
+DEF s__HOME 0x8FD
+DEF s__INITIALIZER 0x8FD
+DEF s__GSINIT 0x901
+DEF s__GSFINAL 0x907
DEF s__DATA 0x2000
DEF s__INITIALIZED 0x2000
-DEF s__BSEG 0x2002
-DEF s__BSS 0x2002
-DEF s__HEAP 0x2002
+DEF s__BSEG 0x2004
+DEF s__BSS 0x2004
+DEF s__HEAP 0x2004
DEF __clock 0x800
DEF _exit 0x804
DEF _main 0x80A
-DEF _usart_set_baudrate 0x84D
-DEF _usart_set_parity 0x881
-DEF _usart_set_stop_bits 0x8D5
-DEF _usart_word_length 0x902
-DEF _usart_set_autoflow 0x91B
-DEF _usart_init 0x955
-DEF _usart_transmit 0x97E
-DEF _usart_receive 0x999
-DEF _usart_write 0x99E
-DEF _usart_read 0x9E5
-DEF gsinit 0xA66
-LOAD build/sample.ihx
+DEF __pio_data 0x82D
+DEF __pio_control 0x847
+DEF _pio_set_mode 0x861
+DEF _pio_set_interrupts 0x89D
+DEF _pio_set_interrupts_mask 0x8B0
+DEF _pio_read 0x8D7
+DEF _pio_write 0x8ED
+DEF gsinit 0x901
+LOAD build/pio_test.ihx
diff --git a/sw/z80_tests/usart/crt0.s b/sw/z80/tests/pio/crt0.s
index c272f06..c272f06 100644
--- a/sw/z80_tests/usart/crt0.s
+++ b/sw/z80/tests/pio/crt0.s
diff --git a/sw/z80/tests/pio/main.c b/sw/z80/tests/pio/main.c
new file mode 100644
index 0000000..4b0bcdb
--- /dev/null
+++ b/sw/z80/tests/pio/main.c
@@ -0,0 +1,12 @@
+#include "pio.h"
+
+void main(void)
+{
+ uint8_t j = 0;
+
+ pio_set_mode(PIO_A, PIO_MODE_BYTE_OUT, 0);
+
+ while (1) {
+ pio_write(PIO_A, j++);
+ }
+}
diff --git a/sw/z80_tests/usart/makefile b/sw/z80/tests/pio/makefile
index 080f41c..bd9d5bf 100644
--- a/sw/z80_tests/usart/makefile
+++ b/sw/z80/tests/pio/makefile
@@ -1,13 +1,13 @@
####
# source code settings
#
-OSNAME := sample
+NAME := pio_test
-CSOURCES := $(wildcard *.c)
+CSOURCES := $(wildcard *.c)
OBJECTS := $(patsubst %.c,build/%.rel,$(CSOURCES))
-HEXFILE := build/$(OSNAME).hex
-BINARY := build/$(OSNAME).bin
+HEXFILE := build/$(NAME).hex
+BINARY := build/$(NAME).bin
###
# compiler settings
@@ -15,12 +15,18 @@ BINARY := build/$(OSNAME).bin
CC := sdcc
CFLAGS := -mz80 \
+ -pedantic \
-I . \
+ -I ../../arch \
+ -I ../../drivers/include \
-DDEBUG
-LDFLAGS := -mz80 --no-std-crt0 build/crt0.rel \
- --std-c89 -pedantic \
- --code-loc 0x0800 --data-loc 0x2000
+LDFLAGS := -mz80 \
+ -L ../../drivers/build/ \
+ -l drivers.a \
+ --no-std-crt0 build/crt0.rel \
+ --code-loc 0x0800 \
+ --data-loc 0x2000
.PHONY: dirs dis clean
all: $(BINARY)
@@ -28,8 +34,6 @@ all: $(BINARY)
# build binary
$(BINARY): $(OBJECTS) dirs
$(CC) $(LDFLAGS) $(OBJECTS) -o $(HEXFILE)
- @# xxd -r -p $(HEXFILE) $(BINARY)
- @# makebin -s 16384 $(HEXFILE) $(BINARY)
makebin -s 8192 $(HEXFILE) $(BINARY)
$(OBJECTS): build/%.rel : %.c $(CSOURCES) dirs build/crt0.rel
diff --git a/sw/z80_tests/ram/build/crt0.rel b/sw/z80/tests/ram/build/crt0.rel
index cce6a25..b9ed132 100644
--- a/sw/z80_tests/ram/build/crt0.rel
+++ b/sw/z80/tests/ram/build/crt0.rel
@@ -1,5 +1,5 @@
XL2
-H 14 areas 3 global symbols
+H 15 areas 3 global symbols
M crt0
S _main Ref0000
S .__.ABS. Def0000
@@ -14,7 +14,8 @@ A _HEADER4 size 2 flags 8 addr 20
A _HEADER5 size 2 flags 8 addr 28
A _HEADER6 size 2 flags 8 addr 30
A _HEADER7 size 2 flags 8 addr 38
-A _HEADER8 size 9 flags 8 addr 100
+A _HEADER8 size 2 flags 8 addr 66
+A _HEADER9 size 9 flags 8 addr 100
A _HOME size 0 flags 0 addr 0
A _INITIALIZER size 0 flags 0 addr 0
A _GSINIT size 0 flags 0 addr 0
@@ -27,7 +28,7 @@ A _HEAP size 0 flags 0 addr 0
T 00 00
R 00 00 02 00
T 00 00 C3 00 01
-R 00 00 02 00 00 03 0A 00
+R 00 00 02 00 00 03 0B 00
T 08 00
R 00 00 03 00
T 08 00 ED 4D
@@ -56,12 +57,16 @@ T 38 00
R 00 00 09 00
T 38 00 ED 4D
R 00 00 09 00
-T 00 01
+T 66 00
R 00 00 0A 00
-T 00 01
+T 66 00 ED 4D
R 00 00 0A 00
+T 00 01
+R 00 00 0B 00
+T 00 01
+R 00 00 0B 00
T 00 01 31 FF FF CD 00 00 C3 00 00
-R 00 00 0A 00 02 06 00 00 00 09 00 00
+R 00 00 0B 00 02 06 00 00 00 09 00 00
T 00 00
R 00 00 00 00
T 00 00
diff --git a/sw/z80_tests/ram/build/main.asm b/sw/z80/tests/ram/build/main.asm
index f3b8add..f3b8add 100644
--- a/sw/z80_tests/ram/build/main.asm
+++ b/sw/z80/tests/ram/build/main.asm
diff --git a/sw/z80_tests/ram/build/main.lst b/sw/z80/tests/ram/build/main.lst
index 17142d4..17142d4 100644
--- a/sw/z80_tests/ram/build/main.lst
+++ b/sw/z80/tests/ram/build/main.lst
diff --git a/sw/z80_tests/ram/build/main.rel b/sw/z80/tests/ram/build/main.rel
index cad7a3c..cad7a3c 100644
--- a/sw/z80_tests/ram/build/main.rel
+++ b/sw/z80/tests/ram/build/main.rel
diff --git a/sw/z80_tests/ram/build/main.sym b/sw/z80/tests/ram/build/main.sym
index d81bdc8..d81bdc8 100644
--- a/sw/z80_tests/ram/build/main.sym
+++ b/sw/z80/tests/ram/build/main.sym
diff --git a/sw/z80/tests/ram/build/ram_test.lk b/sw/z80/tests/ram/build/ram_test.lk
new file mode 100644
index 0000000..724eb89
--- /dev/null
+++ b/sw/z80/tests/ram/build/ram_test.lk
@@ -0,0 +1,11 @@
+-mjwx
+-i build/ram_test.hex
+-b _CODE = 0x0000
+-b _DATA = 0x2000
+-k /usr/libexec/../share/sdcc/lib/z80
+-k /usr/share/sdcc/lib/z80
+-l z80
+build/crt0.rel
+build/main.rel
+
+-e
diff --git a/sw/z80/tests/ram/build/ram_test.map b/sw/z80/tests/ram/build/ram_test.map
new file mode 100644
index 0000000..0d36247
--- /dev/null
+++ b/sw/z80/tests/ram/build/ram_test.map
@@ -0,0 +1,174 @@
+ ASxxxx Linker V03.00 + NoICE + sdld, page 1.
+Hexadecimal [32-Bits]
+
+Area Addr Size Decimal Bytes (Attributes)
+-------------------------------- ---- ---- ------- ----- ------------
+. .ABS. 00000000 00000000 = 0. bytes (ABS,CON)
+
+ Value Global Global Defined In Module
+ ----- -------------------------------- ------------------------
+ 00000000 .__.ABS. main
+ 00000000 l__BSEG
+ 00000000 l__BSS
+ 00000000 l__CABS
+ 00000000 l__DABS
+ 00000000 l__DATA
+ 00000000 l__GSFINAL
+ 00000000 l__GSINIT
+ 00000000 l__HEADER
+ 00000000 l__HEAP
+ 00000000 l__HOME
+ 00000000 l__INITIALIZED
+ 00000000 l__INITIALIZER
+ 00000000 s__CABS
+ 00000000 s__CODE
+ 00000000 s__DABS
+ 00000000 s__HEADER
+ 00000000 s__HEADER0
+ 00000000 s__HEADER1
+ 00000000 s__HEADER2
+ 00000000 s__HEADER3
+ 00000000 s__HEADER4
+ 00000000 s__HEADER5
+ 00000000 s__HEADER6
+ 00000000 s__HEADER7
+ 00000000 s__HEADER8
+ 00000000 s__HEADER9
+ 00000002 l__HEADER1
+ 00000002 l__HEADER2
+ 00000002 l__HEADER3
+ 00000002 l__HEADER4
+ 00000002 l__HEADER5
+ 00000002 l__HEADER6
+ 00000002 l__HEADER7
+ 00000002 l__HEADER8
+ 00000003 l__HEADER0
+ 00000009 l__HEADER9
+ 0000000D l__CODE
+ 0000000D s__GSFINAL
+ 0000000D s__GSINIT
+ 0000000D s__HOME
+ 0000000D s__INITIALIZER
+ 00002000 s__BSEG
+ 00002000 s__BSS
+ 00002000 s__DATA
+ 00002000 s__HEAP
+ 00002000 s__INITIALIZED
+
+ ASxxxx Linker V03.00 + NoICE + sdld, page 2.
+Hexadecimal [32-Bits]
+
+Area Addr Size Decimal Bytes (Attributes)
+-------------------------------- ---- ---- ------- ----- ------------
+_CODE 00000000 0000000D = 13. bytes (REL,CON)
+
+ Value Global Global Defined In Module
+ ----- -------------------------------- ------------------------
+ 00000000 _exit crt0
+ 00000003 _main main
+
+ ASxxxx Linker V03.00 + NoICE + sdld, page 3.
+Hexadecimal [32-Bits]
+
+Area Addr Size Decimal Bytes (Attributes)
+-------------------------------- ---- ---- ------- ----- ------------
+_HEADER0 00000000 00000003 = 3. bytes (ABS,CON)
+
+ Value Global Global Defined In Module
+ ----- -------------------------------- ------------------------
+ ASxxxx Linker V03.00 + NoICE + sdld, page 4.
+Hexadecimal [32-Bits]
+
+Area Addr Size Decimal Bytes (Attributes)
+-------------------------------- ---- ---- ------- ----- ------------
+_HEADER1 00000000 00000002 = 2. bytes (ABS,CON)
+
+ Value Global Global Defined In Module
+ ----- -------------------------------- ------------------------
+ ASxxxx Linker V03.00 + NoICE + sdld, page 5.
+Hexadecimal [32-Bits]
+
+Area Addr Size Decimal Bytes (Attributes)
+-------------------------------- ---- ---- ------- ----- ------------
+_HEADER2 00000000 00000002 = 2. bytes (ABS,CON)
+
+ Value Global Global Defined In Module
+ ----- -------------------------------- ------------------------
+ ASxxxx Linker V03.00 + NoICE + sdld, page 6.
+Hexadecimal [32-Bits]
+
+Area Addr Size Decimal Bytes (Attributes)
+-------------------------------- ---- ---- ------- ----- ------------
+_HEADER3 00000000 00000002 = 2. bytes (ABS,CON)
+
+ Value Global Global Defined In Module
+ ----- -------------------------------- ------------------------
+ ASxxxx Linker V03.00 + NoICE + sdld, page 7.
+Hexadecimal [32-Bits]
+
+Area Addr Size Decimal Bytes (Attributes)
+-------------------------------- ---- ---- ------- ----- ------------
+_HEADER4 00000000 00000002 = 2. bytes (ABS,CON)
+
+ Value Global Global Defined In Module
+ ----- -------------------------------- ------------------------
+ ASxxxx Linker V03.00 + NoICE + sdld, page 8.
+Hexadecimal [32-Bits]
+
+Area Addr Size Decimal Bytes (Attributes)
+-------------------------------- ---- ---- ------- ----- ------------
+_HEADER5 00000000 00000002 = 2. bytes (ABS,CON)
+
+ Value Global Global Defined In Module
+ ----- -------------------------------- ------------------------
+ ASxxxx Linker V03.00 + NoICE + sdld, page 9.
+Hexadecimal [32-Bits]
+
+Area Addr Size Decimal Bytes (Attributes)
+-------------------------------- ---- ---- ------- ----- ------------
+_HEADER6 00000000 00000002 = 2. bytes (ABS,CON)
+
+ Value Global Global Defined In Module
+ ----- -------------------------------- ------------------------
+ ASxxxx Linker V03.00 + NoICE + sdld, page 10.
+Hexadecimal [32-Bits]
+
+Area Addr Size Decimal Bytes (Attributes)
+-------------------------------- ---- ---- ------- ----- ------------
+_HEADER7 00000000 00000002 = 2. bytes (ABS,CON)
+
+ Value Global Global Defined In Module
+ ----- -------------------------------- ------------------------
+ ASxxxx Linker V03.00 + NoICE + sdld, page 11.
+Hexadecimal [32-Bits]
+
+Area Addr Size Decimal Bytes (Attributes)
+-------------------------------- ---- ---- ------- ----- ------------
+_HEADER8 00000000 00000002 = 2. bytes (ABS,CON)
+
+ Value Global Global Defined In Module
+ ----- -------------------------------- ------------------------
+ ASxxxx Linker V03.00 + NoICE + sdld, page 12.
+Hexadecimal [32-Bits]
+
+Area Addr Size Decimal Bytes (Attributes)
+-------------------------------- ---- ---- ------- ----- ------------
+_HEADER9 00000000 00000009 = 9. bytes (ABS,CON)
+
+ Value Global Global Defined In Module
+ ----- -------------------------------- ------------------------
+ ASxxxx Linker V03.00 + NoICE + sdld, page 13.
+
+Files Linked [ module(s) ]
+
+build/crt0.rel [ crt0 ]
+build/main.rel [ main ]
+
+ ASxxxx Linker V03.00 + NoICE + sdld, page 14.
+
+User Base Address Definitions
+
+_CODE = 0x0000
+_DATA = 0x2000
+
+ \ No newline at end of file
diff --git a/sw/z80/tests/ram/build/ram_test.noi b/sw/z80/tests/ram/build/ram_test.noi
new file mode 100644
index 0000000..94266c5
--- /dev/null
+++ b/sw/z80/tests/ram/build/ram_test.noi
@@ -0,0 +1,50 @@
+DEF .__.ABS. 0x0
+DEF l__BSEG 0x0
+DEF l__BSS 0x0
+DEF l__CABS 0x0
+DEF l__DABS 0x0
+DEF l__DATA 0x0
+DEF l__GSFINAL 0x0
+DEF l__GSINIT 0x0
+DEF l__HEADER 0x0
+DEF l__HEAP 0x0
+DEF l__HOME 0x0
+DEF l__INITIALIZED 0x0
+DEF l__INITIALIZER 0x0
+DEF s__CABS 0x0
+DEF s__CODE 0x0
+DEF s__DABS 0x0
+DEF s__HEADER 0x0
+DEF s__HEADER0 0x0
+DEF s__HEADER1 0x0
+DEF s__HEADER2 0x0
+DEF s__HEADER3 0x0
+DEF s__HEADER4 0x0
+DEF s__HEADER5 0x0
+DEF s__HEADER6 0x0
+DEF s__HEADER7 0x0
+DEF s__HEADER8 0x0
+DEF s__HEADER9 0x0
+DEF l__HEADER1 0x2
+DEF l__HEADER2 0x2
+DEF l__HEADER3 0x2
+DEF l__HEADER4 0x2
+DEF l__HEADER5 0x2
+DEF l__HEADER6 0x2
+DEF l__HEADER7 0x2
+DEF l__HEADER8 0x2
+DEF l__HEADER0 0x3
+DEF l__HEADER9 0x9
+DEF l__CODE 0xD
+DEF s__GSFINAL 0xD
+DEF s__GSINIT 0xD
+DEF s__HOME 0xD
+DEF s__INITIALIZER 0xD
+DEF s__BSEG 0x2000
+DEF s__BSS 0x2000
+DEF s__DATA 0x2000
+DEF s__HEAP 0x2000
+DEF s__INITIALIZED 0x2000
+DEF _exit 0x0
+DEF _main 0x3
+LOAD build/ram_test.ihx
diff --git a/sw/z80_tests/ram/build/test.lk b/sw/z80/tests/ram/build/test.lk
index 03a8db4..03a8db4 100644
--- a/sw/z80_tests/ram/build/test.lk
+++ b/sw/z80/tests/ram/build/test.lk
diff --git a/sw/z80_tests/ram/build/test.map b/sw/z80/tests/ram/build/test.map
index 07b953f..07b953f 100644
--- a/sw/z80_tests/ram/build/test.map
+++ b/sw/z80/tests/ram/build/test.map
diff --git a/sw/z80_tests/ram/build/test.noi b/sw/z80/tests/ram/build/test.noi
index 403beda..403beda 100644
--- a/sw/z80_tests/ram/build/test.noi
+++ b/sw/z80/tests/ram/build/test.noi
diff --git a/sw/z80_tests/ram/build/test.z80 b/sw/z80/tests/ram/build/test.z80
index 25a162a..25a162a 100644
--- a/sw/z80_tests/ram/build/test.z80
+++ b/sw/z80/tests/ram/build/test.z80
diff --git a/sw/z80_tests/ram/crt0.s b/sw/z80/tests/ram/crt0.s
index ac0698f..d775e66 100644
--- a/sw/z80_tests/ram/crt0.s
+++ b/sw/z80/tests/ram/crt0.s
@@ -21,7 +21,6 @@
.org 0x38
reti
.org 0x66
- ld hl,#BEEF
reti
.org 0x100
diff --git a/sw/z80_tests/ram/main.c b/sw/z80/tests/ram/main.c
index 581072b..581072b 100644
--- a/sw/z80_tests/ram/main.c
+++ b/sw/z80/tests/ram/main.c
diff --git a/sw/z80_tests/ram/makefile b/sw/z80/tests/ram/makefile
index 35d7419..b8435a7 100644
--- a/sw/z80_tests/ram/makefile
+++ b/sw/z80/tests/ram/makefile
@@ -1,7 +1,7 @@
####
# source code settings
#
-OSNAME := test
+OSNAME := ram_test
CSOURCES := $(wildcard *.c)
diff --git a/sw/z80_tests/usart/build/main.rel b/sw/z80_tests/usart/build/main.rel
deleted file mode 100644
index 2557016..0000000
--- a/sw/z80_tests/usart/build/main.rel
+++ /dev/null
@@ -1,41 +0,0 @@
-XL2
-H 9 areas 4 global symbols
-M main
-O -mz80
-S _usart_write Ref0000
-S .__.ABS. Def0000
-S _usart_init Ref0000
-A _CODE size 43 flags 0 addr 0
-S _main Def0000
-A _DATA size 0 flags 0 addr 0
-A _INITIALIZED size 0 flags 0 addr 0
-A _DABS size 0 flags 8 addr 0
-A _HOME size 0 flags 0 addr 0
-A _GSINIT size 0 flags 0 addr 0
-A _GSFINAL size 0 flags 0 addr 0
-A _INITIALIZER size 0 flags 0 addr 0
-A _CABS size 0 flags 8 addr 0
-T 00 00
-R 00 00 00 00
-T 00 00 21 0A 00 E5 2E 01 E5 2E 60 E5 CD 00 00 21
-R 00 00 00 00 02 0D 02 00
-T 0E 00 06 00 39 F9 21 0D 00 E5 21 2E 00 E5 CD
-R 00 00 00 00 00 0B 00 00
-T 1B 00 00 00 F1 F1
-R 00 00 00 00 02 02 00 00
-T 1F 00
-R 00 00 00 00
-T 1F 00 21 05 00 E5 21 3D 00 E5 CD 00 00 F1 F1 18
-R 00 00 00 00 00 07 00 00 02 0B 00 00
-T 2D 00 F1
-R 00 00 00 00
-T 2E 00
-R 00 00 00 00
-T 2E 00 48 65 6C 6C 6F 2C 20 57 6F 72 6C 64 21 0A
-R 00 00 00 00
-T 3C 00 00
-R 00 00 00 00
-T 3D 00
-R 00 00 00 00
-T 3D 00 64 6F 6E 65 0A 00
-R 00 00 00 00
diff --git a/sw/z80_tests/usart/build/pio.lst b/sw/z80_tests/usart/build/pio.lst
deleted file mode 100644
index fcafc2a..0000000
--- a/sw/z80_tests/usart/build/pio.lst
+++ /dev/null
@@ -1,194 +0,0 @@
- 1 ;--------------------------------------------------------
- 2 ; File Created by SDCC : free open source ANSI-C Compiler
- 3 ; Version 3.6.0 #9615 (Linux)
- 4 ;--------------------------------------------------------
- 5 .module pio
- 6 .optsdcc -mz80
- 7
- 8 ;--------------------------------------------------------
- 9 ; Public variables in this module
- 10 ;--------------------------------------------------------
- 11 .globl __pio_data
- 12 .globl __pio_control
- 13 .globl _pio_set_mode
- 14 .globl _pio_set_interrupts
- 15 .globl _pio_set_interrupts_mask
- 16 ;--------------------------------------------------------
- 17 ; special function registers
- 18 ;--------------------------------------------------------
- 19 ;--------------------------------------------------------
- 20 ; ram data
- 21 ;--------------------------------------------------------
- 22 .area _DATA
- 23 ;--------------------------------------------------------
- 24 ; ram data
- 25 ;--------------------------------------------------------
- 26 .area _INITIALIZED
- 0000 27 _pio_port:
- 0000 28 .ds 2
- 0002 29 _pio_ctrl:
- 0002 30 .ds 2
- 31 ;--------------------------------------------------------
- 32 ; absolute external ram data
- 33 ;--------------------------------------------------------
- 34 .area _DABS (ABS)
- 35 ;--------------------------------------------------------
- 36 ; global & static initialisations
- 37 ;--------------------------------------------------------
- 38 .area _HOME
- 39 .area _GSINIT
- 40 .area _GSFINAL
- 41 .area _GSINIT
- 42 ;--------------------------------------------------------
- 43 ; Home
- 44 ;--------------------------------------------------------
- 45 .area _HOME
- 46 .area _HOME
- 47 ;--------------------------------------------------------
- 48 ; code
- 49 ;--------------------------------------------------------
- 50 .area _CODE
- 51 ;pio.c:6: inline void _pio_data(int port, uint8_t data)
- 52 ; ---------------------------------
- 53 ; Function _pio_data
- 54 ; ---------------------------------
- 0000 55 __pio_data::
- 56 ;pio.c:8: *(pio_port + port) = data;
- 0000 21 02 00 [10] 57 ld hl,#2
- 0003 39 [11] 58 add hl,sp
- 0004 FD 21r00r00 [14] 59 ld iy,#_pio_port
- 0008 FD 7E 00 [19] 60 ld a,0 (iy)
- 000B 86 [ 7] 61 add a, (hl)
- 000C 4F [ 4] 62 ld c,a
- 000D FD 7E 01 [19] 63 ld a,1 (iy)
- 0010 23 [ 6] 64 inc hl
- 0011 8E [ 7] 65 adc a, (hl)
- 0012 47 [ 4] 66 ld b,a
- 0013 21 04 00 [10] 67 ld hl, #4+0
- 0016 39 [11] 68 add hl, sp
- 0017 7E [ 7] 69 ld a, (hl)
- 0018 02 [ 7] 70 ld (bc),a
- 0019 C9 [10] 71 ret
- 72 ;pio.c:11: inline void _pio_control(int port, uint8_t cmd)
- 73 ; ---------------------------------
- 74 ; Function _pio_control
- 75 ; ---------------------------------
- 001A 76 __pio_control::
- 77 ;pio.c:13: *(pio_ctrl + port) = cmd;
- 001A 21 02 00 [10] 78 ld hl,#2
- 001D 39 [11] 79 add hl,sp
- 001E FD 21r02r00 [14] 80 ld iy,#_pio_ctrl
- 0022 FD 7E 00 [19] 81 ld a,0 (iy)
- 0025 86 [ 7] 82 add a, (hl)
- 0026 4F [ 4] 83 ld c,a
- 0027 FD 7E 01 [19] 84 ld a,1 (iy)
- 002A 23 [ 6] 85 inc hl
- 002B 8E [ 7] 86 adc a, (hl)
- 002C 47 [ 4] 87 ld b,a
- 002D 21 04 00 [10] 88 ld hl, #4+0
- 0030 39 [11] 89 add hl, sp
- 0031 7E [ 7] 90 ld a, (hl)
- 0032 02 [ 7] 91 ld (bc),a
- 0033 C9 [10] 92 ret
- 93 ;pio.c:16: void pio_set_mode(int port, int mode, uint8_t io)
- 94 ; ---------------------------------
- 95 ; Function pio_set_mode
- 96 ; ---------------------------------
- 0034 97 _pio_set_mode::
- 98 ;pio.c:19: _pio_control(port, ((mode << 6) | 0x0F));
- 0034 21 04 00 [10] 99 ld hl, #4+0
- 0037 39 [11] 100 add hl, sp
- 0038 7E [ 7] 101 ld a, (hl)
- 0039 0F [ 4] 102 rrca
- 003A 0F [ 4] 103 rrca
- 003B E6 C0 [ 7] 104 and a,#0xc0
- 003D F6 0F [ 7] 105 or a, #0x0f
- 003F 4F [ 4] 106 ld c,a
- 0040 D1 [10] 107 pop de
- 0041 E1 [10] 108 pop hl
- 0042 E5 [11] 109 push hl
- 0043 D5 [11] 110 push de
- 111 ;pio.c:13: *(pio_ctrl + port) = cmd;
- 0044 FD 2Ar02r00 [20] 112 ld iy,(_pio_ctrl)
- 0048 5D [ 4] 113 ld e, l
- 0049 54 [ 4] 114 ld d, h
- 004A FD 19 [15] 115 add iy, de
- 004C FD 71 00 [19] 116 ld 0 (iy), c
- 117 ;pio.c:23: if (mode == PIO_MODE_BIT_IO) {
- 004F FD 21 04 00 [14] 118 ld iy,#4
- 0053 FD 39 [15] 119 add iy,sp
- 0055 FD 7E 00 [19] 120 ld a,0 (iy)
- 0058 D6 03 [ 7] 121 sub a, #0x03
- 005A C0 [11] 122 ret NZ
- 005B FD 7E 01 [19] 123 ld a,1 (iy)
- 005E B7 [ 4] 124 or a, a
- 005F C0 [11] 125 ret NZ
- 126 ;pio.c:24: _pio_control(port, io);
- 0060 FD 21 06 00 [14] 127 ld iy,#6
- 0064 FD 39 [15] 128 add iy,sp
- 0066 FD 4E 00 [19] 129 ld c,0 (iy)
- 130 ;pio.c:13: *(pio_ctrl + port) = cmd;
- 0069 ED 5Br02r00 [20] 131 ld de,(_pio_ctrl)
- 006D 19 [11] 132 add hl,de
- 006E 71 [ 7] 133 ld (hl),c
- 134 ;pio.c:24: _pio_control(port, io);
- 006F C9 [10] 135 ret
- 136 ;pio.c:28: void pio_set_interrupts(int port, int control)
- 137 ; ---------------------------------
- 138 ; Function pio_set_interrupts
- 139 ; ---------------------------------
- 0070 140 _pio_set_interrupts::
- 141 ;pio.c:31: _pio_control(port, (control | 0x07));
- 0070 21 04 00 [10] 142 ld hl, #4+0
- 0073 39 [11] 143 add hl, sp
- 0074 7E [ 7] 144 ld a, (hl)
- 0075 F6 07 [ 7] 145 or a, #0x07
- 0077 4F [ 4] 146 ld c,a
- 0078 D1 [10] 147 pop de
- 0079 E1 [10] 148 pop hl
- 007A E5 [11] 149 push hl
- 007B D5 [11] 150 push de
- 151 ;pio.c:13: *(pio_ctrl + port) = cmd;
- 007C ED 5Br02r00 [20] 152 ld de,(_pio_ctrl)
- 0080 19 [11] 153 add hl,de
- 0081 71 [ 7] 154 ld (hl),c
- 155 ;pio.c:31: _pio_control(port, (control | 0x07));
- 0082 C9 [10] 156 ret
- 157 ;pio.c:34: void pio_set_interrupts_mask(int port, int control, uint8_t mask)
- 158 ; ---------------------------------
- 159 ; Function pio_set_interrupts_mask
- 160 ; ---------------------------------
- 0083 161 _pio_set_interrupts_mask::
- 162 ;pio.c:38: _pio_control(port, (control | 0x17));
- 0083 21 04 00 [10] 163 ld hl, #4+0
- 0086 39 [11] 164 add hl, sp
- 0087 7E [ 7] 165 ld a, (hl)
- 0088 F6 17 [ 7] 166 or a, #0x17
- 008A 4F [ 4] 167 ld c,a
- 008B D1 [10] 168 pop de
- 008C E1 [10] 169 pop hl
- 008D E5 [11] 170 push hl
- 008E D5 [11] 171 push de
- 172 ;pio.c:13: *(pio_ctrl + port) = cmd;
- 008F FD 2Ar02r00 [20] 173 ld iy,(_pio_ctrl)
- 0093 5D [ 4] 174 ld e, l
- 0094 54 [ 4] 175 ld d, h
- 0095 FD 19 [15] 176 add iy, de
- 0097 FD 71 00 [19] 177 ld 0 (iy), c
- 178 ;pio.c:39: _pio_control(port, mask);
- 009A FD 21 06 00 [14] 179 ld iy,#6
- 009E FD 39 [15] 180 add iy,sp
- 00A0 FD 4E 00 [19] 181 ld c,0 (iy)
- 182 ;pio.c:13: *(pio_ctrl + port) = cmd;
- 00A3 ED 5Br02r00 [20] 183 ld de,(_pio_ctrl)
- 00A7 19 [11] 184 add hl,de
- 00A8 71 [ 7] 185 ld (hl),c
- 186 ;pio.c:39: _pio_control(port, mask);
- 00A9 C9 [10] 187 ret
- 188 .area _CODE
- 189 .area _INITIALIZER
- 0000 190 __xinit__pio_port:
- 0000 00 42 191 .dw #0x4200
- 0002 192 __xinit__pio_ctrl:
- 0002 02 42 193 .dw #0x4202
- 194 .area _CABS (ABS)
diff --git a/sw/z80_tests/usart/build/sample.z80 b/sw/z80_tests/usart/build/sample.z80
deleted file mode 100644
index 965a0d8..0000000
--- a/sw/z80_tests/usart/build/sample.z80
+++ /dev/null
@@ -1,558 +0,0 @@
-;
-; DZ80 V3.4.1 Z80 Disassembly of build/sample.bin
-; 2017/09/25 17:08
-;
- org 0x0
-;
-X0000: jp X0100
-;
- org 0x4
-;
-X0004: rst 0x38
-X0005: rst 0x38
-X0006: rst 0x38
-;
- org 0x8
-;
- reti
-;
-X000a: rst 0x38
-;
- org 0xc
-;
-X000c: rst 0x38
-X000d: rst 0x38
-;
- org 0x10
-;
- reti
-;
- rst 0x38
-;
- org 0x18
-;
- reti
-;
- rst 0x38
-;
- org 0x20
-;
- reti
-;
- rst 0x38
-;
- org 0x28
-;
- reti
-;
- rst 0x38
-;
- org 0x30
-;
- reti
-;
- rst 0x38
-;
- org 0x38
-;
- reti
-;
- rst 0x38
-;
- org 0x100
-;
-X0100: ld sp,X0000
- call X0b15
- call X08b4
- jp X0804
-;
- org 0x800
-;
- ld a,0x2
- rst 8
- ret
-;
-X0804: ld a,0x0
- rst 8
-X0807: halt
-;
- jr X0807
-;
- ld hl,X0002
- add hl,sp
- ld iy,X2000
- ld a,(iy+0x0)
- add a,(hl)
- ld c,a
- ld a,(iy+0x1)
- inc hl
- adc a,(hl)
- ld b,a
- ld hl,X0004
- add hl,sp
- ld a,(hl)
- ld (bc),a
- ret
-;
- ld hl,X0002
- add hl,sp
- ld iy,X2002
- ld a,(iy+0x0)
- add a,(hl)
- ld c,a
- ld a,(iy+0x1)
- inc hl
- adc a,(hl)
- ld b,a
- ld hl,X0004
- add hl,sp
- ld a,(hl)
- ld (bc),a
- ret
-;
- ld hl,X0004
- add hl,sp
- ld a,(hl)
- rrca
- rrca
- and 0xc0
- or 0xf
- ld c,a
- pop de
- pop hl
- push hl
- push de
- ld iy,(X2002)
- ld e,l
- ld d,h
- add iy,de
- ld (iy+0x0),c
- ld iy,X0004
- add iy,sp
- ld a,(iy+0x0)
- sub 0x3
- ret nz
- ld a,(iy+0x1)
- or a
- ret nz
- ld iy,X0006
- add iy,sp
- ld c,(iy+0x0)
- ld de,(X2002)
- add hl,de
- ld (hl),c
- ret
-;
- ld hl,X0004
- add hl,sp
- ld a,(hl)
- or 0x7
- ld c,a
- pop de
- pop hl
- push hl
- push de
- ld de,(X2002)
- add hl,de
- ld (hl),c
- ret
-;
- ld hl,X0004
- add hl,sp
- ld a,(hl)
- or 0x17
- ld c,a
- pop de
- pop hl
- push hl
- push de
- ld iy,(X2002)
- ld e,l
- ld d,h
- add iy,de
- ld (iy+0x0),c
- ld iy,X0006
- add iy,sp
- ld c,(iy+0x0)
- ld de,(X2002)
- add hl,de
- ld (hl),c
- ret
-;
-X08b4: ld hl,X000a
- push hl
- ld l,0x1
- push hl
- ld l,0x60
- push hl
- call X0a00
- ld hl,X0006
- add hl,sp
- ld sp,hl
- ld hl,X000d
- push hl
- ld hl,X08e2
- push hl
- call X0a49
- pop af
- pop af
-X08d3: ld hl,X0005
- push hl
- ld hl,X08f1
- push hl
- call X0a49
- pop af
- pop af
- jr X08d3
-;
-X08e2: ld c,b
- ld h,l
- ld l,h
- ld l,h
- ld l,a
- inc l
- jr nz,X0941
- ld l,a
- ld (hl),d
- ld l,h
- ld h,h
- ld hl,X000a
-X08f1: ld h,h
- ld l,a
- ld l,(hl)
- ld h,l
- ld a,(bc)
- nop
- ret
-;
-X08f8: push ix
- ld ix,X0000
- add ix,sp
- ld hl,(X2004)
- ld bc,X0004
- add hl,bc
- ld a,(hl)
- or 0x80
- ld (hl),a
- ld hl,(X2004)
- ld c,(ix+0x4)
- ld (hl),c
- ld de,(X2004)
- inc de
- ld l,(ix+0x5)
- ld h,0x0
- ld a,(hl)
- ld (de),a
- ld hl,(X2004)
- ld bc,X0004
- add hl,bc
- ld a,(hl)
- and 0x7f
- ld (hl),a
- pop ix
- ret
-;
-X092c: ld hl,(X2004)
- ld bc,X0004
- add hl,bc
- ld iy,X0002
- add iy,sp
- ld a,(iy+0x0)
- dec a
- jr nz,X094b
- ld a,(iy+0x1)
- or a
- jr nz,X094b
- ld a,(hl)
- or 0x10
- ld (hl),a
- jr X0962
-;
-X094b: ld iy,X0002
- add iy,sp
- ld a,(iy+0x0)
- sub 0x2
- jr nz,X0962
- ld a,(iy+0x1)
- or a
- jr nz,X0962
- ld a,(hl)
- and 0xef
- ld (hl),a
-X0962: ld hl,(X2004)
- ld bc,X0004
- add hl,bc
- ld iy,X0002
- add iy,sp
- ld a,(iy+0x0)
- rlca
- rlca
- rlca
- and 0xf8
- and 0x8
- ld c,a
- ld a,(hl)
- and 0xf7
- or c
- ld (hl),a
- ret
-;
-X0980: ld bc,(X2004)
- inc bc
- inc bc
- inc bc
- inc bc
- ld iy,X0002
- add iy,sp
- ld a,(iy+0x0)
- sub 0xa
- jr nz,X099f
- ld a,(iy+0x1)
- or a
- jr nz,X099f
- ld a,0x1
- jr X09a0
-;
-X099f: xor a
-X09a0: xor 0x1
- add a,a
- add a,a
- and 0x4
- ld l,a
- ld a,(bc)
- and 0xfb
- or l
- ld (bc),a
- ret
-;
- ld hl,(X2004)
- ld bc,X0004
- add hl,bc
- ld iy,X0002
- add iy,sp
- ld a,(iy+0x0)
- and 0x3
- ld c,a
- ld a,(hl)
- and 0xfc
- or c
- ld (hl),a
- ret
-;
-X09c6: ld hl,(X2004)
- ld bc,X000c
- add hl,bc
- ld iy,X0002
- add iy,sp
- ld a,(iy+0x0)
- and 0x1
- ld c,a
- ld a,(hl)
- and 0xfe
- or c
- ld (hl),a
- ld hl,(X2004)
- ld bc,X0005
- add hl,bc
- ld a,(iy+0x0)
- sub 0x3
- jr nz,X09f6
- ld a,(iy+0x1)
- or a
- jr nz,X09f6
- ld a,0x1
- jr X09f7
-;
-X09f6: xor a
-X09f7: and 0x1
- ld c,a
- ld a,(hl)
- and 0xfe
- or c
- ld (hl),a
- ret
-;
-X0a00: pop bc
- pop hl
- push hl
- push bc
- push hl
- call X08f8
- pop af
- ld hl,X0004
- add hl,sp
- ld c,(hl)
- inc hl
- ld b,(hl)
- push bc
- call X092c
- pop af
- ld hl,X0006
- add hl,sp
- ld c,(hl)
- inc hl
- ld b,(hl)
- push bc
- call X0980
- ld hl,X0000
- ex (sp),hl
- call X09c6
- pop af
- ret
-;
- ld hl,(X2004)
- ld iy,X0002
- add iy,sp
- ld a,(iy+0x0)
- ld (hl),a
-X0a36: ld hl,(X2004)
- ld bc,X000d
- add hl,bc
- ld a,(hl)
- rlca
- rlca
- rlca
- jr nc,X0a36
- ret
-;
- ld hl,(X2004)
- ld l,(hl)
- ret
-;
-X0a49: push ix
- ld ix,X0000
- add ix,sp
- push af
- ld a,(ix+0x4)
- ld (ix+0xfe),a
- ld a,(ix+0x5)
- ld (ix+0xff),a
- ld c,(ix+0x6)
- ld b,(ix+0x7)
-X0a64: ld e,c
- ld d,b
- dec bc
- ld a,d
- or e
- jr z,X0a89
- ld de,(X2004)
- pop hl
- push hl
- ld a,(hl)
- inc (ix+0xfe)
- jr nz,X0a7a
- inc (ix+0xff)
-X0a7a: ld (de),a
-X0a7b: ld hl,(X2004)
- ld de,X000d
- add hl,de
- ld a,(hl)
- rlca
- rlca
- jr nc,X0a64
- jr X0a7b
-;
-X0a89: ld l,c
- ld h,b
- ld sp,ix
- pop ix
- ret
-;
- push ix
- ld ix,X0000
- add ix,sp
- ld hl,Xfffa
- add hl,sp
- ld sp,hl
- ld a,(ix+0x4)
- ld (ix+0xfa),a
- ld a,(ix+0x5)
- ld (ix+0xfb),a
- ld c,(ix+0x6)
- ld b,(ix+0x7)
- ld (ix+0xfc),0x0
- ld (ix+0xfd),0x0
-X0ab7: ld e,c
- ld d,b
- dec bc
- ld a,d
- or e
- jr z,X0b06
- ld hl,(X2004)
- ld e,(hl)
- pop hl
- push hl
- ld (hl),e
- inc (ix+0xfa)
- jr nz,X0acd
- inc (ix+0xfb)
-X0acd: ld de,(X2004)
- ld hl,X000d
- add hl,de
- ld (ix+0xfe),l
- ld (ix+0xff),h
- ld l,(ix+0xfe)
- ld h,(ix+0xff)
- ld a,(hl)
- rrca
- rrca
- rrca
- and 0x1
- jr nz,X0af6
- ld l,(ix+0xfe)
- ld h,(ix+0xff)
- ld a,(hl)
- rrca
- rrca
- and 0x1
- jr z,X0afc
-X0af6: pop hl
- push hl
- dec hl
- ex (sp),hl
- jr X0ab7
-;
-X0afc: inc (ix+0xfc)
- jr nz,X0ab7
- inc (ix+0xfd)
- jr X0ab7
-;
-X0b06: pop bc
- pop hl
- push hl
- push bc
- ld sp,ix
- pop ix
- ret
-;
-X0b0f: nop
- ld b,d
- ld (bc),a
- ld b,d
- nop
- ld b,b
-X0b15: ld bc,X0006
- ld a,b
- or c
- jr z,X0b24
- ld de,X2000
- ld hl,X0b0f
- ldir
-X0b24: ret
-;
- rst 0x38
-;
-; Miscellaneous equates
-;
-; These are addresses referenced in the code but
-; which are in the middle of a multibyte instruction
-; or are addresses outside the initialized space
-;
-X0002 equ 0x2
-X2002 equ 0x2002
-X2004 equ 0x2004
-Xfffa equ 0xfffa
-;
- end
-;
-
diff --git a/sw/z80_tests/usart/main.c b/sw/z80_tests/usart/main.c
deleted file mode 100644
index d2e1d8e..0000000
--- a/sw/z80_tests/usart/main.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "usart.h"
-
-void main(void)
-{
- usart_init(USART_BAUDRATE_1200, USART_PARITY_EVEN, USART_STOP_BITS_1);
- usart_write("Hello, World!\n", 13);
-
- while(1) {
- usart_write("done\n", 5);
- }
-}
diff --git a/sw/z80_tests/usart/usart.c b/sw/z80_tests/usart/usart.c
deleted file mode 120000
index 2927470..0000000
--- a/sw/z80_tests/usart/usart.c
+++ /dev/null
@@ -1 +0,0 @@
-../../z80/kernel/drivers/usart.c \ No newline at end of file
diff --git a/sw/z80_tests/usart/usart.h b/sw/z80_tests/usart/usart.h
deleted file mode 120000
index 84ee24d..0000000
--- a/sw/z80_tests/usart/usart.h
+++ /dev/null
@@ -1 +0,0 @@
-../../z80/kernel/include/drivers/usart.h \ No newline at end of file