Created
April 14, 2024 22:55
-
-
Save carlynorama/69c0e0f3d582e8f7faeafdec22eb80d7 to your computer and use it in GitHub Desktop.
Pulled from bigger project for reference.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.cpu cortex-m0 | |
.fpu softvfp | |
.thumb | |
.section .text.program_code | |
.equ portA_address, 0x41004400 | |
.equ portA_DIRSET, 0x41004400+0x08 | |
.equ portA_OUTTGL, 0x41004400+0x1C | |
.equ delayTime, 50000 | |
.equ pinOffset, 10 | |
.thumb_func | |
.global _start | |
_start: | |
MOVS R4, #1 | |
LSLS R4, R4, #pinOffset //R4 now contains the 1 at the pin offset bit. | |
LDR R5, =portA_DIRSET | |
STR R4, [R5] | |
LDR R5, =portA_OUTTGL | |
loop: | |
STR R4, [R5] | |
LDR R3, =delayTime | |
BL delay | |
B loop | |
.thumb_func | |
delay: | |
SUBS R3, R3, #1 | |
BNE delay | |
BX LR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.syntax unified | |
.cpu cortex-m0 | |
.fpu softvfp | |
.thumb | |
.section .vectors | |
.global vector_table | |
vector_table: | |
//-------------- arm core list | |
.word _end_stack //edge of stack, set in linker | |
.word reset_handler //reset handler | |
.word nmi_handler | |
.word hard_fault_handler | |
.word 0//not in M0+ | |
.word 0//not in M0+ | |
.word 0//not in M0+ | |
.word 0//not in M0+ | |
.word 0//not in M0+ | |
.word 0//not in M0+ | |
.word 0//not in M0+ | |
.word svc_handler | |
.word 0//not in M0+ | |
.word 0//not in M0+ | |
.word pendsv_handler | |
.word systick_handler | |
//-------------- peripherals list | |
//SAMD21E18 doesn't do all available to the family. | |
.word PM_Handler | |
.word SYSCTRL_Handler | |
.word WDT_Handler | |
.word RTC_Handler | |
.word EIC_Handler | |
.word NVMCTRL_Handler | |
.word DMAC_Handler | |
.word USB_Handler | |
.word EVSYS_Handler | |
.word SERCOM0_Handler | |
.word SERCOM1_Handler | |
.word SERCOM2_Handler | |
.word SERCOM3_Handler | |
.word 0/*SERCOM4_Handler*/ | |
.word 0/*SERCOM5_Handler*/ | |
.word TCC0_Handler | |
.word TCC1_Handler | |
.word TCC2_Handler | |
.word TC3_Handler | |
.word TC4_Handler | |
.word TC5_Handler | |
.word 0/*TC6_Handler*/ | |
.word 0/*TC7_Handler*/ | |
.word ADC_Handler | |
.word AC_Handler | |
.word DAC_Handler | |
.word PTC_Handler | |
.word I2S_Handler | |
.word 0/*AC1_Handler*/ | |
.word 0/*TCC3_Handler*/ | |
.text | |
.section .text.default_handler | |
.word default_handler | |
.thumb_func | |
default_handler: | |
ldr r3, =#0x8BADF00D | |
//hangs the program. | |
b . | |
.weakref nmi_handler, default_handler | |
.weakref hard_fault_handler, default_handler | |
.weakref svc_handler, default_handler | |
.weakref pendsv_handler, default_handler | |
.weakref systick_handler, default_handler | |
.weakref PM_Handler, default_handler | |
.weakref SYSCTRL_Handler, default_handler | |
.weakref WDT_Handler, default_handler | |
.weakref RTC_Handler, default_handler | |
.weakref EIC_Handler, default_handler | |
.weakref NVMCTRL_Handler, default_handler | |
.weakref DMAC_Handler, default_handler | |
.weakref USB_Handler, default_handler | |
.weakref EVSYS_Handler, default_handler | |
.weakref SERCOM0_Handler, default_handler | |
.weakref SERCOM1_Handler, default_handler | |
.weakref SERCOM2_Handler, default_handler | |
.weakref SERCOM3_Handler, default_handler | |
//.weakref SERCOM4_Handler, default_handler | |
//.weakref SERCOM5_Handler, default_handler | |
.weakref TCC0_Handler, default_handler | |
.weakref TCC1_Handler, default_handler | |
.weakref TCC2_Handler, default_handler | |
.weakref TC3_Handler, default_handler | |
.weakref TC4_Handler, default_handler | |
.weakref TC5_Handler, default_handler | |
////.weakref TC6_Handler, default_handler | |
.weakref TC7_Handler, default_handler | |
.weakref ADC_Handler, default_handler | |
.weakref AC_Handler, default_handler | |
.weakref DAC_Handler, default_handler | |
.weakref PTC_Handler, default_handler | |
.weakref I2S_Handler, default_handler | |
.weakref AC1_Handler, default_handler | |
//.weakref TCC3_Handler, default_handler | |
.section .text.reset_handler | |
@ The Reset Handler | |
.global reset_handler | |
.thumb_func | |
reset_handler: | |
/* reset handler started */ | |
/* r7 will hold my notes to self */ | |
ldr r7, =0x0000AAAA | |
/* set stack pointer */ | |
ldr r1, =_end_stack | |
mov sp, r1 | |
/* set .bss section to 0 (SRAM) */ | |
/* uses the jump to exit style loop */ | |
zero_bss: | |
/* get 0 handy in two registers */ | |
movs r0, #0 | |
movs r1, #0 | |
/* get the bounds */ | |
ldr r2, = _start_bss | |
ldr r3, = _end_bss | |
loop_start_bss_zero: | |
/* compare, first one is that there is a bss. */ | |
cmp r2, r3 | |
/* compare: unsigned higher or same (is end higher than current ) */ | |
bhs loop_end_bss_zero | |
/* will load 2 and increase the pointer after */ | |
@ stmia r2!, {r0,r1} | |
stmia r2!, {r0} /* decided against moving bss to after data in linker */ | |
b loop_start_bss_zero | |
loop_end_bss_zero: | |
/* copy .data section to SRAM */ | |
/* uses the jump to entry style loop */ | |
move_data_to_ram: | |
/* get the bounds */ | |
ldr r0, = _start_data | |
ldr r1, = _end_data | |
/* read head location */ | |
ldr r2, = _sidata | |
b loop_enter_data_copy | |
loop_action_data_copy: | |
ldmia r2!, {r3} | |
stmia r0!, {r3} | |
loop_enter_data_copy: | |
cmp r0, r1 | |
bcc loop_action_data_copy | |
/* call the clock system initialization function.*/ | |
/* not done */ | |
/* call init of libraries (stdlib when loop in C) that need it.*/ | |
/* not done */ | |
/* note to self handler finished */ | |
LDR r7, =0x0000BBBB | |
/* Call the application's entry point.*/ | |
bl _start | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENTRY(reset_handler); | |
MEMORY { | |
flash(rx): ORIGIN = 0x00000000, LENGTH = 0x00040000 /*256K*/ | |
sram(rwx): ORIGIN = 0x20000000, LENGTH = 0x00008000 /*32K*/ | |
} | |
/* sp_initial_value, _estack, __Top_of_Stack all the same. */ | |
/* edge that stack grows away from. */ | |
/* better code would change this based on actual size of appilication */ | |
/* this value is aligned 8 as required. */ | |
_end_stack = ORIGIN(sram) + LENGTH(sram); /* 0x20008000 */ | |
SECTIONS { | |
/* TODO: Coretex-M0+ have no vma???, impacts AT? */ | |
.text : { | |
/* The Top! */ | |
startup.o(.vectors) /* do the one from this file first */ | |
KEEP(*(.vectors .vectors.*)) /* do any in other files jic */ | |
/* . = 0xB4 /* HACK: could force the linker to jump expected end of vector table */ | |
/* I want things realted to this code to come to the top */ | |
*(.text.reset_handler) | |
*(.text.default_handler) | |
/* the rest of the .text and .text sub sections */ | |
*(.text .text.*) | |
/* all files read only data and read only data sub sections */ | |
*(.rodata, .rodata*) /* read only data */ | |
} > flash /* nothing relocatable */ | |
. = ALIGN(4); /* snap to grid */ | |
_end_text = .; /* store current location counter value in _end_text */ | |
/* Used by the startup to initialize data with the "originating" address */ | |
/* not so relevant on the M0+, more significant diff on beefier cores */ | |
_sidata = LOADADDR(.data); | |
.data : { | |
. = ALIGN(4); | |
_start_data = .; /* store current location in _end_data t*/ | |
*(.data) | |
. = ALIGN(4); | |
_end_data = .; /* store current location in _end_data t*/ | |
} > sram AT> flash | |
.bss(NOLOAD) : { | |
. = ALIGN(4); | |
_start_bss = .; | |
*(.bss) | |
*(COMMON) | |
} > sram | |
/* todo, inside or outside */ | |
. = ALIGN(4); | |
_end_bss = .; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment