github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/targets/avrtiny.S (about) 1 #define __tmp_reg__ r16 2 #define __zero_reg__ r17 3 4 ; Startup code 5 .section .text.__vector_RESET 6 .global __vector_RESET 7 __vector_RESET: 8 clr __zero_reg__ ; this register is expected to be 0 by the C calling convention 9 10 ; Keep the stack pointer at the default location, which is RAMEND. 11 12 ; Initialize .data section. 13 .section .text.__do_copy_data,"ax",@progbits 14 .global __do_copy_data 15 __do_copy_data: 16 ldi xl, lo8(__data_start) 17 ldi xh, hi8(__data_start) 18 ldi yl, lo8(__data_end) 19 ldi yh, hi8(__data_end) 20 ldi zl, lo8(__data_load_start) 21 ldi zh, hi8(__data_load_start) 22 1: ; loop 23 cp xl, yl ; if x == y 24 cpc xh, yh 25 breq 2f ; goto end 26 ld r16, Z+ ; r0 = *(z++) 27 st X+, r16 ; *(x++) = r0 28 rjmp 1b ; goto loop 29 2: ; end 30 31 ; Initialize .bss section. 32 .section .text.__do_clear_bss,"ax",@progbits 33 .global __do_clear_bss 34 __do_clear_bss: 35 ldi xl, lo8(__bss_start) 36 ldi xh, hi8(__bss_start) 37 ldi yl, lo8(__bss_end) 38 1: ; loop 39 cp xl, yl ; if x == y 40 breq 2f ; goto end 41 st X+, __zero_reg__ ; *(x++) = 0 42 rjmp 1b ; goto loop 43 2: ; end