Data Copy & BSS Clear Initializing RAM Before main() Can Run Phase 2: Data Copy Copy initialized variables flash -> RAM C code: int counter = 42; Value 42 stored in flash but variables live in RAM! Flash -> RAM data_cpy_table has entries: src: 0x10001B4C (flash) dst: 0x20000110 (RAM) Phase 3: BSS Clear Zero uninitialized global variables C code: int my_counter; C standard requires this to start at zero. r1 = BSS start r2 = BSS end r0 = 0 Loop: store 0, advance r1 Until r1 == r2 -> done! Key Assembly Instructions ldmia r4!, {r1,r2,r3} Load source, dest, end from table bl data_cpy Copy word-by-word until done movs r0, #0 Load zero into r0 stmia r1!, {r0} Store zero, advance pointer