调试的时候有一段本该执行的代码被自动跳过去了,执行不了
小弟在做UCOS操作系统移植的时候函数OS_Sched()里面的一段本该执行的代码被自动跳过了。该部分代码对应的反汇编文件显示 NO source file,不知道代码被跳过是不是和这个有关系。void OS_Sched (void)
{
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
INT8U y;
OS_ENTER_CRITICAL();
if ((OSIntNesting == 0) && (OSLockNesting == 0)) {
y = OSUnMapTbl[OSRdyGrp]; /*从本行代码开始跳过*/
OSPrioHighRdy = (INT8U)((y << 3) + OSUnMapTbl[OSRdyTbl[y]]);
if (OSPrioHighRdy != OSPrioCur) {
OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];
OSCtxSwCtr++;
OS_TASK_SW();
}
}
OS_EXIT_CRITICAL();
}/*直接跳到这个地方,本来这个IF语句是应该执行的*/
反汇编文件如下:
307: if ((OSIntNesting == 0) && (OSLockNesting == 0)) { /* Reschedule only if all ISRs complete ... */
00000212 CPSE R24,R1 Compare, skip if equal
00000213 RJMP PC+0x0041 Relative jump
--- No source file -------------------------------------------------------------
00000214 LDS R24,0x016C Load direct from data space
00000216 CPSE R24,R1 Compare, skip if equal
00000217 RJMP PC+0x003D Relative jump
00000218 LDS R30,0x0181 Load direct from data space
0000021A LDI R31,0x00 Load immediate
0000021B SUBI R30,0xA0 Subtract immediate
0000021C SBCI R31,0xFF Subtract immediate with carry
0000021D LDD R24,Z+0 Load indirect with displacement
0000021E STS 0x0189,R24 Store direct to data space
00000220 MOV R30,R24 Copy register
00000221 LDI R31,0x00 Load immediate
00000222 SUBI R30,0x7E Subtract immediate
00000223 SBCI R31,0xFE Subtract immediate with carry
00000224 LDD R30,Z+0 Load indirect with displacement
00000225 LDI R31,0x00 Load immediate
00000226 SUBI R30,0xA0 Subtract immediate
00000227 SBCI R31,0xFF Subtract immediate with carry
00000228 LSL R24 Logical Shift Left
00000229 LSL R24 Logical Shift Left
0000022A LSL R24 Logical Shift Left
0000022B LDD R25,Z+0 Load indirect with displacement
0000022C ADD R24,R25 Add without carry
0000022D STS 0x0172,R24 Store direct to data space
--- E:\AVR_Studio_document\abc\abc_test\abc_test\Debug/.././os_core.c ----------
310: if (OSPrioHighRdy != OSPrioCur) { /* No Ctx Sw if current task is highest rdy */
0000022F LDS R25,0x0175 Load direct from data space
00000231 CP R24,R25 Compare
00000232 BREQ PC+0x22 Branch if equal
311: OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];
00000233 MOV R30,R24 Copy register
00000234 LDI R31,0x00 Load immediate
00000235 LSL R30 Logical Shift Left
00000236 ROL R31 Rotate Left Through Carry
00000237 SUBI R30,0x6B Subtract immediate
00000238 SBCI R31,0xFD Subtract immediate with carry
00000239 LDD R24,Z+0 Load indirect with displacement
0000023A LDD R25,Z+1 Load indirect with displacement
0000023B STS 0x0180,R25 Store direct to data space
0000023D STS 0x017F,R24 Store direct to data space
312: OSCtxSwCtr++; /* Keep track of the number of context switches */
0000023F LDS R20,0x0178 Load direct from data space
00000241 LDS R21,0x0179 Load direct from data space
00000243 LDS R22,0x017A Load direct from data space
00000245 LDS R23,0x017B Load direct from data space
00000247 SUBI R20,0xFF Subtract immediate
00000248 SBCI R21,0xFF Subtract immediate with carry
00000249 SBCI R22,0xFF Subtract immediate with carry
0000024A SBCI R23,0xFF Subtract immediate with carry
0000024B STS 0x0178,R20 Store direct to data space
0000024D STS 0x0179,R21 Store direct to data space
0000024F STS 0x017A,R22 Store direct to data space
00000251 STS 0x017B,R23 Store direct to data space
313: OSIntCtxSw(); /* Perform interrupt level context switch */
00000253 RCALL PC-0x018A Relative call subroutine
316: OS_EXIT_CRITICAL();
00000254 MOV R24,R28 Copy register
00000255 RCALL PC-0x0223 Relative call subroutine
317: }
00000256 POP R28 Pop register from stack
00000257 RET Subroutine return