# crt.asm
|
# crt.asm
|
# C RunTime:
|
# C RunTime:
|
# Used for initialization of small data
|
# Used for initialization of small data
|
# anchors and stack for programs compiled using
|
# anchors and stack for programs compiled using
|
# Xilinx Gnu Tools.
|
# Xilinx Gnu Tools.
|
# Used for initialization of user's bss area
|
# Used for initialization of user's bss area
|
# All external and static variables are initialized
|
# All external and static variables are initialized
|
|
|
.globl _start
|
.globl _start
|
|
|
.align 2
|
.align 2
|
.ent _start
|
.ent _start
|
_start:
|
_start:
|
|
nop /* to help simulation external program without block ram */
|
/* todo : initialize system vectors */
|
/* todo : initialize system vectors */
|
|
|
/* Set the Small Data Anchors and the Stack pointer */
|
/* Set the Small Data Anchors and the Stack pointer */
|
la r13, r0, _SDA_BASE_
|
la r13, r0, _SDA_BASE_
|
la r2, r0, _SDA2_BASE_
|
la r2, r0, _SDA2_BASE_
|
la r1, r0, _stack # stack is at end of heap
|
la r1, r0, _stack # stack is at end of heap
|
|
|
_crtinit: /* clear sbss */
|
_crtinit: /* clear sbss */
|
addi r6,r0,__sbss_start /* SBSS beginning */
|
addi r6,r0,__sbss_start /* SBSS beginning */
|
addi r7,r0,__sbss_end /* SBSS end */
|
addi r7,r0,__sbss_end /* SBSS end */
|
rsub r18,r6,r7 /* Compare */
|
rsub r18,r6,r7 /* Compare */
|
blei r18,.Lendsbss
|
blei r18,.Lendsbss
|
.Lloopsbss:
|
.Lloopsbss:
|
sw r0,r6,r0
|
sw r0,r6,r0
|
addi r6,r6,4
|
addi r6,r6,4
|
rsub r18,r6,r7
|
rsub r18,r6,r7
|
bgti r18,.Lloopsbss
|
bgti r18,.Lloopsbss
|
.Lendsbss: /* clear bss */
|
.Lendsbss: /* clear bss */
|
addi r6,r0,__bss_start /* BSS beginning */
|
addi r6,r0,__bss_start /* BSS beginning */
|
addi r7,r0,__bss_end /* BSS end */
|
addi r7,r0,__bss_end /* BSS end */
|
rsub r18,r6,r7 /* Compare */
|
rsub r18,r6,r7 /* Compare */
|
blei r18,.Lendbss
|
blei r18,.Lendbss
|
.Lloopbss:
|
.Lloopbss:
|
sw r0,r6,r0
|
sw r0,r6,r0
|
addi r6,r6,4
|
addi r6,r6,4
|
rsub r18,r6,r7
|
rsub r18,r6,r7
|
bgti r18,.Lloopbss
|
bgti r18,.Lloopbss
|
.Lendbss:
|
.Lendbss:
|
|
|
brlid r15,main # enter main program (ignoring parameters: r5, r6 & r7)
|
brlid r15,main # enter main program (ignoring parameters: r5, r6 & r7)
|
nop # fall throught to exit
|
nop # fall throught to exit
|
.end _start
|
.end _start
|
|
|
.globl exit # exit library call
|
.globl exit # exit library call
|
.ent exit
|
.ent exit
|
exit:
|
exit:
|
brai 0x0 # enter monitor again...
|
brai 0x0 # enter monitor again...
|
.end exit
|
.end exit
|
|
|