Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .section .text.boot
- .global _start
- .global _stack_top
- _start:
- // load stackpointer
- la sp, _stack_top
- // Copy .data section from flash to RAM
- la a0, _data_load // Source address in flash
- la a1, _data_start // Destination address in RAM
- la a2, _data_end
- // Skip if no data to copy
- beq a1, a2, init_bss
- copy_data:
- lw t0, 0(a0) // Load word from flash
- sw t0, 0(a1) // Store to RAM
- addi a0, a0, 4 // Increment source
- addi a1, a1, 4 // Increment destination
- bltu a1, a2, copy_data
- init_bss:
- // Clear .bss section
- la a0, _bss_start
- la a1, _bss_end
- // Skip if no bss to clear
- beq a0, a1, init_done
- clear_bss:
- sw zero, 0(a0) // Store zero
- addi a0, a0, 4 // Increment address
- bltu a0, a1, clear_bss
- init_done:
- // Jump to main function
- call main
- 1: // Infinite loop if main returns
- j 1b
- .end
Advertisement
Add Comment
Please, Sign In to add comment