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

📄 rzkswitchcontexta.s

📁 zilog的实时操作系统RZK,可以移植到多种处理器上
💻 S
字号:
;/*
;* File				:	RZKSwitchContextA.s
;*
;* Description		:	This file defines _RZKSwitchContextA routine
;* 
;* Copyright 2004 ZiLOG Inc.  ALL RIGHTS RESERVED.
;*
;* This file contains unpublished confidential and proprietary information
;* of ZiLOG, Inc.
;* NO PART OF THIS WORK MAY BE DUPLICATED, STORED, PUBLISHED OR DISCLOSED 
;* IN ANY FORM WITHOUT THE PRIOR WRITTEN CONSENT OF ZiLOG, INC.
;* This is not a license and no use of any kind of this work is authorized
;* in the absence of a written license granted by ZiLOG, Inc. in ZiLOG's 
;* sole discretion 
;*/

	.extern _hCurrentThread

	OFFSET_SP	:	equ	07H

;	.INCLUDE	"toolsmith.inc"	
	.RZK_TOOLSMITH	.equ 1
	.def _RZKSwitchContextA
	.assume	adl=1

;/* Function		:	RZKSwitchContextA
;*
;* Description		:	Switches context of threads
;* 
;* Inputs			:	Thread where context shoudl switch to.
;*							
;* Outputs			:	None.
;*							
;*
;* Dependencies		:	None.
;*/
_RZKSwitchContextA:					; Scratch HL & AF Register
	PUSH		BC					; Save HL Register
	PUSH		HL					; Dummy Save HL Register

;	#if RZK_TOOLSMITH
;	PUSH		DE					; Save DE Register
;	#endif

	PUSH		DE					; Save BC Register
	PUSH		IX					; Save IY Register
	PUSH		IY					; Save IX Register
	PUSH		AF

	LD		IY, 	(_hCurrentThread)	; pCurrentThread
	LD		IX,	 0
	
	ADD		IX, 	SP

	.IF	.RZK_TOOLSMITH	
		LD		HL,	( IX + 21 )			; pCurrentThread = pThread	
		LD		( _hCurrentThread ), HL
	ELSE
		LD		(_hCurrentThread), DE	; pCurrentThread = pThread
	ENDIF

	LD		HL, RestoreReg
	PUSH		HL			; Save PC for Return from Context Switch
	
	LD		HL,	0
	ADD		HL,	SP					; Current Stack Pointer
	LD		(IY + OFFSET_SP), HL	; Save Stack Pointer of CurrentThread
		
	LD		IY, (_hCurrentThread)	; pThread
	LD		HL, (IY + OFFSET_SP)	; Get Stack Pointer of pThread
	LD		SP, HL					; Update the SP	LD
	RET							; Return to pThread Context
	
RestoreReg:	
	POP		AF
	POP		IY			; Restore IX Register
	POP		IX			; Restore IY Register
	POP		DE 			; Restore BC Register
	
;	#if RZK_TOOLSMITH
;	POP		DE 			; Restore DE Register
;	#endif

	POP		HL			; Restore HL Register
	POP		BC			; dummy POP HL register
;	EI				; Enable Interrupts
	RET				; Return to RZKScheduler
 
    .def _StartThread
_StartThread:
	EI				; Enable Interrupts
	JP		RestoreReg

	.def _EnableDisable
_EnableDisable:			; Scratch HL & AF Register
	EI
	NOP
	NOP
	NOP
	NOP
	DI
	RET



;************************************************************************
;	.def	___HUGE_VAL
;___HUGE_VAL
;	.long	80000000h
;************************************************************************

⌨️ 快捷键说明

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