summaryrefslogtreecommitdiff
path: root/c/rvcontroller-libraries/rvcontroller-init-be.S
blob: 86389c74bc5676e1e8ae6a1b13171525cb8cc3c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#Assembly stub for C programs targeting RVController - Big-endian Flavor
#A product of Advanced Mesecons Devices, a Cheapie Systems company
#This is free and unencumbered software released into the public domain.
#See http://unlicense.org/ for more information

#This file should always be linked first.
#RVController has a default reset vector of 0,
#therefore _start should end up as the first thing in the file.

.section .text.startup
_start:

# Switch to big-endian mode (little-endian is default after reset)
li t0,0x20 # MBE
csrrs x0,0x310,t0 # 0x310 = mstatush

# Set up stack pointer
li sp,0x10000

# Call main function
call main

# Exit program
li a7,10
ecall

# Shouldn't ever get here, will crash if it does
ret

.globl _start