newlib/libgloss/ms1/crt0.S
Aldy Hernandez 3f4df6211e * configure.in: Add ms1 case.
* configure: Regenerate.
	* ms1/16-002.ld: New.
	* ms1/16-003.ld: New.
	* ms1/64-001.ld: New.
	* ms1/access.c: New.
	* ms1/chmod.c: New.
	* ms1/close.c: New.
	* ms1/configure: New.
	* ms1/configure.in: New.
	* ms1/crt0-16-002.S: New.
	* ms1/crt0-16-003.S: New.
	* ms1/crt0-64-001.S: New.
	* ms1/crt0.S: New.
	* ms1/exit-16-002.c: New.
	* ms1/exit-16-003.c: New.
	* ms1/exit-64-001.c: New.
	* ms1/exit.c: New.
	* ms1/fstat.c: New.
	* ms1/getpid.c: New.
	* ms1/gettime.c: New.
	* ms1/isatty.c: New.
	* ms1/kill.c: New.
	* ms1/lseek.c: New.
	* ms1/Makefile.in: New.
	* ms1/open.c: New.
	* ms1/read.c: New.
	* ms1/sbrk.c: New.
	* ms1/startup-16-002.S: New.
	* ms1/startup-16-003.S: New.
	* ms1/startup-64-001.S: New.
	* ms1/stat.c: New.
	* ms1/time.c: New.
	* ms1/times.c: New.
	* ms1/trap.h: New.
	* ms1/trap.S: New.
	* ms1/unlink.c: New.
	* ms1/utime.c: New.
	* ms1/write.c: New.
2005-07-06 12:58:12 +00:00

64 lines
1.3 KiB
ArmAsm

# Startup Code for the Morpho ms1
# Create a label for the start of the eh_frame section.
.section .eh_frame
__eh_frame_begin:
.section .text
.global _start
_start:
;; Initialise the stack pointer
ldui sp, #%hi16(__stack)
addui sp, sp, #%lo16(__stack)
or fp, sp, sp
;; Zero the data space
ldui r9, #%hi16(_edata)
addui r9, r9, #%lo16(_edata)
ldui r10, #%hi16(_end)
addui r10, r10, #%lo16(_end)
addi r5, r0, #0
.L0:
stw r5, r9, #0
addi r9, r9, #4
or r0, r0, r0 ; nop
brle r9, r10, .L0
or r0, r0, r0 ; nop
;; Call global and static constructors
ldui r10, #%hi16(_init)
addui r10, r10, #%lo16(_init)
or r0, r0, r0 ; nop
jal r14, r10
or r0, r0, r0 ; nop
;; Setup destructors to be called from exit.
;; (Just in case main never returns....)
ldui r10, #%hi16(atexit)
addui r10, r10, #%lo16(atexit)
ldui r1, #%hi16(_fini)
addui r1, r1, #%lo16(_fini)
or r0, r0, r0 ; nop
jal r14, r10
or r0, r0, r0 ; nop
;; Initialise argc, argv and envp to empty
addi r1, r0, #0
addi r2, r0, #0
addi r3, r0, #0
;; Call main
ldui r10, #%hi16(main)
addui r10, r10, #%lo16(main)
or r0, r0, r0 ; nop
jal r14, r10
or r0, r0, r0 ; nop
;; Jump to exit
ldui r10, #%hi16(exit)
addui r10, r10, #%lo16(exit)
or r0, r0, r0 ; nop
jal r14, r10
or r0, r0, r0 ; nop