Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 1.67 KB | None | 0 0
  1. .global _start
  2. _start:
  3.     b reset
  4.     ldr     pc, _undefined_instruction
  5.     ldr     pc, _software_interrupt
  6.     ldr     pc, _prefetch_abort
  7.     ldr     pc, _data_abort
  8.     ldr     pc, _not_used
  9.     ldr     pc, _irq
  10.     ldr     pc, _fiq
  11. reset:
  12.     /* compare run and link addresses */
  13.     adr r4, run
  14.     ldr r5, .LCrun
  15.     cmp r4, r5
  16.     beq run
  17.  
  18.     /* Disable caches as we're moving code around */
  19.    mcr p15, 0, r3, c7, c5, 0 /* ICIALLU */
  20.    mrc p15, 0, r0, c1, c0
  21.    bic r0, #0x0004
  22.    bic r0, #0x1000
  23.    mcr p15, 0, r0, c1, c0
  24.  
  25.    /* Figure how to move */
  26.    ldr r7, .LCend_bin
  27.    subs r8, r5, r4
  28.    /* Moving */
  29.    sub r8, r7, r8 /* r8 points to the end of source image */
  30. move:
  31.     ldr r6, [r8, #-4]!  /* Take bytes */
  32.     str r6, [r7, #-4]!  /* Put bytes */
  33.    cmp r5, r7
  34.    blt move
  35.    ldr pc, .LCrun
  36.  
  37.    b .
  38. .LCrun:       .word run
  39. .LCstart_bin: .word _start
  40. .LCend_bin:   .word _image_end
  41.    
  42. run:
  43.    ldr r3, .uart_dr_p
  44.    mov r2, #'r'
  45.    str r2, [r3]
  46.    
  47.    ldr sp, .stack_top_p
  48.    ldr r0, .func_p
  49.    blx r0
  50.    
  51.    mov r2, #'e'
  52.    str r2, [r3]
  53.    b .
  54.  
  55. .stack_top_p: .word crt0_stack_high
  56. .func_p : .word another_function
  57. .uart_dr_p : .word 0x10009000
  58. another_function:
  59.    push {r0, lr}
  60.    bl calling_function
  61.    pop {r0, lr}
  62.    b calling_function
  63.  
  64. calling_function:
  65.    mov r2, #'c'
  66.    str r2, [r3]
  67.    
  68.    bx lr
  69. _undefined_instruction:
  70. _software_interrupt:
  71. _prefetch_abort:
  72. _data_abort:
  73. _not_used:
  74. _irq:
  75. _fiq:
  76.    b .
  77.  
  78. /* bss */
  79. .section ".bss"
  80.    .global crt0_stack_low
  81. crt0_stack_low:
  82.    .space  8192 /* need about 8k of stack space */
  83.    .global crt0_stack_high
  84. crt0_stack_high:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement