How is stack pointer saved to the TCB?

I am using Renesas RX MCU. In port.c prvYieldHander(), there is this code which is supposed to save stack pointer onto TCB: MOV.L #_pxCurrentTCB, R15 MOV.L [R15], R15 MOV.L R0, [R15] Can anybody explain the purpose of line 2? My understanding is: 1. pxCurrentTCB is a global variable, which holds the start address of the TCB of current task 2. First line of code: move the content of pxCurrentTCB (which is the start address of the TCB of current task), to R15 3. Second line of code: don’t know what this is doing 4. Third line of code: Move R0 (which contains the address of top of stack) to the address pointed to by R15, ie. move R0 to first location of TCB Is there anything wrong with my understanding?

How is stack pointer saved to the TCB?

The first line loads the address of the pxCurrentTCB variable into R15. The second line loads the value of pxCurrentTCB from into R15 from its address which is already in R15. The assembly instructions are fully documented in the Renesas manuals :o)