1 |
53 |
dgisselq |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2 |
|
|
;;
|
3 |
|
|
;; Filename: asmstartup.s
|
4 |
|
|
;;
|
5 |
|
|
;; Project: CMod S6 System on a Chip, ZipCPU demonstration project
|
6 |
|
|
;;
|
7 |
|
|
;; Purpose: A small assembly routine, designed to place the startup code
|
8 |
|
|
;; into the very beginning of the program space (i.e. crt0.s).
|
9 |
|
|
;; This startup code *must* start at the RESET_ADDRESS of the ZipCPU. It
|
10 |
|
|
;; does two things: 1) loads a valid stack pointer, and 2) jumps to the
|
11 |
|
|
;; entry point in the program which (as a result of this startup code)
|
12 |
|
|
;; may be anywhere in the address space.
|
13 |
|
|
;;
|
14 |
|
|
;; Creator: Dan Gisselquist, Ph.D.
|
15 |
|
|
;; Gisselquist Technology, LLC
|
16 |
|
|
;;
|
17 |
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
18 |
|
|
;;
|
19 |
|
|
;; Copyright (C) 2015-2017, Gisselquist Technology, LLC
|
20 |
|
|
;;
|
21 |
|
|
;; This program is free software (firmware): you can redistribute it and/or
|
22 |
|
|
;; modify it under the terms of the GNU General Public License as published
|
23 |
|
|
;; by the Free Software Foundation, either version 3 of the License, or (at
|
24 |
|
|
;; your option) any later version.
|
25 |
|
|
;;
|
26 |
|
|
;; This program is distributed in the hope that it will be useful, but WITHOUT
|
27 |
|
|
;; ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
28 |
|
|
;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
29 |
|
|
;; for more details.
|
30 |
|
|
;;
|
31 |
|
|
;; You should have received a copy of the GNU General Public License along
|
32 |
|
|
;; with this program. (It's in the $(ROOT)/doc directory, run make with no
|
33 |
|
|
;; target there if the PDF file isn't present.) If not, see
|
34 |
|
|
;; <http://www.gnu.org/licenses/> for a copy.
|
35 |
|
|
;;
|
36 |
|
|
;; License: GPL, v3, as defined and found on www.gnu.org,
|
37 |
|
|
;; http://www.gnu.org/licenses/gpl.html
|
38 |
|
|
;;
|
39 |
|
|
;;
|
40 |
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
41 |
|
|
;;
|
42 |
|
|
;;
|
43 |
|
|
.section .start,"ax",@progbits
|
44 |
|
|
.global _start
|
45 |
|
|
.type _start,@function
|
46 |
|
|
_start:
|
47 |
|
|
NDUMP
|
48 |
|
|
LDI 255,R0 ; Turn all the LEDs on
|
49 |
|
|
SW R0,(SPIO)
|
50 |
|
|
MOV kernel_exit(PC),uPC
|
51 |
|
|
LDI _top_of_stack,SP
|
52 |
|
|
JSR entry
|
53 |
|
|
NEXIT R0 ; Exit on return if in a simulator
|
54 |
|
|
kernel_exit:
|
55 |
|
|
HALT ; Otherwise just halt the CPU
|
56 |
|
|
BRA kernel_exit ; In case were called from user mode
|
57 |
|
|
|
58 |
|
|
.set SPIO, 0x0414
|