Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .global _start
- _start:
- b reset
- ldr pc, _undefined_instruction
- ldr pc, _software_interrupt
- ldr pc, _prefetch_abort
- ldr pc, _data_abort
- ldr pc, _not_used
- ldr pc, _irq
- ldr pc, _fiq
- reset:
- /* compare run and link addresses */
- adr r4, run
- ldr r5, .LCrun
- cmp r4, r5
- beq run
- /* Disable caches as we're moving code around */
- mcr p15, 0, r3, c7, c5, 0 /* ICIALLU */
- mrc p15, 0, r0, c1, c0
- bic r0, #0x0004
- bic r0, #0x1000
- mcr p15, 0, r0, c1, c0
- /* Figure how to move */
- ldr r7, .LCend_bin
- subs r8, r5, r4
- /* Moving */
- sub r8, r7, r8 /* r8 points to the end of source image */
- move:
- ldr r6, [r8, #-4]! /* Take bytes */
- str r6, [r7, #-4]! /* Put bytes */
- cmp r5, r7
- blt move
- ldr pc, .LCrun
- b .
- .LCrun: .word run
- .LCstart_bin: .word _start
- .LCend_bin: .word _image_end
- run:
- ldr r3, .uart_dr_p
- mov r2, #'r'
- str r2, [r3]
- ldr sp, .stack_top_p
- ldr r0, .func_p
- blx r0
- mov r2, #'e'
- str r2, [r3]
- b .
- .stack_top_p: .word crt0_stack_high
- .func_p : .word another_function
- .uart_dr_p : .word 0x10009000
- another_function:
- push {r0, lr}
- bl calling_function
- pop {r0, lr}
- b calling_function
- calling_function:
- mov r2, #'c'
- str r2, [r3]
- bx lr
- _undefined_instruction:
- _software_interrupt:
- _prefetch_abort:
- _data_abort:
- _not_used:
- _irq:
- _fiq:
- b .
- /* bss */
- .section ".bss"
- .global crt0_stack_low
- crt0_stack_low:
- .space 8192 /* need about 8k of stack space */
- .global crt0_stack_high
- crt0_stack_high:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement