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

📄 saverest.asm

📁 ucos-IIv2.52在TMS320c6416上的移植
💻 ASM
字号:
;********************************************************************************************************
; File         : saverest.asm - save and restore Registers when task switch 
; By	       : rongjie 2006.4
; History      : 
; Description  : this file is written to save and restore kernel registers
;                for c6416  when task is scheduled 
;********************************************************************************************************


FP	.set	A15
DP	.set	B14
SP	.set	B15
    .global _ctwSave, _ctwRest
	.text

;***********************************************************************
; Save all register context except B3, when interrupt happens
; all registers except B3 have to been saved. return address is in B3
; it musted been confirmed that a10-a15,b10-b15 are not use in isr
;***********************************************************************
 
_ctwSave:  

; outside previous B3 that has been saved 
; I$$SAVE return adress is stored in B3
	STW		A0, *SP-- 
	STW		A1, *SP--
	STW		A2, *SP--     
    STW		A3, *SP--     
    STW		A4, *SP--     
    STW		A5, *SP--     
    STW		A6, *SP--
    STW		A7, *SP--     
    STW		A8, *SP--     
    STW		A9, *SP--     
	STW		A10, *SP--     
    STW		A11, *SP--
    STW		A12, *SP--     
    STW		A13, *SP--     
    STW		A14, *SP--     
    STW		A15, *SP--     
    STW		A16, *SP--     
    STW		A17, *SP--     
    STW		A18, *SP--     
    STW		A19, *SP--     
    STW		A20, *SP--     
    STW		A21, *SP--     
    STW		A22, *SP--     
    STW		A23, *SP--     
    STW		A24, *SP--     
    STW		A25, *SP--     
    STW		A26, *SP--     
    STW		A27, *SP--     
    STW		A28, *SP--     
    STW		A29, *SP--     
    STW		A30, *SP--     
    STW		A31, *SP--     
	STW		B0, *SP--     ; Save B0 
	STW		B1, *SP--     
    STW		B2, *SP--     
;B3 is not stored here
    STW		B4, *SP--     
    STW		B5, *SP--     
    STW		B6, *SP--     
    STW		B7, *SP--     
    STW		B8, *SP--     
    STW		B9, *SP--     
	STW		B10, *SP--
	STW		B11, *SP--     
    STW		B12, *SP--     
    STW		B13, *SP--     
    STW		B14, *SP--     
;b15 is stored in TCB
    STW		B16, *SP--     
    STW		B17, *SP--     
    STW		B18, *SP--     
    STW		B19, *SP--     
    STW		B20, *SP--     
    STW		B21, *SP--     
    STW		B22, *SP--     
    STW		B23, *SP--     
    STW		B24, *SP--     
    STW		B25, *SP--     
    STW		B26, *SP--     
    STW		B27, *SP--     
    STW		B28, *SP--     
    STW		B29, *SP--     
    STW		B30, *SP--     
    STW		B31, *SP--     
||  MVC		AMR, B0
    STW     B0, *SP--
||  MVC		CSR, B0
    STW     B0, *SP--
||  MVC		IRP, B0
    STW     B0, *SP--
	ADDK .S2	 -4, SP		;make SP on an 8-bytes boundary
	
    BNOP 	B3, 5	;return from I$$SAVE
; /*$PAGE*/;
;***********************************************************************
; Resume all register context, 
;***********************************************************************
;

_ctwRest:
	ADDK .S2	4, SP			
	LDW		*++SP, B0	;restore IRP
;don't restore IER
	LDW		*++SP, B1   ;CSR
    LDW		*++SP, B2   ;AMR

	LDW		*++SP, B31
	LDW     *++SP, B30 
	LDW		*++SP, B29
    LDW		*++SP, B28
||	MVC		B0, IRP		;IRP
;don't restore IER
	LDW     *++SP, B27 
||	MVC		B1, CSR		;CSR
	LDW		*++SP, B26 
||	MVC		B2, AMR		;AMR
	LDW		*++SP, B25
	LDW     *++SP, B24 
	LDW		*++SP, B23
	LDW		*++SP, B22
	LDW     *++SP, B21 
	LDW     *++SP, B20
	LDW		*++SP, B19
    LDW		*++SP, B18
	LDW     *++SP, B17
	LDW		*++SP, B16
;b15 is stored in TCB, so here don't need to restore it
	LDW		*++SP, B14
	LDW     *++SP, B13 
	LDW		*++SP, B12
	LDW		*++SP, B11
	LDW     *++SP, B10 
	LDW     *++SP, B9 
	LDW		*++SP, B8
    LDW		*++SP, B7
	LDW     *++SP, B6 
	LDW		*++SP, B5
	LDW		*++SP, B4
;B3 is not stored here
	LDW		*++SP, B2
	LDW		*++SP, B1
	LDW     *++SP, B0
	 
	LDW		*++SP, A31
	LDW     *++SP, A30
	LDW		*++SP, A29
    LDW		*++SP, A28
	LDW     *++SP, A27
	LDW		*++SP, A26
	LDW		*++SP, A25
	LDW		*++SP, A24
	LDW     *++SP, A23 
	LDW		*++SP, A22
	LDW		*++SP, A21
	LDW     *++SP, A20
	LDW		*++SP, A19
    LDW		*++SP, A18
	LDW     *++SP, A17
	LDW		*++SP, A16
	LDW		*++SP, A15
	LDW		*++SP, A14
	LDW     *++SP, A13 
	LDW		*++SP, A12
	LDW		*++SP, A11
	LDW     *++SP, A10 
	LDW     *++SP, A9 
	LDW		*++SP, A8
    LDW		*++SP, A7
	LDW     *++SP, A6 
	LDW		*++SP, A5
	LDW		*++SP, A4
	LDW     *++SP, A3 
	LDW		*++SP, A2
	LDW		*++SP, A1
	LDW     *++SP, A0 
    
    ADDK .S2	4, SP			
;restore B3, in interrupt it's a value ,in task switch it is the same 
;as value saved in IRP     
    LDW		*++SP, B3   
        
	B .S2	IRP  ;return from I$$SAVE.PGIE is copied to GIE
	NOP 	5
	
	

⌨️ 快捷键说明

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