]> sourceware.org Git - newlib-cygwin.git/blame - libgloss/m32r/crt0.S
Cygwin: console: Fix clean up conditions in close()
[newlib-cygwin.git] / libgloss / m32r / crt0.S
CommitLineData
03261851
RK
1 .text
2 .balign 4
3 .global _start
4_start:
5
6ae5c86b
JJ
6 seth sp, #shigh(_stack)
7 add3 sp, sp, #low(_stack)
03261851
RK
8 ldi fp, #0
9
10# Clear the BSS. Do it in two parts for efficiency: longwords first
11# for most of it, then the remaining 0 to 3 bytes.
12
13 seth r2, #shigh(__bss_start)
14 add3 r2, r2, #low(__bss_start); R2 = start of BSS
15 seth r3, #shigh(_end)
16 add3 r3, r3, #low(_end) ; R3 = end of BSS + 1
17
18 sub r3, r2 ; R3 = BSS size in bytes
19 mv r4, r3
20 srli r4, #2 ; R4 = BSS size in longwords (rounded down)
21 ldi r1, #0 ; clear R1 for longword store
22 addi r2, #-4 ; account for pre-inc store
23 beqz r4, .Lendloop1 ; any more to go?
24.Lloop1:
25 st r1, @+r2 ; yep, zero out another longword
26 addi r4, #-1 ; decrement count
27 bnez r4, .Lloop1 ; go do some more
28.Lendloop1:
29 and3 r4, r3, #3 ; get no. of remaining BSS bytes to clear
30 addi r2, #4 ; account for pre-inc store
31 beqz r4, .Lendloop2 ; any more to go?
32.Lloop2:
33 stb r1, @r2 ; yep, zero out another byte
34 addi r2, #1 ; bump address
35 addi r4, #-1 ; decrement count
36 bnez r4, .Lloop2 ; go do some more
37.Lendloop2:
38
39# Run code in the .init section.
40# This will queue the .fini section to be run with atexit.
41
42 bl __init
43
44# Call main, then exit.
45
46 bl main
47 bl exit
48
49# If that fails just loop.
50
51.Lexit:
52 bra .Lexit
This page took 0.229998 seconds and 6 git commands to generate.