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

📄 os_cpu_c.s

📁 ucos如何移植到单片机mega128
💻 S
📖 第 1 页 / 共 2 页
字号:
	.module os_cpu_c.c
	.area text(rom, con, rel)
	.dbfile E:\study\ucos_ii\ucos2_iccavr\iccavr\ucos2_with_cpu\os_cpu_c.c
	.dbfunc e OSTaskStkInit _OSTaskStkInit fpc
;           stks -> R10,R11
;            tmp -> R22,R23
;            stk -> R20,R21
;            opt -> y+8
;           ptos -> y+6
;          pdata -> R18,R19
;           task -> R16,R17
	.even
_OSTaskStkInit::
	xcall push_gset3
	.dbline -1
	.dbline 60
; /*
; ********************************************************************************
; *                               uC/OS-II
; *                          The Real-Time Kernel
; * 
; *                         ATmega103 Specific code
; *
; * File:			OS_CPU_C.C
; * By:			Ole Saether
; * Modified by:	Joerg Meyer
; * Revision:		0
; *
; *
; *
; ********************************************************************************
; */
; 
; #define  OS_CPU_GLOBALS
; #include "..\ucos2_application\includes.h"
; 
; /*
; ********************************************************************************
; *                     INITIALIZE A TASK'S STACK
; *
; * Description:
; *	This function is called by either OSTaskCreate() or OSTaskCreateExt() to
; *	initialize the stack frame of the task being created. This function is
; *	highly processor specific.
; *
; * Arguments:
; *	task - 	is a pointer to the task code
; *
; *	pdata -	is a pointer to a user supplied data area that will be passed to the
; *			 task when the task first executes.
; *
; *	ptos - 	is a pointer to the top of stack. It is assumed that 'ptos' points to
; *			the highest valid address on the stack.
; *
; *	opt - 	specifies options that can be used to alter the behavior of 
; 			OSTaskStkInit(). (see uCOS_II.H for OS_TASK_OPT_???).
; *
; * Returns:
; *	Always returns the location of the new top-of-stack' once the processor 
; *	registers have been placed on the stack in the proper order.
; *
; * Note(s):
; *	Interrupts are enabled when your task starts executing. You can change this 
; * 	by setting the SREG to 0x00 instead. In this case, interrupts would be 
; *	disabled upon task startup. The application code would be responsible for 
; *	enabling interrupts at the beginning of the task code. You will need to 
; *	modify OSTaskIdle() and OSTaskStat() so that they enable interrupts. Failure
; *	to do this will make your system crash! The AVR return stack is placed 64 
; *	bytes above the start of the (512 byte) stack. This provides 32 levels of 
; *	function call nesting which should be more than enough for most applications
; *	(see the "read.me" file for more info).
; *
; ********************************************************************************
; */
; OS_STK *OSTaskStkInit (void (*task)(void *pd),
; 						 void *pdata, OS_STK *ptos, INT16U opt){
	.dbline 67
; 
;     INT8U  *stk;
;     INT8U  *stks;		// Temp. variable used for setting up AVR hardware stack
;     INT16U tmp;
; 
; 
;     opt     = opt;			// 'opt' is not used, prevent warning
	.dbline 68
;     stk     = (INT8U *)ptos;		// Wandlung von ptos in Bytezeiger
	ldd R20,y+6
	ldd R21,y+7
	.dbline 70
; 	// AVR return stack ("hardware stack")
;     stks    = (INT8U *)(ptos)-(OS_TASK_DEF_STK_SIZE-32);
	movw R24,R20
	subi R24,96
	sbci R25,0
	.dbline 75
; 
; 	// the function address has an extra level of indirection. Fetch the
;     // actual address.
;     //    
;     tmp = *(INT16U const *)task;
	movw R30,R16
	lpm R22,Z+
	lpm R23,Z
	.dbline 78
;    
; 	// 36 Bytes
;     *stks-- = (INT8U)tmp;	//Put task start address on top of hardware stack
	movw R2,R24
	sbiw R24,1
	movw R30,R2
	std z+0,R22
	.dbline 79
;     *stks-- = (INT8U)(tmp >> 8);
	movw R2,R24
	sbiw R24,1
	movw R10,R24
	movw R4,R22
	mov R4,R5
	clr R5
	movw R30,R2
	std z+0,R4
	.dbline 81
; 
;     *stk-- = (INT8U)0x00;		// R0  = 0x00
	movw R2,R20
	subi R20,1
	sbci R21,0
	clr R4
	movw R30,R2
	std z+0,R4
	.dbline 82
;     *stk-- = (INT8U)0x01; 
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,1
	movw R30,R2
	std z+0,R24
	.dbline 83
;     *stk-- = (INT8U)0x02;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,2
	movw R30,R2
	std z+0,R24
	.dbline 84
;     *stk-- = (INT8U)0x03;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,3
	movw R30,R2
	std z+0,R24
	.dbline 85
;     *stk-- = (INT8U)0x04;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,4
	movw R30,R2
	std z+0,R24
	.dbline 86
;     *stk-- = (INT8U)0x05;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,5
	movw R30,R2
	std z+0,R24
	.dbline 87
;     *stk-- = (INT8U)0x06;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,6
	movw R30,R2
	std z+0,R24
	.dbline 88
;     *stk-- = (INT8U)0x07;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,7
	movw R30,R2
	std z+0,R24
	.dbline 89
;     *stk-- = (INT8U)0x08;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,8
	movw R30,R2
	std z+0,R24
	.dbline 90
;     *stk-- = (INT8U)0x09;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,9
	movw R30,R2
	std z+0,R24
	.dbline 91
;     *stk-- = (INT8U)0x10;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,16
	movw R30,R2
	std z+0,R24
	.dbline 92
;     *stk-- = (INT8U)0x11;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,17
	movw R30,R2
	std z+0,R24
	.dbline 93
;     *stk-- = (INT8U)0x12;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,18
	movw R30,R2
	std z+0,R24
	.dbline 94
;     *stk-- = (INT8U)0x13;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,19
	movw R30,R2
	std z+0,R24
	.dbline 95
;     *stk-- = (INT8U)0x14;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,20
	movw R30,R2
	std z+0,R24
	.dbline 96
;     *stk-- = (INT8U)0x15;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,21
	movw R30,R2
	std z+0,R24
	.dbline 97
;     tmp    = (INT16U)pdata;
	movw R22,R18
	.dbline 98
;     *stk-- = (INT8U)tmp;	//Simulate call to function with argument
	movw R2,R20
	subi R20,1
	sbci R21,0
	movw R30,R2
	std z+0,R22
	.dbline 99
;     *stk-- = (INT8U)(tmp >> 8);
	movw R2,R20
	subi R20,1
	sbci R21,0
	movw R4,R22
	mov R4,R5
	clr R5
	movw R30,R2
	std z+0,R4
	.dbline 100
;     *stk-- = (INT8U)0x18;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,24
	movw R30,R2
	std z+0,R24
	.dbline 101
;     *stk-- = (INT8U)0x19;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,25
	movw R30,R2
	std z+0,R24
	.dbline 102
;     *stk-- = (INT8U)0x20;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,32
	movw R30,R2
	std z+0,R24
	.dbline 103
;     *stk-- = (INT8U)0x21;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,33
	movw R30,R2
	std z+0,R24
	.dbline 104
;     *stk-- = (INT8U)0x22;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,34
	movw R30,R2
	std z+0,R24
	.dbline 105
;     *stk-- = (INT8U)0x23;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,35
	movw R30,R2
	std z+0,R24
	.dbline 106
;     *stk-- = (INT8U)0x24;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,36
	movw R30,R2
	std z+0,R24
	.dbline 107
;     *stk-- = (INT8U)0x25;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,37
	movw R30,R2
	std z+0,R24
	.dbline 108
;     *stk-- = (INT8U)0x26;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,38
	movw R30,R2
	std z+0,R24
	.dbline 109
;     *stk-- = (INT8U)0x27;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,39
	movw R30,R2
	std z+0,R24
	.dbline 111
; 	// the heap pointer Y=R29:R28 will not be stored
;     *stk-- = (INT8U)0x30;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,48
	movw R30,R2
	std z+0,R24
	.dbline 112
;     *stk-- = (INT8U)0x31;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,49
	movw R30,R2
	std z+0,R24
	.dbline 113
;     *stk-- = (INT8U)0x3B;
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,59
	movw R30,R2
	std z+0,R24
	.dbline 114
;     *stk-- = (INT8U)0x80;	//SREG = Interrupts enabled
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,128
	movw R30,R2
	std z+0,R24
	.dbline 116
; 
;     tmp    = (INT16U)(stks);
	movw R22,R10
	.dbline 117
;     *stk-- = (INT8U)(tmp >> 8);
	movw R2,R20

⌨️ 快捷键说明

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