⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 start.s

📁 基于瑞萨 M16C 的最新版本 IIC 通信
💻 S
字号:
/****************************************************************
KPIT Cummins Infosystems Ltd, Pune, India. 08-Aug-2005.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

*****************************************************************/

/* Start-up code for M16C targets only */

.text
	.global	_start
	.type _start, @function
	
_start:
	ldc	#_istack, isp	/* set interrupt stack pointer */
	mov.b	#0x02,0x0a	/* write enable in protect register */
	mov.b	#0x00,0x04	/* set processer mode  :single chip mode */
						/* 0x04 is the address of processor mode register 0 */
	mov.b	#0x00,0x0a	/* write disable in protect register */
	ldc	#0x0080,flg		/* select USER STACK POINTER (BIT7=1,USP) (BIT7=0,ISP) */
	ldc	#_ustack,sp		/* set user stack pointer */
	
	/* INTERRUPT VECTOR ADDRESS  definition	*/
	ldc 	#0xF, intbh	/* load upper 4 bits of variable vector address in intbh */
	ldc 	#0xA000, intbl	/* load lower 16 bits of variable vector address in intbl */

	fset	I			/* ADD THIS TO ENABLE INTERRUPTS */
		
	/* call the hardware initialiser */
	jsr.a	_hw_initialise	
	

/* load data section and rodata section from ROM to RAM only if ROMSTART is defined */
#if ROMSTART

   	mov.b	#%hi8(_mdata),r1h	/* move upper 4 bits of the 20 bit address (_mdata) to, r1h */
	mov.w	#%lo16(_mdata),a0	/* move lower 16 bits of the 20 bit address (_mdata) to,a0 */	
	mov.w	#_data,a1			/* store the start address of data section in, A1 */
	mov.w	#_edata,r3			/* store the end address of data section in R3 */
	sub.w	a1,r3				/* R3=R3-A1. Store size of data section in R3 */
	mov.w	r3,r2				/* Store size of data section in R2 */
	smovf.b

/* load rodata section from ROM to RAM only for M16C target */

   	mov.b	#%hi8(_mdata),r1h	/* move upper 4 bits of the 20 bit address (_mdata) to r1h */
	mov.w	#%lo16(_mdata),a0	/* move lower 16 bits of the 20 bit address (_mdata) to,a0 */
	add.w	r2,a0				/* add the size of data section to a0, to get load address of rodata section */
	jnc rodata_init		    
	add.b	#01, r1h			/* if the carry flag is set, increment r1h */

rodata_init:			
	mov.w	#_rodata,a1			/* store the start address of rodata section in, A1 */
	mov.w	#_erodata,r3		/* store the end address of rodata section in R3 */
	sub.w	a1,r3				/* R3=R3-A1. Store size of rodata section in R3 */
	smovf.b
	
#endif // ROMSTART 


/* bss initialisation : zero out bss */

	mov.b	#0x00,R0L  		/* load R0L reg with 0x0 (value at which bss section will be initialised) */
	mov.w	#_bss, a1  		/* store the start address of bss in A1 */
	mov.w	#_ebss, a0 		/* store the end address of bss in A0 */
	sub.w   a1,a0	   		/* (A0 = A0-A1) */
	mov.w   a0,r3	   		/* Store size of bss section in reg R3 */
	sstr.b


/* start user program */
	jsr.a	_main		
	
	.end

⌨️ 快捷键说明

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