1 ;
--------------------------------------------------------------------------
2 ; crt0.s
- Generic crt0.s for
a Rabbit
2000
3 ; derived from
"Generic crt0.s for a Z80"
5 ; Copyright
(C
) 2000, Michael Hope
6 ; Modified for Rabbit by Leland Morrison
2011
7 ; Copyright
(C
) 2020, Philipp Klaus Krause
9 ; This library is free software; you can redistribute it
and/or modify it
10 ; under the terms of the GNU General Public License as published by the
11 ; Free Software Foundation; either version
2, or (at your option
) any
14 ; This library is distributed in the hope that it will
be useful
,
15 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ; MERCHANTABILITY
or FITNESS FOR
A PARTICULAR PURPOSE. See the
17 ; GNU General Public License for more details.
19 ; You should have received
a copy of the GNU General Public License
20 ; along with this library; see the file COPYING. If
not, write to the
21 ; Free Software Foundation
, 51 Franklin Street
, Fifth Floor
, Boston
,
24 ; As
a special exception
, if you link this library with other files
,
25 ; some of which are compiled with SDCC
, to produce an executable
,
26 ; this library does
not by itself cause the resulting executable to
27 ;
be covered by the GNU General Public License. This exception does
28 ;
not however invalidate any other reasons why the executable file
29 ; might
be covered by the GNU General Public License.
30 ;
--------------------------------------------------------------------------
34 .globl ___sdcc_external_startup
36 GCSR
.equ 0x00 ; Global control / status register
40 MB0CR
.equ 0x14 ; Memory Bank 0 Control Register
41 MB1CR
.equ 0x15 ; Memory Bank 1 Control Register
42 MB2CR
.equ 0x16 ; Memory Bank 2 Control Register
43 MB3CR
.equ 0x17 ; Memory Bank 3 Control Register
47 ; Reset vector
- assuming smode0
and smode1 input pins are grounded
50 ; Setup internal interrupts. Upper byte of interrupt vector table address. For compatibility with Rabbit
3000, we choose this even here
(Rabbit
2000 allows odd values
, so
#1 could be used to save space).
54 ; Configure physical address space.
55 ; Leave MB0CR Flash at default slow at
/OE0
, /CS0
56 ; Assume slow RAM at
/CS1
, /OE1
, /WE1
61 ; Configure logical address space.
32 KB root segment followed by
8 KB data segment
, 16 KB stack segment
, 8 KB xpc segment.
62 ; By default
, SDCC will use the root segment for code
and constant data
, stack segment for data
(including stack
). data segment and xpc segment are then unused.
63 ld a, #0xa8 ; 16 KB stack segment at 0xa000, 8 KB data segment at 0x8000
67 ; Configure mapping to physical address space.
70 ld (STACKSEG
), a ; stack segment base at
0x76000 + 0xa000 = 0x80000
72 ; Set stack pointer directly above top of stack segment
75 call ___sdcc_external_startup
77 ; Initialise global variables. Skip if __sdcc_external_startup returned
78 ; non-zero value. Note
: calling convention version
1 only.
91 ld a, (GCSR
) ; clear interrupt
96 ; Secondary Watchdog
- Rabbit
3000A only
117 ; Syscall instruction
- Rabbit
3000A only
162 ;; Ordering of segments for the linker.
177 ;; Exit
- special code to the emulator
181 ;halt ; opcode for halt used for
'altd' on rabbit processors
200 ldi ; Work around new ldir wait state bug.
205 ld bc, #l__INITIALIZER
209 ld de
, #s__INITIALIZED
210 ld hl
, #s__INITIALIZER
212 ldi ; Work around new ldir wait state bug.