@@ -133,6 +133,7 @@ namespace klib::rtos::cortex_m3 {
133133 rtos::detail::base_task** current_task,
134134 rtos::detail::base_task** next_task
135135 ) {
136+ // r0 contains current_task, r1 contains next_task
136137 __asm__ volatile (
137138 // save context of current and next task is not a nullptr
138139 " ldr r2, [r0]\n "
@@ -146,7 +147,7 @@ namespace klib::rtos::cortex_m3 {
146147
147148 // store the stack pointer with the offset in %0
148149 " ldr r3, [r0]\n "
149- " str r2, [r3, %0 ]\n "
150+ " str r2, [r3, %[offset] ]\n "
150151
151152 " switch_task_next_task:\n "
152153
@@ -155,7 +156,7 @@ namespace klib::rtos::cortex_m3 {
155156 " str r3, [r0]\n "
156157
157158 // get the stack pointer of the next task
158- " ldr r2, [r3, %0 ]\n "
159+ " ldr r2, [r3, %[offset] ]\n "
159160
160161 // pop the registers from the stack that are not saved by hardware
161162 " ldmia r2!, {r4-r11}\n "
@@ -164,8 +165,8 @@ namespace klib::rtos::cortex_m3 {
164165 // return
165166 " bx lr\n "
166167 :
167- : " I" (offsetof (rtos::detail::base_task, stack_pointer))
168- : " r2" , " r3" , " r4" , " r5" , " r6" , " r7" , " r8" , " r9" , " r10" , " r11" , " memory"
168+ : [current] " r " (current_task), [next] " r " (next_task), [offset] " I" (offsetof (rtos::detail::base_task, stack_pointer))
169+ : " r2" , " r3" , " r4" , " r5" , " r6" , " r7" , " r8" , " r9" , " r10" , " r11" , " memory" , " cc "
169170 );
170171 }
171172
0 commit comments