init.s

来自「含有完整TCP/IP PPP协议的嵌入式操作系统」· S 代码 · 共 52 行

S
52
字号
; to be included by the crt*.s files;	; initialize stacks	;	; set the hardware stack to ram_end, and the software stack some	; bytes below that	ldi R28,<ram_end	ldi R29,>ram_end	out $3D,R28	out $3E,R29	subi R28,<hwstk_size	sbci R29,>hwstk_size	ldi R16,0xAA	; sentenial	std	Y+0,R16		; put sentenial at bottom of HW stack	clr R0	ldi R30,<__bss_start	ldi R31,>__bss_start	ldi R17,>__bss_end; this loop zeros out all the data in the bss area;init_loop:	cpi R30,<__bss_end	cpc R31,R17	breq init_done	st Z+,R0	rjmp init_loopinit_done:	std Z+0,R16		; put sentenial at bottom of SW stack; copy data from idata to data; idata contains the initialized values of the global variables	ldi R30,<__idata_start	ldi R31,>__idata_start	ldi R26,<__data_start	ldi R27,>__data_start	ldi R17,>__idata_endcopy_loop:	cpi R30,<__idata_end	cpc R31,R17	breq copy_done	lpm 	; load (Z) byte into R0	adiw R30,1	st X+,R0	rjmp copy_loopcopy_done:

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?