Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRanjith Kumaran <ranjith@cygnus.com>2000-03-18 01:48:54 +0300
committerRanjith Kumaran <ranjith@cygnus.com>2000-03-18 01:48:54 +0300
commit03261851a10dd2d6900a0a00a7515a0a46fb5d76 (patch)
tree7c22ac6cbbc99fd5cd1b5426853be8d4fd7bfcf1 /libgloss/m32r/crt0.S
parentfae4c299f14fc23e2829c8656992eba21f79242a (diff)
20000317 sourceware import
Diffstat (limited to 'libgloss/m32r/crt0.S')
-rw-r--r--libgloss/m32r/crt0.S51
1 files changed, 51 insertions, 0 deletions
diff --git a/libgloss/m32r/crt0.S b/libgloss/m32r/crt0.S
new file mode 100644
index 000000000..f60a1a603
--- /dev/null
+++ b/libgloss/m32r/crt0.S
@@ -0,0 +1,51 @@
+ .text
+ .balign 4
+ .global _start
+_start:
+
+ ld24 sp, _stack
+ ldi fp, #0
+
+# Clear the BSS. Do it in two parts for efficiency: longwords first
+# for most of it, then the remaining 0 to 3 bytes.
+
+ seth r2, #shigh(__bss_start)
+ add3 r2, r2, #low(__bss_start); R2 = start of BSS
+ seth r3, #shigh(_end)
+ add3 r3, r3, #low(_end) ; R3 = end of BSS + 1
+
+ sub r3, r2 ; R3 = BSS size in bytes
+ mv r4, r3
+ srli r4, #2 ; R4 = BSS size in longwords (rounded down)
+ ldi r1, #0 ; clear R1 for longword store
+ addi r2, #-4 ; account for pre-inc store
+ beqz r4, .Lendloop1 ; any more to go?
+.Lloop1:
+ st r1, @+r2 ; yep, zero out another longword
+ addi r4, #-1 ; decrement count
+ bnez r4, .Lloop1 ; go do some more
+.Lendloop1:
+ and3 r4, r3, #3 ; get no. of remaining BSS bytes to clear
+ addi r2, #4 ; account for pre-inc store
+ beqz r4, .Lendloop2 ; any more to go?
+.Lloop2:
+ stb r1, @r2 ; yep, zero out another byte
+ addi r2, #1 ; bump address
+ addi r4, #-1 ; decrement count
+ bnez r4, .Lloop2 ; go do some more
+.Lendloop2:
+
+# Run code in the .init section.
+# This will queue the .fini section to be run with atexit.
+
+ bl __init
+
+# Call main, then exit.
+
+ bl main
+ bl exit
+
+# If that fails just loop.
+
+.Lexit:
+ bra .Lexit