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

📄 lexra.s

📁 C语言编写的监控中心终端程序。基于GPRS上传收发数据功能
💻 S
字号:
/*
** FILE
** lexra.S
**
** DESCRIPTION
**
** assembly routines to 
**	1. set/get intr_mask
**	2. enable/disable IE (global interrupt enable)
**
*/
#include "regdef.h"
	
		.text	
		.global	cpu_set_intr_mask
		.global	cpu_get_intr_mask
		.global	cpu_intr_config
		.global	cpu_intr_enable
		.global	cpu_intr_disable

		.text	
/*
** FUNCTION
** UINT32	cpu_set_intr_mask(UINT32 mask[7:0]);
**
** DESCRIPTION
** set r3k CP0 interrupt mask, 1 to enable.
*/
		.ent	cpu_set_intr_mask
cpu_set_intr_mask:
                mfc0    t0, C0_STATUS		/* get STATUS[31:0] in t0	*/
		andi	a0, 0x00ff		/* clip a0 (new mask)		*/
		sll	a0, 8			/* {IM[7:0], 8'b0}		*/
		andi	t1, t0, 0xff00		/* get current IM in t1		*/
		xor	t0, t1			/* toggle mask bits for t0	*/
		or	t0, a0			/* insert new intr_mask to t0	*/
                mtc0    t0, C0_STATUS		/* write to STATUS		*/
		srl	v0, t1, 8		/* return last IM		*/
		jr	ra
		.end	cpu_set_intr_mask

/*
** FUNCION
** UINT32	cpu_get_intr_mask(void);
**
** DESCRIPTION
** get r3k CP0 interrupt mask, 1:enabled, 0:disabled
*/
		.ent	cpu_get_intr_mask
cpu_get_intr_mask:
		mfc0	v0, C0_STATUS
		srl	v0, 8
		andi	v0, 0x00ff
		jr	ra
		.end	cpu_get_intr_mask


/*
** FUNCION
** void		cpu_intr_disable(void);
**
** DESCRIPTION
** disable R3000 interrupt (globally)
*/
		.ent	cpu_intr_config
cpu_intr_config:
		beqz	a0, cpu_intr_disable
		/* fall thru if 1 */
/*
** FUNCION
** int		cpu_intr_enable(void);
**
** DESCRIPTIN
** enable R3000 interrupt (globally) 
*/
cpu_intr_enable:
		mfc0	v0, C0_STATUS
		ori	a0, v0, STATUS_IEc		/* enable STATUS_IEc	*/
cpu_intr_status_set:
		mtc0	a0, C0_STATUS
		andi	v0, 1				/* get last status	*/
		jr	ra


/*
** FUNCION
** int		cpu_intr_disable(void);
**
** DESCRIPTION
** disable R3000 interrupt (globally)
*/
cpu_intr_disable:
		mfc0	v0, C0_STATUS
		li	a0, ~STATUS_IEc
		and	a0, v0
		b	cpu_intr_status_set
		.end	cpu_intr_config


⌨️ 快捷键说明

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