www.pudn.com > iccavrUCOS_m64.rar > Ucos_ii.s
.module Ucos_ii.c .area lit(rom, con, rel) _OSMapTbl:: .byte 1,2 .byte 4,8 .byte 16,32 .byte 64,128 _OSUnMapTbl:: .byte 0,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 3,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 4,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 3,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 5,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 3,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 4,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 3,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 6,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 3,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 4,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 3,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 5,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 3,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 4,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 3,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 7,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 3,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 4,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 3,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 5,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 3,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 4,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 3,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 6,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 3,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 4,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 3,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 5,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 3,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 4,0 .byte 1,0 .byte 2,0 .byte 1,0 .byte 3,0 .byte 1,0 .byte 2,0 .byte 1,0 .area text(rom, con, rel) ; i -> R10,R11 .even _OSInit:: xcall push_gset3x sbiw R28,3 ; /* ; ********************************************************************************************************* ; * uC/OS-II ; * The Real-Time Kernel ; * ; * (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL ; * All Rights Reserved ; * ; * V2.00 ; * ; * File : uCOS_II.C ; * By : Jean J. Labrosse ; ********************************************************************************************************* ; */ ; ; #define OS_GLOBALS /* Declare GLOBAL variables */ ; #include "includes.h" ; ; ; #define OS_MASTER_FILE /* Prevent the following files from including includes.h */ ; #include "os_core.c" ; #include "os_task.c" ; #include "os_time.c" ; //#include "uart.c" ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ldi R24,0 ldi R25,0 ldi R26,0 ldi R27,0 sts _OSTime+1,R25 sts _OSTime,R24 sts _OSTime+2+1,R27 sts _OSTime+2,R26 ; clr R2 sts _OSIntNesting,R2 ; sts _OSLockNesting,R2 ; ; sts _OSTaskCtr,R2 ; ; sts _OSRunning,R2 ; ldi R24,0 ldi R25,0 ldi R26,0 ldi R27,0 sts _OSIdleCtr+1,R25 sts _OSIdleCtr,R24 sts _OSIdleCtr+2+1,R27 sts _OSIdleCtr+2,R26 ; ; ldi R24,0 ldi R25,0 ldi R26,0 ldi R27,0 sts _OSCtxSwCtr+1,R25 sts _OSCtxSwCtr,R24 sts _OSCtxSwCtr+2+1,R27 sts _OSCtxSwCtr+2,R26 ; sts _OSRdyGrp,R2 clr R10 clr R11 xjmp L6 L3: ldi R24,<_OSRdyTbl ldi R25,>_OSRdyTbl movw R30,R10 add R30,R24 adc R31,R25 clr R2 std z+0,R2 L4: movw R24,R10 adiw R24,1 movw R10,R24 L6: ; movw R24,R10 cpi R24,2 ldi R30,0 cpc R25,R30 brlo L3 ; ; ; ; clr R2 sts _OSPrioCur,R2 ; sts _OSPrioHighRdy,R2 ; clr R3 sts _OSTCBHighRdy+1,R3 sts _OSTCBHighRdy,R2 ; sts _OSTCBCur+1,R3 sts _OSTCBCur,R2 ; sts _OSTCBList+1,R3 sts _OSTCBList,R2 clr R10 clr R11 xjmp L10 L7: ldi R16,2 ldi R17,0 movw R18,R10 xcall empy16s movw R30,R16 ldi R24,<_OSTCBPrioTbl ldi R25,>_OSTCBPrioTbl add R30,R24 adc R31,R25 clr R2 clr R3 std z+1,R3 std z+0,R2 L8: movw R24,R10 adiw R24,1 movw R10,R24 L10: ; movw R24,R10 cpi R24,16 ldi R30,0 cpc R25,R30 brlo L7 clr R10 clr R11 xjmp L14 L11: movw R18,R10 subi R18,255 ; offset = 1 sbci R19,255 ldi R16,14 ldi R17,0 xcall empy16s movw R2,R16 ldi R24,<_OSTCBTbl ldi R25,>_OSTCBTbl add R2,R24 adc R3,R25 ldi R16,14 ldi R17,0 movw R18,R10 xcall empy16s movw R30,R16 ldi R24,<_OSTCBTbl+2 ldi R25,>_OSTCBTbl+2 add R30,R24 adc R31,R25 std z+1,R3 std z+0,R2 L12: movw R24,R10 adiw R24,1 movw R10,R24 L14: ; ; ; movw R24,R10 cpi R24,5 ldi R30,0 cpc R25,R30 brlo L11 ; ; ; clr R2 clr R3 sts _OSTCBTbl+70+2+1,R3 sts _OSTCBTbl+70+2,R2 ; ldi R24,<_OSTCBTbl ldi R25,>_OSTCBTbl sts _OSTCBFreeList+1,R25 sts _OSTCBFreeList,R24 clr R10 clr R11 xjmp L21 L18: movw R18,R10 subi R18,255 ; offset = 1 sbci R19,255 ldi R16,8 ldi R17,0 xcall empy16s movw R2,R16 ldi R24,<_OSEventTbl ldi R25,>_OSEventTbl add R2,R24 adc R3,R25 ldi R16,8 ldi R17,0 movw R18,R10 xcall empy16s movw R30,R16 ldi R24,<_OSEventTbl ldi R25,>_OSEventTbl add R30,R24 adc R31,R25 std z+1,R3 std z+0,R2 L19: movw R24,R10 adiw R24,1 movw R10,R24 L21: ; ; ; movw R24,R10 cpi R24,1 ldi R30,0 cpc R25,R30 brlo L18 ; ; ; clr R2 clr R3 sts _OSEventTbl+8+1,R3 sts _OSEventTbl+8,R2 ; ldi R24,<_OSEventTbl ldi R25,>_OSEventTbl sts _OSEventFreeList+1,R25 sts _OSEventFreeList,R24 ; ; ; ; ldi R24,15 std y+2,R24 ldi R24,<_OSTaskIdleStk+99 ldi R25,>_OSTaskIdleStk+99 std y+1,R25 std y+0,R24 clr R18 clr R19 ldi R16,PL_OSTaskIdle xcall _OSTaskCreate L2: adiw R28,3 xcall pop_gset3x .dbline 0 ; func end ret .even _OSIntExit:: ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; st -y,r16 in r16,0x3F cli push r16 ld r16,y+ ; lds R24,_OSIntNesting subi R24,1 mov R2,R24 sts _OSIntNesting,R2 lds R4,_OSLockNesting or R2,R4 breq X0 xjmp L25 X0: ; ldi R24,<_OSUnMapTbl ldi R25,>_OSUnMapTbl lds R30,_OSRdyGrp clr R31 add R30,R24 adc R31,R25 lpm R30,Z sts _OSIntExitY,R30 ; ldi R24,<_OSRdyTbl ldi R25,>_OSRdyTbl clr R31 add R30,R24 adc R31,R25 ldd R30,z+0 clr R31 ldi R24,<_OSUnMapTbl ldi R25,>_OSUnMapTbl add R30,R24 adc R31,R25 lpm R2,Z clr R3 lds R4,_OSIntExitY clr R5 lsl R4 rol R5 lsl R4 rol R5 lsl R4 rol R5 add R4,R2 adc R5,R3 sts _OSPrioHighRdy,R4 ; lds R2,_OSPrioCur cp R4,R2 breq L27 ; mov R2,R4 ldi R24,2 mul R24,R2 movw R30,R0 ldi R24,<_OSTCBPrioTbl ldi R25,>_OSTCBPrioTbl add R30,R24 adc R31,R25 ldd R2,z+0 ldd R3,z+1 sts _OSTCBHighRdy+1,R3 sts _OSTCBHighRdy,R2 ; ldi R24,1 ldi R25,0 ldi R26,0 ldi R27,0 lds R4,_OSCtxSwCtr+2 lds R5,_OSCtxSwCtr+2+1 lds R2,_OSCtxSwCtr lds R3,_OSCtxSwCtr+1 add R2,R24 adc R3,R25 adc R4,R26 adc R5,R27 sts _OSCtxSwCtr+1,R3 sts _OSCtxSwCtr,R2 sts _OSCtxSwCtr+2+1,R5 sts _OSCtxSwCtr+2,R4 ; xcall _OSIntCtxSw ; L27: ; L25: ; st -y,r16 pop r16 out 0x3F,r16 ld r16,y+ L24: .dbline 0 ; func end ret ; y -> R10 .even _OSSched:: xcall push_gset3x ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; st -y,r16 in r16,0x3F cli push r16 ld r16,y+ ; lds R2,_OSIntNesting lds R3,_OSLockNesting or R3,R2 breq X1 xjmp L30 X1: ; ldi R24,<_OSUnMapTbl ldi R25,>_OSUnMapTbl lds R30,_OSRdyGrp clr R31 add R30,R24 adc R31,R25 lpm R10,Z ; ldi R24,<_OSRdyTbl ldi R25,>_OSRdyTbl mov R30,R10 clr R31 add R30,R24 adc R31,R25 ldd R30,z+0 clr R31 ldi R24,<_OSUnMapTbl ldi R25,>_OSUnMapTbl add R30,R24 adc R31,R25 lpm R2,Z clr R3 mov R4,R10 clr R5 lsl R4 rol R5 lsl R4 rol R5 lsl R4 rol R5 add R4,R2 adc R5,R3 sts _OSPrioHighRdy,R4 ; lds R2,_OSPrioCur cp R4,R2 breq L32 ; mov R2,R4 ldi R24,2 mul R24,R2 movw R30,R0 ldi R24,<_OSTCBPrioTbl ldi R25,>_OSTCBPrioTbl add R30,R24 adc R31,R25 ldd R2,z+0 ldd R3,z+1 sts _OSTCBHighRdy+1,R3 sts _OSTCBHighRdy,R2 ; ldi R24,1 ldi R25,0 ldi R26,0 ldi R27,0 lds R4,_OSCtxSwCtr+2 lds R5,_OSCtxSwCtr+2+1 lds R2,_OSCtxSwCtr lds R3,_OSCtxSwCtr+1 add R2,R24 adc R3,R25 adc R4,R26 adc R5,R27 sts _OSCtxSwCtr+1,R3 sts _OSCtxSwCtr,R2 sts _OSCtxSwCtr+2+1,R5 sts _OSCtxSwCtr+2,R4 ; xcall _OSCtxSw ; L32: ; L30: ; st -y,r16 pop r16 out 0x3F,r16 ld r16,y+ L29: xcall pop_gset3x .dbline 0 ; func end ret ; x -> R12 ; y -> R10 .even _OSStart:: xcall push_gset4x ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; lds R2,_OSRunning tst R2 breq X2 xjmp L35 X2: ; ldi R24,<_OSUnMapTbl ldi R25,>_OSUnMapTbl lds R30,_OSRdyGrp clr R31 add R30,R24 adc R31,R25 lpm R10,Z ; ldi R24,<_OSRdyTbl ldi R25,>_OSRdyTbl mov R30,R10 clr R31 add R30,R24 adc R31,R25 ldd R30,z+0 clr R31 ldi R24,<_OSUnMapTbl ldi R25,>_OSUnMapTbl add R30,R24 adc R31,R25 lpm R12,Z ; mov R2,R12 clr R3 mov R4,R10 clr R5 lsl R4 rol R5 lsl R4 rol R5 lsl R4 rol R5 add R4,R2 adc R5,R3 sts _OSPrioHighRdy,R4 ; mov R2,R4 sts _OSPrioCur,R2 ; ldi R24,2 mul R24,R2 movw R30,R0 ldi R24,<_OSTCBPrioTbl ldi R25,>_OSTCBPrioTbl add R30,R24 adc R31,R25 ldd R2,z+0 ldd R3,z+1 sts _OSTCBHighRdy+1,R3 sts _OSTCBHighRdy,R2 ; sts _OSTCBCur+1,R3 sts _OSTCBCur,R2 ; xcall _OSStartHighRdy ; L35: L34: xcall pop_gset4x .dbline 0 ; func end ret ; pdata -> R16,R17 .even _OSTaskIdle:: ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; L38: ; ; st -y,r16 in r16,0x3F cli push r16 ld r16,y+ ; ldi R24,1 ldi R25,0 ldi R26,0 ldi R27,0 lds R4,_OSIdleCtr+2 lds R5,_OSIdleCtr+2+1 lds R2,_OSIdleCtr lds R3,_OSIdleCtr+1 add R2,R24 adc R3,R25 adc R4,R26 adc R5,R27 sts _OSIdleCtr+1,R3 sts _OSIdleCtr,R2 sts _OSIdleCtr+2+1,R5 sts _OSIdleCtr+2,R4 ; st -y,r16 pop r16 out 0x3F,r16 ld r16,y+ ; xjmp L38 X3: L37: .dbline 0 ; func end ret ; ptcb -> R10,R11 ; opt -> y+10 ; pext -> y+8 ; stk_size -> y+6 ; id -> y+4 ; pbos -> y+2 ; ptos -> R18,R19 ; prio -> R16 .even _OSTCBInit:: xcall push_gset3x ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; st -y,r16 in r16,0x3F cli push r16 ld r16,y+ ; lds R10,_OSTCBFreeList lds R11,_OSTCBFreeList+1 ; tst R10 brne X4 tst R11 brne X6 xjmp L43 X6: X4: ; movw R30,R10 ldd R2,z+2 ldd R3,z+3 sts _OSTCBFreeList+1,R3 sts _OSTCBFreeList,R2 ; st -y,r16 pop r16 out 0x3F,r16 ld r16,y+ ; movw R30,R10 std z+1,R19 std z+0,R18 ; std z+9,R16 ; clr R2 movw R30,R10 std z+8,R2 ; clr R3 movw R30,R10 std z+7,R3 std z+6,R2 ; ; ; ; ; ; ; ; mov R2,R16 lsr R2 lsr R2 lsr R2 movw R30,R10 std z+11,R2 ; ldi R24,<_OSMapTbl ldi R25,>_OSMapTbl movw R30,R10 ldd R30,z+11 clr R31 add R30,R24 adc R31,R25 lpm R30,Z movw R26,R10 adiw R26,13 st x,R30 ; mov R24,R16 andi R24,7 movw R30,R10 std z+10,R24 ; ldi R24,<_OSMapTbl ldi R25,>_OSMapTbl movw R30,R10 ldd R30,z+10 clr R31 add R30,R24 adc R31,R25 lpm R30,Z movw R26,R10 adiw R26,12 st x,R30 ; ; st -y,r16 in r16,0x3F cli push r16 ld r16,y+ ; ldi R24,2 mul R24,R16 movw R30,R0 ldi R24,<_OSTCBPrioTbl ldi R25,>_OSTCBPrioTbl add R30,R24 adc R31,R25 std z+1,R11 std z+0,R10 ; lds R2,_OSTCBList lds R3,_OSTCBList+1 movw R30,R10 std z+3,R3 std z+2,R2 ; clr R2 clr R3 movw R30,R10 std z+5,R3 std z+4,R2 ; lds R2,_OSTCBList lds R3,_OSTCBList+1 tst R2 brne X5 tst R3 breq L45 X5: ; lds R30,_OSTCBList lds R31,_OSTCBList+1 std z+5,R11 std z+4,R10 ; L45: ; sts _OSTCBList+1,R11 sts _OSTCBList,R10 ; movw R30,R10 ldd R2,z+13 lds R3,_OSRdyGrp or R3,R2 sts _OSRdyGrp,R3 ; ldi R24,<_OSRdyTbl ldi R25,>_OSRdyTbl movw R30,R10 ldd R2,z+11 clr R3 add R2,R24 adc R3,R25 movw R30,R10 ldd R4,z+12 movw R30,R2 ldd R5,z+0 or R5,R4 std z+0,R5 ; st -y,r16 pop r16 out 0x3F,r16 ld r16,y+ ; clr R16 xjmp L42 L43: ; ; st -y,r16 pop r16 out 0x3F,r16 ld r16,y+ ; ldi R16,70 L42: xcall pop_gset3x .dbline 0 ; func end ret ; ptcb -> R16,R17 .even _OSTimeTick:: ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; lds R16,_OSTCBList lds R17,_OSTCBList+1 xjmp L49 L48: ; ; st -y,r16 in r16,0x3F cli push r16 ld r16,y+ ; movw R30,R16 ldd R2,z+6 ldd R3,z+7 tst R2 brne X7 tst R3 brne X9 xjmp L51 X9: X7: ; movw R24,R16 adiw R24,6 movw R30,R24 ldd R24,z+0 ldd R25,z+1 sbiw R24,1 movw R4,R24 std z+1,R5 std z+0,R4 cpi R24,0 cpc R24,R25 breq X10 xjmp L53 X10: X8: ; movw R30,R16 ldd R2,z+8 sbrc R2,3 rjmp L55 ; movw R30,R16 ldd R2,z+13 lds R3,_OSRdyGrp or R3,R2 sts _OSRdyGrp,R3 ; ldi R24,<_OSRdyTbl ldi R25,>_OSRdyTbl movw R30,R16 ldd R2,z+11 clr R3 add R2,R24 adc R3,R25 movw R30,R16 ldd R4,z+12 movw R30,R2 ldd R5,z+0 or R5,R4 std z+0,R5 xjmp L56 L55: ; ; ldi R24,1 ldi R25,0 movw R30,R16 std z+7,R25 std z+6,R24 ; L56: ; L53: ; L51: movw R30,R16 ldd R16,z+2 ldd R17,z+3 st -y,r16 pop r16 out 0x3F,r16 ld r16,y+ L49: movw R30,R16 ldd R24,z+9 cpi R24,15 breq X11 xjmp L48 X11: ; ; ; ; st -y,r16 in r16,0x3F cli push r16 ld r16,y+ ; ldi R24,1 ldi R25,0 ldi R26,0 ldi R27,0 lds R4,_OSTime+2 lds R5,_OSTime+2+1 lds R2,_OSTime lds R3,_OSTime+1 add R2,R24 adc R3,R25 adc R4,R26 adc R5,R27 sts _OSTime+1,R3 sts _OSTime,R2 sts _OSTime+2+1,R5 sts _OSTime+2,R4 ; st -y,r16 pop r16 out 0x3F,r16 ld r16,y+ L47: .dbline 0 ; func end ret ; stks -> R14,R15 ; tmp -> R12,R13 ; stk -> R10,R11 ; opt -> y+8 ; ptos -> y+6 ; pdata -> R18,R19 ; task -> R16,R17 .even _OSTaskStkInit:: xcall push_gset5x ldd R10,y+6 ldd R11,y+7 movw R24,R10 subi R24,68 sbci R25,0 movw R30,R16 lpm R12,Z+ lpm R13,Z movw R2,R24 sbiw R24,1 movw R30,R2 std z+0,R12 movw R2,R24 sbiw R24,1 movw R14,R24 movw R4,R12 mov R4,R5 clr R5 movw R30,R2 std z+0,R4 movw R2,R10 movw R24,R2 sbiw R24,1 clr R4 movw R30,R2 std z+0,R4 movw R2,R24 sbiw R24,1 movw R10,R24 ldi R24,1 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,2 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,3 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,4 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,5 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,6 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,7 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,8 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,9 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,16 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,17 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,18 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,19 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,20 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,21 movw R30,R2 std z+0,R24 movw R12,R18 movw R2,R10 movw R24,R2 sbiw R24,1 movw R30,R2 std z+0,R12 movw R2,R24 sbiw R24,1 movw R4,R12 mov R4,R5 clr R5 movw R30,R2 std z+0,R4 movw R2,R24 sbiw R24,1 movw R10,R24 ldi R24,24 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,25 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,32 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,33 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,34 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,35 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,36 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,37 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,38 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,39 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,48 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,49 movw R30,R2 std z+0,R24 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 ldi R24,128 movw R30,R2 std z+0,R24 movw R12,R14 movw R2,R10 movw R24,R2 sbiw R24,1 movw R10,R24 movw R4,R12 mov R4,R5 clr R5 movw R30,R2 std z+0,R4 movw R30,R24 std z+0,R12 movw R16,R24 L57: xcall pop_gset5x .dbline 0 ; func end ret ; psp -> R10,R11 ; err -> R10 ; prio -> R12 ; ptos -> y+16 ; pdata -> R14,R15 ; task -> R10,R11 .even _OSTaskCreate:: xcall push_gset5x movw R14,R18 movw R10,R16 sbiw R28,10 ldd R12,y+18 ldi R24,15 cp R24,R12 brsh L59 ldi R16,42 xjmp L58 L59: st -y,r16 in r16,0x3F cli push r16 ld r16,y+ ldi R24,2 mul R24,R12 movw R30,R0 ldi R24,<_OSTCBPrioTbl ldi R25,>_OSTCBPrioTbl add R30,R24 adc R31,R25 ldd R2,z+0 ldd R3,z+1 tst R2 breq X13 xjmp L61 X13: tst R3 breq X14 xjmp L61 X14: X12: ldi R24,2 mul R24,R12 movw R30,R0 ldi R24,<_OSTCBPrioTbl ldi R25,>_OSTCBPrioTbl add R30,R24 adc R31,R25 ldi R24,1 ldi R25,0 std z+1,R25 std z+0,R24 st -y,r16 pop r16 out 0x3F,r16 ld r16,y+ clr R2 clr R3 std y+3,R3 std y+2,R2 ldd R0,y+16 ldd R1,y+17 std y+1,R1 std y+0,R0 movw R18,R14 movw R16,R10 xcall _OSTaskStkInit movw R10,R16 clr R2 clr R3 std y+9,R3 std y+8,R2 std y+7,R3 std y+6,R2 std y+5,R3 std y+4,R2 std y+3,R3 std y+2,R2 std y+1,R3 std y+0,R2 movw R18,R10 mov R16,R12 xcall _OSTCBInit mov R10,R16 tst R16 brne L63 st -y,r16 in r16,0x3F cli push r16 ld r16,y+ lds R24,_OSTaskCtr subi R24,255 ; addi 1 sts _OSTaskCtr,R24 st -y,r16 pop r16 out 0x3F,r16 ld r16,y+ lds R2,_OSRunning tst R2 breq L64 xcall _OSSched xjmp L64 L63: st -y,r16 in r16,0x3F cli push r16 ld r16,y+ ldi R24,2 mul R24,R12 movw R30,R0 ldi R24,<_OSTCBPrioTbl ldi R25,>_OSTCBPrioTbl add R30,R24 adc R31,R25 clr R2 clr R3 std z+1,R3 std z+0,R2 st -y,r16 pop r16 out 0x3F,r16 ld r16,y+ L64: mov R16,R10 xjmp L58 L61: st -y,r16 pop r16 out 0x3F,r16 ld r16,y+ ldi R16,40 L58: adiw R28,10 xcall pop_gset5x .dbline 0 ; func end ret ; ticks -> R10,R11 .even _OSTimeDly:: xcall push_gset3x movw R10,R16 tst R10 brne X15 tst R11 brne X16 xjmp L68 X16: X15: st -y,r16 in r16,0x3F cli push r16 ld r16,y+ ldi R24,<_OSRdyTbl ldi R25,>_OSRdyTbl lds R30,_OSTCBCur lds R31,_OSTCBCur+1 ldd R2,z+11 clr R3 add R2,R24 adc R3,R25 lds R30,_OSTCBCur lds R31,_OSTCBCur+1 ldd R4,z+12 com R4 movw R30,R2 ldd R5,z+0 and R5,R4 mov R4,R5 std z+0,R4 tst R5 brne L70 lds R30,_OSTCBCur lds R31,_OSTCBCur+1 ldd R2,z+13 com R2 lds R3,_OSRdyGrp and R3,R2 sts _OSRdyGrp,R3 L70: lds R30,_OSTCBCur lds R31,_OSTCBCur+1 std z+7,R11 std z+6,R10 st -y,r16 pop r16 out 0x3F,r16 ld r16,y+ xcall _OSSched L68: L67: xcall pop_gset3x .dbline 0 ; func end ret .area bss(ram, con, rel) _OSTCBTbl: .blkb 84 _OSTaskIdleStk: .blkb 100 _OSIntExitY: .blkb 1 _OSTime:: .blkb 4 _OSTCBPrioTbl:: .blkb 32 _OSTCBList:: .blkb 2 _OSTCBHighRdy:: .blkb 2 _OSTCBFreeList:: .blkb 2 _OSTCBCur:: .blkb 2 _OSTaskCtr:: .blkb 1 _OSRunning:: .blkb 1 _OSRdyTbl:: .blkb 2 _OSRdyGrp:: .blkb 1 _OSPrioHighRdy:: .blkb 1 _OSPrioCur:: .blkb 1 _OSLockNesting:: .blkb 1 _OSIntNesting:: .blkb 1 _OSIdleCtr:: .blkb 4 _OSEventTbl:: .blkb 16 _OSEventFreeList:: .blkb 2 _OSCtxSwCtr:: .blkb 4 .area func_lit PL_OSTaskIdle: .word `_OSTaskIdle