First commit
This commit is contained in:
commit
c29ed0580a
8
.build/bios.lst
Normal file
8
.build/bios.lst
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
0000 1 __bios_call::
|
||||||
|
0000 2A 01 00 [16] 2 ld hl, (1)
|
||||||
|
0003 85 [ 4] 3 add l
|
||||||
|
0004 6F [ 4] 4 ld l, a
|
||||||
|
0005 D2r09r00 [10] 5 jp nc, bios_call_cont
|
||||||
|
0008 24 [ 4] 6 inc h
|
||||||
|
0009 7 bios_call_cont:
|
||||||
|
0009 E9 [ 4] 8 jp (hl)
|
13
.build/bios.rel
Normal file
13
.build/bios.rel
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
XL2
|
||||||
|
H 1 areas 2 global symbols
|
||||||
|
S .__.ABS. Def0000
|
||||||
|
A _CODE size A flags 0 addr 0
|
||||||
|
S __bios_call Def0000
|
||||||
|
T 00 00
|
||||||
|
R 00 00 00 00
|
||||||
|
T 00 00 2A 01 00 85 6F D2 09 00 24
|
||||||
|
R 00 00 00 00 00 08 00 00
|
||||||
|
T 09 00
|
||||||
|
R 00 00 00 00
|
||||||
|
T 09 00 E9
|
||||||
|
R 00 00 00 00
|
15
.build/bios.sym
Normal file
15
.build/bios.sym
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180 / ZX-Next / eZ80), page 1.
|
||||||
|
Hexadecimal [16-Bits]
|
||||||
|
|
||||||
|
Symbol Table
|
||||||
|
|
||||||
|
.__.$$$.= 2710 L | .__.ABS.= 0000 G | .__.CPU.= 0000 L
|
||||||
|
.__.H$L.= 0000 L | 0 __bios_c 0000 GR | 0 bios_cal 0009 R
|
||||||
|
|
||||||
|
ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180 / ZX-Next / eZ80), page 2.
|
||||||
|
Hexadecimal [16-Bits]
|
||||||
|
|
||||||
|
Area Table
|
||||||
|
|
||||||
|
0 _CODE size A flags 0
|
||||||
|
|
96
.build/console.asm
Normal file
96
.build/console.asm
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
;--------------------------------------------------------
|
||||||
|
; File Created by SDCC : free open source ANSI-C Compiler
|
||||||
|
; Version 4.0.0 #11528 (Linux)
|
||||||
|
;--------------------------------------------------------
|
||||||
|
.module console
|
||||||
|
.optsdcc -mz80
|
||||||
|
|
||||||
|
;--------------------------------------------------------
|
||||||
|
; Public variables in this module
|
||||||
|
;--------------------------------------------------------
|
||||||
|
.globl _get_char
|
||||||
|
.globl _put_char
|
||||||
|
.globl _put_string
|
||||||
|
;--------------------------------------------------------
|
||||||
|
; special function registers
|
||||||
|
;--------------------------------------------------------
|
||||||
|
;--------------------------------------------------------
|
||||||
|
; ram data
|
||||||
|
;--------------------------------------------------------
|
||||||
|
.area _DATA
|
||||||
|
;--------------------------------------------------------
|
||||||
|
; ram data
|
||||||
|
;--------------------------------------------------------
|
||||||
|
.area _INITIALIZED
|
||||||
|
;--------------------------------------------------------
|
||||||
|
; absolute external ram data
|
||||||
|
;--------------------------------------------------------
|
||||||
|
.area _DABS (ABS)
|
||||||
|
;--------------------------------------------------------
|
||||||
|
; global & static initialisations
|
||||||
|
;--------------------------------------------------------
|
||||||
|
.area _HOME
|
||||||
|
.area _GSINIT
|
||||||
|
.area _GSFINAL
|
||||||
|
.area _GSINIT
|
||||||
|
;--------------------------------------------------------
|
||||||
|
; Home
|
||||||
|
;--------------------------------------------------------
|
||||||
|
.area _HOME
|
||||||
|
.area _HOME
|
||||||
|
;--------------------------------------------------------
|
||||||
|
; code
|
||||||
|
;--------------------------------------------------------
|
||||||
|
.area _CODE
|
||||||
|
;src/console.c:3: char get_char() __naked {
|
||||||
|
; ---------------------------------
|
||||||
|
; Function get_char
|
||||||
|
; ---------------------------------
|
||||||
|
_get_char::
|
||||||
|
;src/console.c:9: __endasm;
|
||||||
|
ld a, #6
|
||||||
|
call __bios_call
|
||||||
|
ld l, a
|
||||||
|
ret
|
||||||
|
;src/console.c:10: }
|
||||||
|
;src/console.c:12: void put_char(char c) __naked {
|
||||||
|
; ---------------------------------
|
||||||
|
; Function put_char
|
||||||
|
; ---------------------------------
|
||||||
|
_put_char::
|
||||||
|
;src/console.c:21: __endasm;
|
||||||
|
ld iy, #2
|
||||||
|
add iy, sp
|
||||||
|
ld c, 0(iy)
|
||||||
|
ld a, #9
|
||||||
|
call __bios_call
|
||||||
|
ret
|
||||||
|
;src/console.c:22: }
|
||||||
|
;src/console.c:24: void put_string(char* s) {
|
||||||
|
; ---------------------------------
|
||||||
|
; Function put_string
|
||||||
|
; ---------------------------------
|
||||||
|
_put_string::
|
||||||
|
;src/console.c:25: while (*s) {
|
||||||
|
pop de
|
||||||
|
pop bc
|
||||||
|
push bc
|
||||||
|
push de
|
||||||
|
00101$:
|
||||||
|
ld a, (bc)
|
||||||
|
or a, a
|
||||||
|
ret Z
|
||||||
|
;src/console.c:26: put_char(*s);
|
||||||
|
push bc
|
||||||
|
push af
|
||||||
|
inc sp
|
||||||
|
call _put_char
|
||||||
|
inc sp
|
||||||
|
pop bc
|
||||||
|
;src/console.c:27: s++;
|
||||||
|
inc bc
|
||||||
|
;src/console.c:29: }
|
||||||
|
jr 00101$
|
||||||
|
.area _CODE
|
||||||
|
.area _INITIALIZER
|
||||||
|
.area _CABS (ABS)
|
96
.build/console.lst
Normal file
96
.build/console.lst
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
1 ;--------------------------------------------------------
|
||||||
|
2 ; File Created by SDCC : free open source ANSI-C Compiler
|
||||||
|
3 ; Version 4.0.0 #11528 (Linux)
|
||||||
|
4 ;--------------------------------------------------------
|
||||||
|
5 .module console
|
||||||
|
6 .optsdcc -mz80
|
||||||
|
7
|
||||||
|
8 ;--------------------------------------------------------
|
||||||
|
9 ; Public variables in this module
|
||||||
|
10 ;--------------------------------------------------------
|
||||||
|
11 .globl _get_char
|
||||||
|
12 .globl _put_char
|
||||||
|
13 .globl _put_string
|
||||||
|
14 ;--------------------------------------------------------
|
||||||
|
15 ; special function registers
|
||||||
|
16 ;--------------------------------------------------------
|
||||||
|
17 ;--------------------------------------------------------
|
||||||
|
18 ; ram data
|
||||||
|
19 ;--------------------------------------------------------
|
||||||
|
20 .area _DATA
|
||||||
|
21 ;--------------------------------------------------------
|
||||||
|
22 ; ram data
|
||||||
|
23 ;--------------------------------------------------------
|
||||||
|
24 .area _INITIALIZED
|
||||||
|
25 ;--------------------------------------------------------
|
||||||
|
26 ; absolute external ram data
|
||||||
|
27 ;--------------------------------------------------------
|
||||||
|
28 .area _DABS (ABS)
|
||||||
|
29 ;--------------------------------------------------------
|
||||||
|
30 ; global & static initialisations
|
||||||
|
31 ;--------------------------------------------------------
|
||||||
|
32 .area _HOME
|
||||||
|
33 .area _GSINIT
|
||||||
|
34 .area _GSFINAL
|
||||||
|
35 .area _GSINIT
|
||||||
|
36 ;--------------------------------------------------------
|
||||||
|
37 ; Home
|
||||||
|
38 ;--------------------------------------------------------
|
||||||
|
39 .area _HOME
|
||||||
|
40 .area _HOME
|
||||||
|
41 ;--------------------------------------------------------
|
||||||
|
42 ; code
|
||||||
|
43 ;--------------------------------------------------------
|
||||||
|
44 .area _CODE
|
||||||
|
45 ;src/console.c:3: char get_char() __naked {
|
||||||
|
46 ; ---------------------------------
|
||||||
|
47 ; Function get_char
|
||||||
|
48 ; ---------------------------------
|
||||||
|
0000 49 _get_char::
|
||||||
|
50 ;src/console.c:9: __endasm;
|
||||||
|
0000 3E 06 [ 7] 51 ld a, #6
|
||||||
|
0002 CDr00r00 [17] 52 call __bios_call
|
||||||
|
0005 6F [ 4] 53 ld l, a
|
||||||
|
0006 C9 [10] 54 ret
|
||||||
|
55 ;src/console.c:10: }
|
||||||
|
56 ;src/console.c:12: void put_char(char c) __naked {
|
||||||
|
57 ; ---------------------------------
|
||||||
|
58 ; Function put_char
|
||||||
|
59 ; ---------------------------------
|
||||||
|
0007 60 _put_char::
|
||||||
|
61 ;src/console.c:21: __endasm;
|
||||||
|
0007 FD 21 02 00 [14] 62 ld iy, #2
|
||||||
|
000B FD 39 [15] 63 add iy, sp
|
||||||
|
000D FD 4E 00 [19] 64 ld c, 0(iy)
|
||||||
|
0010 3E 09 [ 7] 65 ld a, #9
|
||||||
|
0012 CDr00r00 [17] 66 call __bios_call
|
||||||
|
0015 C9 [10] 67 ret
|
||||||
|
68 ;src/console.c:22: }
|
||||||
|
69 ;src/console.c:24: void put_string(char* s) {
|
||||||
|
70 ; ---------------------------------
|
||||||
|
71 ; Function put_string
|
||||||
|
72 ; ---------------------------------
|
||||||
|
0016 73 _put_string::
|
||||||
|
74 ;src/console.c:25: while (*s) {
|
||||||
|
0016 D1 [10] 75 pop de
|
||||||
|
0017 C1 [10] 76 pop bc
|
||||||
|
0018 C5 [11] 77 push bc
|
||||||
|
0019 D5 [11] 78 push de
|
||||||
|
001A 79 00101$:
|
||||||
|
001A 0A [ 7] 80 ld a, (bc)
|
||||||
|
001B B7 [ 4] 81 or a, a
|
||||||
|
001C C8 [11] 82 ret Z
|
||||||
|
83 ;src/console.c:26: put_char(*s);
|
||||||
|
001D C5 [11] 84 push bc
|
||||||
|
001E F5 [11] 85 push af
|
||||||
|
001F 33 [ 6] 86 inc sp
|
||||||
|
0020 CDr07r00 [17] 87 call _put_char
|
||||||
|
0023 33 [ 6] 88 inc sp
|
||||||
|
0024 C1 [10] 89 pop bc
|
||||||
|
90 ;src/console.c:27: s++;
|
||||||
|
0025 03 [ 6] 91 inc bc
|
||||||
|
92 ;src/console.c:29: }
|
||||||
|
0026 18 F2 [12] 93 jr 00101$
|
||||||
|
94 .area _CODE
|
||||||
|
95 .area _INITIALIZER
|
||||||
|
96 .area _CABS (ABS)
|
36
.build/console.rel
Normal file
36
.build/console.rel
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
XL2
|
||||||
|
H 9 areas 5 global symbols
|
||||||
|
M console
|
||||||
|
O -mz80
|
||||||
|
S .__.ABS. Def0000
|
||||||
|
S __bios_call Ref0000
|
||||||
|
A _CODE size 28 flags 0 addr 0
|
||||||
|
S _get_char Def0000
|
||||||
|
S _put_string Def0016
|
||||||
|
S _put_char Def0007
|
||||||
|
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 3E 06 CD 00 00 6F C9
|
||||||
|
R 00 00 00 00 02 05 01 00
|
||||||
|
T 07 00
|
||||||
|
R 00 00 00 00
|
||||||
|
T 07 00 FD 21 02 00 FD 39 FD 4E 00 3E 09 CD 00 00
|
||||||
|
R 00 00 00 00 02 0E 01 00
|
||||||
|
T 15 00 C9
|
||||||
|
R 00 00 00 00
|
||||||
|
T 16 00
|
||||||
|
R 00 00 00 00
|
||||||
|
T 16 00 D1 C1 C5 D5
|
||||||
|
R 00 00 00 00
|
||||||
|
T 1A 00
|
||||||
|
R 00 00 00 00
|
||||||
|
T 1A 00 0A B7 C8 C5 F5 33 CD 07 00 33 C1 03 18 F2
|
||||||
|
R 00 00 00 00 00 09 00 00
|
30
.build/console.sym
Normal file
30
.build/console.sym
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180 / ZX-Next / eZ80), page 1.
|
||||||
|
Hexadecimal [16-Bits]
|
||||||
|
|
||||||
|
Symbol Table
|
||||||
|
|
||||||
|
.__.$$$. = 2710 L
|
||||||
|
.__.ABS. = 0000 G
|
||||||
|
.__.CPU. = 0000 L
|
||||||
|
.__.H$L. = 0000 L
|
||||||
|
__bios_call **** GX
|
||||||
|
0 _get_char 0000 GR
|
||||||
|
0 _put_char 0007 GR
|
||||||
|
0 _put_string 0016 GR
|
||||||
|
|
||||||
|
|
||||||
|
ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180 / ZX-Next / eZ80), page 2.
|
||||||
|
Hexadecimal [16-Bits]
|
||||||
|
|
||||||
|
Area Table
|
||||||
|
|
||||||
|
0 _CODE size 28 flags 0
|
||||||
|
1 _DATA size 0 flags 0
|
||||||
|
2 _INITIALIZED size 0 flags 0
|
||||||
|
3 _DABS size 0 flags 8
|
||||||
|
4 _HOME size 0 flags 0
|
||||||
|
5 _GSINIT size 0 flags 0
|
||||||
|
6 _GSFINAL size 0 flags 0
|
||||||
|
7 _INITIALIZER size 0 flags 0
|
||||||
|
8 _CABS size 0 flags 8
|
||||||
|
|
BIN
.build/crt.a
Normal file
BIN
.build/crt.a
Normal file
Binary file not shown.
52
.build/crt0.lst
Normal file
52
.build/crt0.lst
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
1 ;--------------------------------------------------------------------------
|
||||||
|
2 ; cpm0.s - Generic cpm0.s for a Z80 CP/M-80 v2.2 Application
|
||||||
|
3 ; Copyright (C) 2011, Douglas Goodall All Rights Reserved.
|
||||||
|
4 ;--------------------------------------------------------------------------
|
||||||
|
5
|
||||||
|
6 .area _CODE
|
||||||
|
0000 7 .ds 0x0100
|
||||||
|
0100 8 init:
|
||||||
|
9 ;; Define an adequate stack
|
||||||
|
0100 31r00r01 [10] 10 ld sp, #stktop
|
||||||
|
11
|
||||||
|
12 ;; Initialise global variables
|
||||||
|
0103 CDr00r00 [17] 13 call gsinit
|
||||||
|
14
|
||||||
|
15 ;; Call the C main routine
|
||||||
|
0106 CDr00r00 [17] 16 call _main
|
||||||
|
17
|
||||||
|
18 ;; Return back to CP/M
|
||||||
|
0109 0E 00 [ 7] 19 ld c, #0
|
||||||
|
010B CD 05 00 [17] 20 call 5
|
||||||
|
21
|
||||||
|
22 ;; Ordering of segments for the linker.
|
||||||
|
23 .area _TPA
|
||||||
|
24
|
||||||
|
25 .area _HOME
|
||||||
|
26 .area _CODE
|
||||||
|
27 .area _INITIALIZER
|
||||||
|
28 .area _GSINIT
|
||||||
|
29 .area _GSFINAL
|
||||||
|
30 .area _DATA
|
||||||
|
31 .area _INITIALIZED
|
||||||
|
32
|
||||||
|
33 .area _STACK
|
||||||
|
0000 34 .ds 256
|
||||||
|
0100 35 stktop:
|
||||||
|
36
|
||||||
|
37 .area _GSINIT
|
||||||
|
0000 38 gsinit::
|
||||||
|
0000 01r00r00 [10] 39 ld bc, #l__INITIALIZER
|
||||||
|
0003 78 [ 4] 40 ld a, b
|
||||||
|
0004 B1 [ 4] 41 or a, c
|
||||||
|
0005 28 08 [12] 42 jr z, gsinit_next
|
||||||
|
0007 11r00r00 [10] 43 ld de, #s__INITIALIZED
|
||||||
|
000A 21r00r00 [10] 44 ld hl, #s__INITIALIZER
|
||||||
|
000D ED B0 [21] 45 ldir
|
||||||
|
000F 46 gsinit_next:
|
||||||
|
47 .area _GSFINAL
|
||||||
|
0000 C9 [10] 48 ret
|
||||||
|
49
|
||||||
|
50 ;;;;;;;;;;;;;;;;
|
||||||
|
51 ; eof - cpm0.s ;
|
||||||
|
52 ;;;;;;;;;;;;;;;;
|
37
.build/crt0.rel
Normal file
37
.build/crt0.rel
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
XL2
|
||||||
|
H 9 areas 6 global symbols
|
||||||
|
S _main Ref0000
|
||||||
|
S .__.ABS. Def0000
|
||||||
|
S s__INITIALIZED Ref0000
|
||||||
|
S l__INITIALIZER Ref0000
|
||||||
|
S s__INITIALIZER Ref0000
|
||||||
|
A _CODE size 10E flags 0 addr 0
|
||||||
|
A _TPA size 0 flags 0 addr 0
|
||||||
|
A _HOME size 0 flags 0 addr 0
|
||||||
|
A _INITIALIZER size 0 flags 0 addr 0
|
||||||
|
A _GSINIT size F 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 _STACK size 100 flags 0 addr 0
|
||||||
|
T 00 00
|
||||||
|
R 00 00 00 00
|
||||||
|
T 00 01
|
||||||
|
R 00 00 00 00
|
||||||
|
T 00 01 31 00 01 CD 00 00 CD 00 00 0E 00 CD 05 00
|
||||||
|
R 00 00 00 00 00 03 08 00 00 06 04 00 02 09 00 00
|
||||||
|
T 00 00
|
||||||
|
R 00 00 08 00
|
||||||
|
T 00 01
|
||||||
|
R 00 00 08 00
|
||||||
|
T 00 00
|
||||||
|
R 00 00 04 00
|
||||||
|
T 00 00 01 00 00 78 B1 28 08 11 00 00 21 00 00 ED
|
||||||
|
R 00 00 04 00 02 03 03 00 02 0A 02 00 02 0D 04 00
|
||||||
|
T 0E 00 B0
|
||||||
|
R 00 00 04 00
|
||||||
|
T 0F 00
|
||||||
|
R 00 00 04 00
|
||||||
|
T 00 00 C9
|
||||||
|
R 00 00 05 00
|
25
.build/crt0.sym
Normal file
25
.build/crt0.sym
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180 / ZX-Next / eZ80), page 1.
|
||||||
|
Hexadecimal [16-Bits]
|
||||||
|
|
||||||
|
Symbol Table
|
||||||
|
|
||||||
|
.__.$$$.= 2710 L | .__.ABS.= 0000 G | .__.CPU.= 0000 L
|
||||||
|
.__.H$L.= 0000 L | _main **** GX | 4 gsinit 0000 GR
|
||||||
|
4 gsinit_n 000F R | 0 init 0100 R | l__INITI **** GX
|
||||||
|
s__INITI **** GX | s__INITI **** GX | 8 stktop 0100 R
|
||||||
|
|
||||||
|
ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180 / ZX-Next / eZ80), page 2.
|
||||||
|
Hexadecimal [16-Bits]
|
||||||
|
|
||||||
|
Area Table
|
||||||
|
|
||||||
|
0 _CODE size 10E flags 0
|
||||||
|
1 _TPA size 0 flags 0
|
||||||
|
2 _HOME size 0 flags 0
|
||||||
|
3 _INITIAL size 0 flags 0
|
||||||
|
4 _GSINIT size F flags 0
|
||||||
|
5 _GSFINAL size 1 flags 0
|
||||||
|
6 _DATA size 0 flags 0
|
||||||
|
7 _INITIAL size 0 flags 0
|
||||||
|
8 _STACK size 100 flags 0
|
||||||
|
|
29
.build/random.lst
Normal file
29
.build/random.lst
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
1 ; Fast RND
|
||||||
|
2 ;
|
||||||
|
3 ; An 8-bit pseudo-random number generator,
|
||||||
|
4 ; using a similar method to the Spectrum ROM,
|
||||||
|
5 ; - without the overhead of the Spectrum ROM.
|
||||||
|
6 ;
|
||||||
|
7 ; R = random number seed
|
||||||
|
8 ; an integer in the range [1, 256]
|
||||||
|
9 ;
|
||||||
|
10 ; R -> (33*R) mod 257
|
||||||
|
11 ;
|
||||||
|
12 ; S = R - 1
|
||||||
|
13 ; an 8-bit unsigned integer
|
||||||
|
14
|
||||||
|
0000 15 _random::
|
||||||
|
0000 3Ar00r00 [13] 16 ld a, (_seed)
|
||||||
|
0003 47 [ 4] 17 ld b, a
|
||||||
|
18
|
||||||
|
0004 0F [ 4] 19 rrca ; multiply by 32
|
||||||
|
0005 0F [ 4] 20 rrca
|
||||||
|
0006 0F [ 4] 21 rrca
|
||||||
|
0007 EE 1F [ 7] 22 xor #0x1f
|
||||||
|
23
|
||||||
|
0009 80 [ 4] 24 add a, b
|
||||||
|
000A DE FF [ 7] 25 sbc a, #255 ; carry
|
||||||
|
26
|
||||||
|
000C 32r00r00 [13] 27 ld (_seed), a
|
||||||
|
000F 6F [ 4] 28 ld l, a
|
||||||
|
0010 C9 [10] 29 ret
|
12
.build/random.rel
Normal file
12
.build/random.rel
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
XL2
|
||||||
|
H 1 areas 3 global symbols
|
||||||
|
S _seed Ref0000
|
||||||
|
S .__.ABS. Def0000
|
||||||
|
A _CODE size 11 flags 0 addr 0
|
||||||
|
S _random Def0000
|
||||||
|
T 00 00
|
||||||
|
R 00 00 00 00
|
||||||
|
T 00 00 3A 00 00 47 0F 0F 0F EE 1F 80 DE FF 32
|
||||||
|
R 00 00 00 00 02 03 00 00
|
||||||
|
T 0D 00 00 00 6F C9
|
||||||
|
R 00 00 00 00 02 02 00 00
|
15
.build/random.sym
Normal file
15
.build/random.sym
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180 / ZX-Next / eZ80), page 1.
|
||||||
|
Hexadecimal [16-Bits]
|
||||||
|
|
||||||
|
Symbol Table
|
||||||
|
|
||||||
|
.__.$$$.= 2710 L | .__.ABS.= 0000 G | .__.CPU.= 0000 L
|
||||||
|
.__.H$L.= 0000 L | 0 _random 0000 GR | _seed **** GX
|
||||||
|
|
||||||
|
ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180 / ZX-Next / eZ80), page 2.
|
||||||
|
Hexadecimal [16-Bits]
|
||||||
|
|
||||||
|
Area Table
|
||||||
|
|
||||||
|
0 _CODE size 11 flags 0
|
||||||
|
|
42
Makefile
Normal file
42
Makefile
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
AS = sdasz80
|
||||||
|
CC = sdcc
|
||||||
|
AR = sdar
|
||||||
|
|
||||||
|
BUILD = .build
|
||||||
|
|
||||||
|
TARGET = crt
|
||||||
|
OPT = s
|
||||||
|
|
||||||
|
CFLAGS = -mz80 -D__SDCC__ -Iinclude
|
||||||
|
ASFLAGS = -plosgff
|
||||||
|
|
||||||
|
SRC = \
|
||||||
|
src/crt0.s \
|
||||||
|
src/bios.s \
|
||||||
|
src/random.s \
|
||||||
|
src/console.c \
|
||||||
|
|
||||||
|
OBJ_1 = $(notdir $(SRC:.c=.rel))
|
||||||
|
OBJ_2 = $(notdir $(OBJ_1:.s=.rel))
|
||||||
|
OBJ = $(addprefix $(BUILD)/, $(OBJ_2))
|
||||||
|
vpath %.c $(sort $(dir $(SRC)))
|
||||||
|
vpath %.s $(sort $(dir $(SRC)))
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
|
|
||||||
|
all: $(BUILD) $(BUILD)/$(TARGET).a
|
||||||
|
|
||||||
|
$(BUILD)/%.rel: %.c Makefile | $(BUILD)
|
||||||
|
$(CC) -c $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
$(BUILD)/%.rel: %.s Makefile | $(BUILD)
|
||||||
|
$(AS) $(ASFLAGS) $@ $<
|
||||||
|
|
||||||
|
$(BUILD)/$(TARGET).a: $(OBJ)
|
||||||
|
$(AR) rcs $@ $(OBJ)
|
||||||
|
|
||||||
|
$(BUILD):
|
||||||
|
mkdir $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -fr $(BUILD)
|
2
README.md
Normal file
2
README.md
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Based on:
|
||||||
|
https://github.com/hkzlab/sdcc-cpm-example
|
7
include/console.h
Normal file
7
include/console.h
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
void put_char(char c);
|
||||||
|
char get_char();
|
||||||
|
|
||||||
|
void put_string(char* s);
|
||||||
|
|
3
include/random.h
Normal file
3
include/random.h
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
uint8_t random();
|
7
include/types.h
Normal file
7
include/types.h
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
typedef signed char int8_t;
|
||||||
|
typedef short int int16_t;
|
||||||
|
|
||||||
|
typedef unsigned char uint8_t;
|
||||||
|
typedef unsigned short uint16_t;
|
8
src/bios.s
Normal file
8
src/bios.s
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
__bios_call::
|
||||||
|
ld hl, (1)
|
||||||
|
add l
|
||||||
|
ld l, a
|
||||||
|
jp nc, bios_call_cont
|
||||||
|
inc h
|
||||||
|
bios_call_cont:
|
||||||
|
jp (hl)
|
29
src/console.c
Normal file
29
src/console.c
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#include "console.h"
|
||||||
|
|
||||||
|
char get_char() __naked {
|
||||||
|
__asm
|
||||||
|
ld a, #6
|
||||||
|
call __bios_call
|
||||||
|
ld l, a
|
||||||
|
ret
|
||||||
|
__endasm;
|
||||||
|
}
|
||||||
|
|
||||||
|
void put_char(char c) __naked {
|
||||||
|
c;
|
||||||
|
__asm
|
||||||
|
ld iy, #2
|
||||||
|
add iy, sp
|
||||||
|
ld c, 0(iy)
|
||||||
|
ld a, #9
|
||||||
|
call __bios_call
|
||||||
|
ret
|
||||||
|
__endasm;
|
||||||
|
}
|
||||||
|
|
||||||
|
void put_string(char* s) {
|
||||||
|
while (*s) {
|
||||||
|
put_char(*s);
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
}
|
52
src/crt0.s
Normal file
52
src/crt0.s
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
;--------------------------------------------------------------------------
|
||||||
|
; cpm0.s - Generic cpm0.s for a Z80 CP/M-80 v2.2 Application
|
||||||
|
; Copyright (C) 2011, Douglas Goodall All Rights Reserved.
|
||||||
|
;--------------------------------------------------------------------------
|
||||||
|
|
||||||
|
.area _CODE
|
||||||
|
.ds 0x0100
|
||||||
|
init:
|
||||||
|
;; Define an adequate stack
|
||||||
|
ld sp, #stktop
|
||||||
|
|
||||||
|
;; Initialise global variables
|
||||||
|
call gsinit
|
||||||
|
|
||||||
|
;; Call the C main routine
|
||||||
|
call _main
|
||||||
|
|
||||||
|
;; Return back to CP/M
|
||||||
|
ld c, #0
|
||||||
|
call 5
|
||||||
|
|
||||||
|
;; Ordering of segments for the linker.
|
||||||
|
.area _TPA
|
||||||
|
|
||||||
|
.area _HOME
|
||||||
|
.area _CODE
|
||||||
|
.area _INITIALIZER
|
||||||
|
.area _GSINIT
|
||||||
|
.area _GSFINAL
|
||||||
|
.area _DATA
|
||||||
|
.area _INITIALIZED
|
||||||
|
|
||||||
|
.area _STACK
|
||||||
|
.ds 256
|
||||||
|
stktop:
|
||||||
|
|
||||||
|
.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
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;
|
||||||
|
; eof - cpm0.s ;
|
||||||
|
;;;;;;;;;;;;;;;;
|
29
src/random.s
Normal file
29
src/random.s
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
; Fast RND
|
||||||
|
;
|
||||||
|
; An 8-bit pseudo-random number generator,
|
||||||
|
; using a similar method to the Spectrum ROM,
|
||||||
|
; - without the overhead of the Spectrum ROM.
|
||||||
|
;
|
||||||
|
; R = random number seed
|
||||||
|
; an integer in the range [1, 256]
|
||||||
|
;
|
||||||
|
; R -> (33*R) mod 257
|
||||||
|
;
|
||||||
|
; S = R - 1
|
||||||
|
; an 8-bit unsigned integer
|
||||||
|
|
||||||
|
_random::
|
||||||
|
ld a, (_seed)
|
||||||
|
ld b, a
|
||||||
|
|
||||||
|
rrca ; multiply by 32
|
||||||
|
rrca
|
||||||
|
rrca
|
||||||
|
xor #0x1f
|
||||||
|
|
||||||
|
add a, b
|
||||||
|
sbc a, #255 ; carry
|
||||||
|
|
||||||
|
ld (_seed), a
|
||||||
|
ld l, a
|
||||||
|
ret
|
Loading…
Reference in New Issue
Block a user