z80: uart echo test program (SDCC)
[z80.git] / z80 / uart / crt0.s
1 ;--------------------------------------------------------------------------
2 ;  crt0.s - Generic crt0.s for a Z80
3 ;
4 ;  Copyright (C) 2000, Michael Hope
5 ;
6 ;  This library is free software; you can redistribute it and/or modify it
7 ;  under the terms of the GNU General Public License as published by the
8 ;  Free Software Foundation; either version 2.1, or (at your option) any
9 ;  later version.
10 ;
11 ;  This library is distributed in the hope that it will be useful,
12 ;  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;  GNU General Public License for more details.
15 ;
16 ;  You should have received a copy of the GNU General Public License 
17 ;  along with this library; see the file COPYING. If not, write to the
18 ;  Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
19 ;   MA 02110-1301, USA.
20 ;
21 ;  As a special exception, if you link this library with other files,
22 ;  some of which are compiled with SDCC, to produce an executable,
23 ;  this library does not by itself cause the resulting executable to
24 ;  be covered by the GNU General Public License. This exception does
25 ;  not however invalidate any other reasons why the executable file
26 ;   might be covered by the GNU General Public License.
27 ;--------------------------------------------------------------------------
28
29         .module crt0
30         .globl  _main
31
32         .area   _HEADER (ABS)
33         ;; Reset vector
34         .org    0
35         jp      init
36
37         .org    0x08
38         reti
39         .org    0x10
40         reti
41         .org    0x18
42         reti
43         .org    0x20
44         reti
45         .org    0x28
46         reti
47         .org    0x30
48         reti
49         .org    0x38
50         reti
51
52         .org    0x100
53 init:
54         ;; Stack at the top of memory.
55         ld      sp,#0x7fff
56
57         ;; Initialise global variables
58         call    gsinit
59         call    _main
60         jp      _exit
61
62         ;; Ordering of segments for the linker.
63         .area   _HOME
64         .area   _CODE
65         .area   _GSINIT
66         .area   _GSFINAL
67
68         .area   _DATA
69         .area   _BSEG
70         .area   _BSS
71         .area   _HEAP
72
73         .area   _CODE
74 __clock::
75         ld      a,#2
76         rst     0x08
77         ret
78
79 _exit::
80         ;; Exit - special code to the emulator
81         ld      a,#0
82         rst     0x08
83 1$:
84         halt
85         jr      1$
86
87         .area   _GSINIT
88 gsinit::
89
90         .area   _GSFINAL
91         ret