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

📄 os_cpu_a.lst

📁 在ucos_ii基础上加上网络功能
💻 LST
📖 第 1 页 / 共 2 页
字号:
Microsoft (R) Macro Assembler Version 6.11		    02/23/02 18:58:47
.\src\os_cpu_a.asm					     Page 1 - 1


				; $Id: os_cpu_a.asm,v 1.6 2002/02/07 01:08:53 linfusheng Exp $

					.386P						; Priviledged instructions can be used.


 00000000			_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
 0000				_TEXT	ENDS
 00000000			_DATA	SEGMENT DWORD USE32 PUBLIC 'DATA'
 0000				_DATA	ENDS
 00000000			CONST	SEGMENT DWORD USE32 PUBLIC 'CONST'
 0000				CONST	ENDS
 00000000			_BSS	SEGMENT DWORD USE32 PUBLIC 'BSS'
 0000				_BSS	ENDS
 00000000			_TLS	SEGMENT DWORD USE32 PUBLIC 'TLS'
 0000				_TLS	ENDS

				; Put all segment directives into one single group (flat memory model).

				GFLAT	GROUP _TEXT, _DATA, CONST, _BSS
						ASSUME	CS: GFLAT, DS: GFLAT, ES: GFLAT, SS: GFLAT

 00000000			_TEXT	SEGMENT

				;=======================================================================
				; uCOS-II Functions
				;=======================================================================



				;-----------------------------------------------------------------------
				; OSTickISR
				;-----------------------------------------------------------------------

				PUBLIC	_OSTickISR
				EXTRN	_OSIntEnter:NEAR
				EXTRN	_OSTimeTick:NEAR
				EXTRN	_OSIntExit:NEAR

 00000000			_OSTickISR	PROC NEAR

 00000000  60					pushad

				; Send an end-of-interrupt to the i8259.

 00000001  B0 20				mov	al,20h
 00000003  E6 20				out	20h,al

				; Standard uCOS processing.

 00000005  E8 00000000 E			call	_OSIntEnter
 0000000A  E8 00000000 E			call	_OSTimeTick
 0000000F  E8 00000000 E			call	_OSIntExit

 00000014  61					popad
 00000015  CF					iretd

 00000016			_OSTickISR ENDP




				;-----------------------------------------------------------------------
				; OSStartHighRdy
				;-----------------------------------------------------------------------

				PUBLIC	_OSStartHighRdy
				EXTRN	_OSTaskSwHook:NEAR
				EXTRN	_OSRunning:BYTE
				EXTRN	_OSTCBHighRdy:DWORD

 00000016			_OSStartHighRdy PROC NEAR


					; Call OSTaskSwHook();

 00000016  E8 00000000 E			call	_OSTaskSwHook

					; Increment OSRunning by 1 (the documentation says to set it to 1,
					; but the ix86l example increments it).

 0000001B  FE 05 00000000 E			inc		[_OSRunning]

					; Load the processor stack pointer with OSTCBHighRdy->OSTCBStkPtr

 00000021  A1 00000000 E			mov	eax,[_OSTCBHighRdy]	; Point to TCB of highest priority task ready to run
 00000026  8B 20				mov	esp,[eax]			; ESP = OSTCBHighRdy->OSTCBStkPtr

					; Pop all the processor registers from the stack

 00000028  61					popad

					; Execute a Return from interrupt intruction;

 00000029  CF					iretd

 0000002A			_OSStartHighRdy ENDP

				;-----------------------------------------------------------------------
				; OSCtxSw
				;-----------------------------------------------------------------------

				PUBLIC	_OSCtxSw
				EXTRN	_OSTCBCur:DWORD
				EXTRN	_OSTaskSwHook:NEAR
				EXTRN	_OSPrioHighRdy:BYTE
				EXTRN	_OSPrioCur:BYTE
				EXTRN	_OSTCBHighRdy:DWORD

 0000002A			_OSCtxSw	PROC NEAR

					; PUSH processor registers onto the current task's stack

 0000002A  60					pushad

					; Save the stack pointer into OSTCBCur->OSTCBStkPtr

 0000002B  A1 00000000 E			mov	eax,[_OSTCBCur]
 00000030  89 20				mov	[eax],esp			; Stack pointer is ESP

					; Call OSTaskSwHook();

 00000032  E8 00000000 E			call	_OSTaskSwHook

					; OSPrioCur = OSPrioHighRdy

 00000037  A0 00000000 E			mov	al,[_OSPrioHighRdy] ; AL is OSPrioHighRdy
 0000003C  A2 00000000 E			mov	[_OSPrioCur],al

					; OSTCBCur = OSTCBHighRdy

 00000041  A1 00000000 E			mov	eax,[_OSTCBHighRdy]	; EAX is OSTCBHighRdy
 00000046  A3 00000000 E			mov	[_OSTCBCur],eax

					; Load the processor stack pointer with OSTCBHighRdy->OSTCBStkPtr
					; Note that EAX is still OSTCBHighRdy.

 0000004B  8B 20				mov	esp,[eax]			; ESP = OSTCBHighRdy->OSTCBStkPtr

					; Pop all the processor registers from the stack

 0000004D  61					popad

					; Execute a Return from interrupt intruction;

 0000004E  CF					iretd

 0000004F			_OSCtxSw	ENDP

				;-----------------------------------------------------------------------
				; OSIntCtxSw
				;-----------------------------------------------------------------------

				PUBLIC	_OSIntCtxSw
				EXTRN	_OSTCBCur:DWORD
				EXTRN	_OSTaskSwHook:NEAR
				EXTRN	_OSPrioHighRdy:BYTE
				EXTRN	_OSPrioCur:BYTE
				EXTRN	_OSTCBHighRdy:DWORD

 0000004F			_OSIntCtxSw PROC NEAR

					; Adjust the stack pointer to remove call to OsIntExit(), locals in 
					; OsIntExit() and the call to OSIntCtxSw();

				;IFDEF _SAVE_INT_STATUS
 0000004F  83 C4 0C				add	esp,12			; Ignore calls to OSIntExit, PUSHFD and OSIntCtxSw
				;ELSE
				;		add	esp,8			; Ignore calls to OSIntExit and OSIntCtxSw
				;ENDIF

					; Save the stack pointer into OSTCBCur->OSTCBStkPtr

 00000052  A1 00000000 E			mov	eax,[_OSTCBCur]
 00000057  89 20				mov	[eax],esp			; Stack pointer is ESP

					; Call OSTaskSwHook();

 00000059  E8 00000000 E			call	_OSTaskSwHook

					; OSPrioCur = OSPrioHighRdy

 0000005E  A0 00000000 E			mov	al,[_OSPrioHighRdy] ; AL is OSPrioHighRdy
 00000063  A2 00000000 E			mov	[_OSPrioCur],al

					; OSTCBCur = OSTCBHighRdy

 00000068  A1 00000000 E			mov	eax,[_OSTCBHighRdy]	; EAX is OSTCBHighRdy
 0000006D  A3 00000000 E			mov	[_OSTCBCur],eax

					; Load the processor stack pointer with OSTCBHighRdy->OSTCBStkPtr
					; Note that EAX is still OSTCBHighRdy.

 00000072  8B 20				mov	esp,[eax]			; ESP = OSTCBHighRdy->OSTCBStkPtr

					; Pop all the processor registers from the stack

 00000074  61					popad

					; Execute a Return from interrupt intruction;

 00000075  CF					iretd

 00000076			_OSIntCtxSw ENDP

				;=======================================================================
				; x86 Helper Functions.
				;=======================================================================

				;-----------------------------------------------------------------------
				; void DefIntHandler();
				;
				; Default interrupt handler. It simply performs an interrupt return.
				; It is required to initialize all interrupt entries in the IDT.
				;-----------------------------------------------------------------------

				PUBLIC		_DefIntHandler
				EXTRN		_OSIntEnter:NEAR
				EXTRN		_OSDefault_interrupt:NEAR
				EXTRN		_OSIntExit:NEAR
 00000076			_DefIntHandler	PROC NEAR

 00000076  60					pushad

				; Standard uCOS processing.

 00000077  E8 00000000 E			call	_OSIntEnter
 0000007C  E8 00000000 E			call	_OSDefault_interrupt
 00000081  E8 00000000 E			call	_OSIntExit

				; Send an end-of-interrupt to the i8259.
 00000086  B0 20				mov	al,20h
 00000088  E6 20				out	20h,al

 0000008A  B0 20				mov al,20h
 0000008C  E6 A1				out 0a1h,al


 0000008E  61					popad
 0000008F  CF					iretd

 00000090			_DefIntHandler	ENDP



				; 中断 0
				PUBLIC		_DefIntHandler0
				EXTRN		_OSIntEnter:NEAR
				EXTRN		_OSDefault_interrupt_i:NEAR
				EXTRN		_OSIntExit:NEAR
 00000090			_DefIntHandler0	PROC NEAR

 00000090  60					pushad

				; Standard uCOS processing.

 00000091  E8 00000000 E			call	_OSIntEnter
 00000096  B8 00000000				mov		eax,0h
 0000009B  50					push	eax
 0000009C  E8 00000000 E			call	_OSDefault_interrupt_i
 000000A1  66| 83 C4 04				add		sp,4
 000000A5  E8 00000000 E			call	_OSIntExit

				; Send an end-of-interrupt to the i8259.
 000000AA  B0 20				mov	al,20h
 000000AC  E6 20				out	20h,al

 000000AE  B0 20				mov al,20h
 000000B0  E6 A1				out 0a1h,al


 000000B2  61					popad
 000000B3  CF					iretd

 000000B4			_DefIntHandler0	ENDP



				;中断1
				PUBLIC		_DefIntHandler1
				EXTRN		_OSIntEnter:NEAR
				EXTRN		_OSDefault_interrupt:NEAR
				EXTRN		_OSIntExit:NEAR
 000000B4			_DefIntHandler1	PROC NEAR

 000000B4  60					pushad


				; Standard uCOS processing.

 000000B5  E8 00000000 E			call	_OSIntEnter
 000000BA  B8 00000001				mov		eax,01h
 000000BF  50					push	eax
 000000C0  E8 00000000 E			call	_OSDefault_interrupt
 000000C5  66| 83 C4 04				add		sp,4
 000000C9  E8 00000000 E			call	_OSIntExit

				; Send an end-of-interrupt to the i8259.
 000000CE  B0 20				mov	al,20h
 000000D0  E6 20				out	20h,al

 000000D2  B0 20				mov al,20h
 000000D4  E6 A1				out 0a1h,al

 000000D6  61					popad
 000000D7  CF					iretd

 000000D8			_DefIntHandler1	ENDP

				;中断2
				PUBLIC		_DefIntHandler2
				EXTRN		_OSIntEnter:NEAR
				EXTRN		_OSDefault_interrupt:NEAR
				EXTRN		_OSIntExit:NEAR
 000000D8			_DefIntHandler2	PROC NEAR

 000000D8  60					pushad

				; Standard uCOS processing.

 000000D9  E8 00000000 E			call	_OSIntEnter
 000000DE  B8 00000002				mov		eax,02h
 000000E3  50					push	eax
 000000E4  E8 00000000 E			call	_OSDefault_interrupt
 000000E9  66| 83 C4 04				add		sp,4
 000000ED  E8 00000000 E			call	_OSIntExit

				; Send an end-of-interrupt to the i8259.
 000000F2  B0 20				mov	al,20h
 000000F4  E6 20				out	20h,al

 000000F6  B0 20				mov al,20h
 000000F8  E6 A1				out 0a1h,al


 000000FA  61					popad
 000000FB  CF					iretd

 000000FC			_DefIntHandler2	ENDP



				;中断3
				PUBLIC		_DefIntHandler3
				EXTRN		_OSIntEnter:NEAR
				EXTRN		_OSDefault_interrupt:NEAR
				EXTRN		_OSIntExit:NEAR
 000000FC			_DefIntHandler3	PROC NEAR

 000000FC  60					pushad

				; Standard uCOS processing.

 000000FD  E8 00000000 E			call	_OSIntEnter
 00000102  B8 00000003				mov		eax,03h
 00000107  50					push	eax
 00000108  E8 00000000 E			call	_OSDefault_interrupt
 0000010D  66| 83 C4 04				add		sp,4
 00000111  E8 00000000 E			call	_OSIntExit

				; Send an end-of-interrupt to the i8259.
 00000116  B0 20				mov	al,20h
 00000118  E6 20				out	20h,al

 0000011A  B0 20				mov al,20h
 0000011C  E6 A1				out 0a1h,al

 0000011E  61					popad
 0000011F  CF					iretd

 00000120			_DefIntHandler3	ENDP


				;中断4
				PUBLIC		_DefIntHandler4
				EXTRN		_OSIntEnter:NEAR
				EXTRN		_OSDefault_interrupt:NEAR
				EXTRN		_OSIntExit:NEAR
 00000120			_DefIntHandler4	PROC NEAR

 00000120  60					pushad

				; Standard uCOS processing.

 00000121  E8 00000000 E			call	_OSIntEnter
 00000126  B8 00000004				mov		eax,04h
 0000012B  50					push	eax
 0000012C  E8 00000000 E			call	_OSDefault_interrupt
 00000131  66| 83 C4 04				add		sp,4		
 00000135  E8 00000000 E			call	_OSIntExit

				; Send an end-of-interrupt to the i8259.
 0000013A  B0 20				mov	al,20h
 0000013C  E6 20				out	20h,al

 0000013E  B0 20				mov al,20h
 00000140  E6 A1				out 0a1h,al

 00000142  61					popad
 00000143  CF					iretd

 00000144			_DefIntHandler4	ENDP



				;中断5
				PUBLIC		_DefIntHandler5
				EXTRN		_OSIntEnter:NEAR
				EXTRN		_OSDefault_interrupt:NEAR
				EXTRN		_OSIntExit:NEAR
 00000144			_DefIntHandler5	PROC NEAR

 00000144  60					pushad

⌨️ 快捷键说明

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