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

📄 chk2xx.asm

📁 DSP的例程
💻 ASM
字号:
	.title "TMS320C2xx PROCESSOR SELFCHECK -- MAIN SHELL"
	.length 60
	.width 120
	.option X
************************************************************
* TMS320C2xx PROCESSOR SELFCHECK -- MAIN SHELL             *
*                                                          *
* Written by:                                              *
*                                                          *
* Release Version 1.0                                      *
*                                                          *
************************************************************
	.def	_c_int0
	.ref	alu, basic, brnch, ctrl, data, ram, mult, shft
	.ref	end2xx
	.def	_chk2xx
	.nolist
	.copy   "options.h"
	.copy   "memmap.h"
	.mmregs
	.list

	.text
_c_int0
_chk2xx				; .set	SS + $

; Save the C environment,ST0, ST1, and IMR 
	LAR	AR2,#CONTEXT	; AR2 points to address for context save
	MAR	*,AR2		; ARP --> AR2
	POPD	*+		; pop return address off hardware stack
	SAR	AR0,*+		; save frame pointer
	SAR	AR1,*+		; save stack pointer
	SAR	AR6,*+		; save AR6
	SAR	AR7,*+		; save AR7
	SST	#1,*+		; save ST1
	SST	#0,*+		; save ST0
	LDP	#0h		; data page @ 0h
	LAR	AR3,IMR		; AR3 contains IMR
	SAR	AR3,*		; save IMR

; disable all maskable interrupts
	SPLK	#0h,IMR		; disable all maskable interrupts

; optionally perform a program code check-sum test

	.if CHKSUM == 1

	SPM	0		; product mode shifter off        

	LACC	#end2xx-1	; must compute repeat count in 2 steps
	SUB	#_chk2xx	;  because assembler can't mix external
	SACL	TEMP00		;  and relocatable symbols.

	SPLK	#1h,TEMP01	; data(TEMP01) = 1h
	MPY	#0h		; flush PREG
	PAC			; flush ACC
	RPT	TEMP00		; execute next instr. "code length" times
	MAC	#_chk2xx,TEMP01	; perform checksum
	APAC			; add last checksum value to ACC
	SACH	TEMP02		; save upper word of actual checksum
	SACL	TEMP03		; save lower word of actual checksum
	BLPD	#end2xx,TEMP04	; data(TEMP04)=upper word of correct answer
	BLPD	#end2xx+1,TEMP05	; data(TEMP05)=lower word of correct answer
	SUB	TEMP04,16	; subtract upper word of correct answer
	SUBS	TEMP05		; subtract lower word of correct answer
	BCND	chk2xx1,EQ	; checksum passes if ACC = 0

	LACL    #1h             ;load checksum error code
	B       fail2xx         ;checksum fails
	
	.endif

; call the check modules
chk2xx1	.set	$ + SS

	CALL	basic		; call basic operations test
	BCND	fail2xx,NEQ	; abort if previous test failed
	CALL	data		; call data memory operations test
	BCND	fail2xx,NEQ	; abort if previous test failed
	CALL	ctrl		; call control instructions test
	BCND	fail2xx,NEQ	; abort if previous test failed
	CALL	brnch		; call branch instructions test
	BCND	fail2xx,NEQ	; abort if previous test failed
	CALL	alu		; call alu instructions test
	BCND	fail2xx,NEQ	; abort if previous test failed
	CALL	mult		; call multiplier operations test
	BCND	fail2xx,NEQ	; abort if previous test failed
	CALL	ram		; call ram test
	BCND	fail2xx,NEQ	; abort if previous test failed
	CALL	shft		; call shifter test
	BCND	fail2xx,NEQ	; abort if previous test failed
	CALL	pass2xx		; call "pass2xx" subroutine

; restore the C environment, ST0, ST1, IMR, and ARP --> AR1
exit2xx	.set	$ + SS 

	LAR	AR2,#CONTEXT	; AR2 points to address for context save
	MAR	*,AR2		; ARP --> AR2
	PSHD	*+		; push return address onto hardware stack
	LAR	AR0,*+		; restore frame pointer
	LAR	AR1,*+		; restore stack pointer
	LAR	AR6,*+		; restore AR6
	LAR	AR7,*+		; restore AR7
	LST	#1,*		; restore ST1, ARP corrupted

	SETC	INTM		; be sure interrupt mask is set
	LDP	#0h		; data page @ 0h
	LAR	AR3,CONTEXT+7	; AR3 contains saved IMR
	SAR	AR3,4h		; restore IMR
	LST	#0,CONTEXT+6	; restore ST0 after IMR so DP is restored               
	MAR	*,AR1		; ARP --> AR1

	RET			; return to calling program

fail2xx	.set	$ + SS

	.if LOCKOUT == 1
	B	fail2xx		; endless loop (lockout calling program)
	.else
	B	exit2xx		; proceed with return to calling program
	.endif


	.page
************************************************************
* SUBROUTINE pass2xx                                       *
*                                                          *
* This subroutine loads the "All tests passed" code into   *
* the accumulator.                                         *
************************************************************
pass2xx	.set	$ + SS

	LACL	#0ffh		; load "All tests passed" code
	RET

⌨️ 快捷键说明

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