OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [libgloss/] [m32r/] [crt0.S] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
        .text
2
        .balign 4
3
        .global _start
4
_start:
5
 
6
        ld24    sp, _stack
7
        ldi     fp, #0
8
 
9
# Clear the BSS.  Do it in two parts for efficiency: longwords first
10
# for most of it, then the remaining 0 to 3 bytes.
11
 
12 56 joel
        seth    r2, #shigh(__bss_start)
13
        add3    r2, r2, #low(__bss_start); R2 = start of BSS
14
        seth    r3, #shigh(_end)
15
        add3    r3, r3, #low(_end)      ; R3 = end of BSS + 1
16
 
17 39 lampret
        sub     r3, r2          ; R3 = BSS size in bytes
18
        mv      r4, r3
19
        srli    r4, #2          ; R4 = BSS size in longwords (rounded down)
20
        ldi     r1, #0          ; clear R1 for longword store
21
        addi    r2, #-4         ; account for pre-inc store
22
        beqz    r4, .Lendloop1  ; any more to go?
23
.Lloop1:
24
        st      r1, @+r2        ; yep, zero out another longword
25
        addi    r4, #-1         ; decrement count
26
        bnez    r4, .Lloop1     ; go do some more
27
.Lendloop1:
28
        and3    r4, r3, #3      ; get no. of remaining BSS bytes to clear
29
        addi    r2, #4          ; account for pre-inc store
30
        beqz    r4, .Lendloop2  ; any more to go?
31
.Lloop2:
32
        stb     r1, @r2         ; yep, zero out another byte
33
        addi    r2, #1          ; bump address
34
        addi    r4, #-1         ; decrement count
35
        bnez    r4, .Lloop2     ; go do some more
36
.Lendloop2:
37
 
38
# Run code in the .init section.
39
# This will queue the .fini section to be run with atexit.
40
 
41
        bl      __init
42
 
43
# Call main, then exit.
44
 
45
        bl      main
46
        bl      exit
47
 
48
# If that fails just loop.
49
 
50
.Lexit:
51
        bra     .Lexit

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.