PIC port explanation

I have moved this message from the bug tracker list.  Please do not submit bug trackers until it has been shown that a bug exists.  Original message follows: I’m not very much into pic-assembler (yet), but I believe there is an error in the pic-port. From port.c: <snippet from PortSAVECONTEXT macro> /* Save the new top of the software stack in the TCB. */ _asm MOVFF pxCurrentTCB, FSR0L MOVFF pxCurrentTCB + 1, FSR0H MOVFF FSR1L, POSTINC0 MOVFF FSR1H, POSTINC0 _endasm } </snippet from PortSAVECONTEXT macro> <snippet from PortRESTORECONTEXT macro> /* Set FSR0 to point to pxCurrentTCB- >pxTopOfStack. */ MOVFF pxCurrentTCB, FSR0L MOVFF pxCurrentTCB + 1, FSR0H </snippet from PortRESTORECONTEXT macro> I cannot believe that the code in the PortSAVECONTEXT- macro saves something in the TCB…

PIC port explanation

Here is the save context snippet with an explanation: ; Obtain the low byte of the pointer to the current ; TCB and place it in the low byte of the FSR0 ; register. MOVFF pxCurrentTCB, FSR0L ; Obtain the high byte of the pointer to the current ; TCB and place it in the high byte of the FSR0 ; register. MOVFF pxCurrentTCB + 1, FSR0H ; The FSR1 register is being used as the stack ; pointer.  FSR0 now points to the current TCB ; structure – the first member of which is the top ; of stack.  Store the top of stack being used into ; the TCB top of stack member. ; Move the low byte of the stack pointer into the ; TCB, then increment the pointer to the high ; byte. MOVFF FSR1L, POSTINC0 ; Move the high byte of the stack pointer into the ; TCB.  The FSR0 register is pointing to the high ; byte already due to the post increment in ; the statement above. MOVFF FSR1H, POSTINC0

PIC port explanation

Thanks, it starts making sense now I’m getting more and more into pic asm…