Search
lxdream.org :: lxdream/test/lib-arm/crt0.s :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename test/lib-arm/crt0.s
changeset 812:8cc61d5ea1f8
next821:4398dafeb77d
author nkeynes
date Wed Aug 13 10:32:00 2008 +0000 (12 years ago)
permissions -rw-r--r--
last change Add ARM test harness (not quite working on DC but almost...)
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/test/lib-arm/crt0.s Wed Aug 13 10:32:00 2008 +0000
1.3 @@ -0,0 +1,59 @@
1.4 +.section .text
1.5 +.code 32
1.6 +.align 0
1.7 +.global start
1.8 +.global ___exit
1.9 +.global _atexit
1.10 +start:
1.11 +
1.12 +/* Start by setting up a stack */
1.13 + /* Set up the stack pointer to a fixed value */
1.14 + ldr r3, .LC0
1.15 + mov sp, r3
1.16 + /* Setup a default stack-limit in-case the code has been
1.17 + compiled with "-mapcs-stack-check". Hard-wiring this value
1.18 + is not ideal, since there is currently no support for
1.19 + checking that the heap and stack have not collided, or that
1.20 + this default 64k is enough for the program being executed.
1.21 + However, it ensures that this simple crt0 world will not
1.22 + immediately cause an overflow event: */
1.23 + sub sl, sp, #64 << 10 /* Still assumes 256bytes below sl */
1.24 +
1.25 + /* Zero-out the BSS segment */
1.26 + mov a2, #0 /* Second arg: fill value */
1.27 + mov fp, a2 /* Null frame pointer */
1.28 + mov r7, a2 /* Null frame pointer for Thumb */
1.29 +
1.30 + ldr a1, .LC1 /* First arg: start of memory block */
1.31 + ldr a3, .LC2
1.32 + sub a3, a3, a1 /* Third arg: length of block */
1.33 + bl memset
1.34 + b .LB0
1.35 + .word 0 /* padding */
1.36 +
1.37 +.syscall:
1.38 + .word -1 /* Syscall # */
1.39 + .word 0 /* Arguments */
1.40 + .word 0
1.41 + .word 0
1.42 +
1.43 + /* Enter main with no arguments for now */
1.44 +.LB0:
1.45 + mov r0, #0 /* no arguments */
1.46 + mov r1, #0 /* no argv either */
1.47 + bl main
1.48 +
1.49 + bl exit /* Should not return */
1.50 +
1.51 + /* For Thumb, constants must be after the code since only
1.52 + positive offsets are supported for PC relative addresses. */
1.53 +
1.54 + .align 0
1.55 +.LC0:
1.56 + .word _stack
1.57 +.LC1:
1.58 + .word __bss_start
1.59 +.LC2:
1.60 + .word __bss_end
1.61 +
1.62 +
.