pxTopOfStack--;\r
*pxTopOfStack = ( portSTACK_TYPE ) 0xdddddd;\r
pxTopOfStack--;\r
- *pxTopOfStack = ( portSTACK_TYPE ) 0xcccccc;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) pvParameters;\r
pxTopOfStack--;\r
*pxTopOfStack = ( portSTACK_TYPE ) 0xbbbbbb;\r
pxTopOfStack--;\r
#ifndef PORTASM_H\r
#define PORTASM_H\r
\r
-portSAVE_CONTEXT macro\r
-\r
IMPORT pxCurrentTCB\r
IMPORT usCriticalNesting\r
\r
+portSAVE_CONTEXT macro\r
+\r
/* Save the remaining registers. */\r
- push r4\r
- push r5\r
- push r6\r
- push r7\r
- push r8\r
- push r9\r
- push r10\r
- push r11\r
- push r12\r
- push r13\r
- push r14\r
- push r15\r
- mov.w &usCriticalNesting, r14\r
- push r14\r
- mov.w &pxCurrentTCB, r12\r
- mov.w r1, 0(r12)\r
+ pushm.a #12, r15\r
+ movx.w &usCriticalNesting, r14\r
+ pushx.a r14\r
+ movx.a &pxCurrentTCB, r12\r
+ movx.a sp, 0( r12 )\r
endm\r
/*-----------------------------------------------------------*/\r
\r
portRESTORE_CONTEXT macro\r
+\r
movx.a &pxCurrentTCB, r12\r
- movx.a @r12, r1\r
+ movx.a @r12, sp\r
popx.a r15\r
movx.w r15, &usCriticalNesting\r
popm.a #12, r15\r
*/\r
vPortYield:\r
\r
- /* Mimic an interrupt by pushing the SR. */\r
- push SR \r
+ /* Mimic an interrupt by combining the SR and the PC, the latter having\r
+ already been pushed onto the stack. R14 is a scratch registers. */\r
+ popx.a r14 /* r14 will hold the 20 bit PC. */\r
+ push.w r14 /* Push just 16 bits of the 20bit PC back onto the stack. */\r
+ rram.a #4, r14 /* Move the top 4 bits of the PC down ready to be combined with the SP. */\r
+ and.w #0xf000, r14/* Ensure other bits are clear. */\r
+ add.w sr, r14 /* Combine the top 4 bits of the PC with the SR. */\r
+ push.w r14 /* Push the generated combined value onto the stack. */\r
\r
/* Now the SR is stacked we can disable interrupts. */\r
- dint \r
+ dint \r
+ nop\r
\r
/* Save the context of the current task. */\r
portSAVE_CONTEXT \r
\r
- /* Switch to the highest priority task that is ready to run. */\r
+ /* Select the next task to run. */\r
calla #vTaskSwitchContext \r
\r
/* Restore the context of the new task. */\r