diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-09-18 11:18:02 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-09-18 11:18:02 -0600 |
commit | 4469398272d78adb81968178276180f16cc8e647 (patch) | |
tree | c360226922c543a5d2fd985ca1e078bb8a603f72 /coroutine.c | |
parent | 05ce08877ff420ca9fc77599dd947ff610d02cb0 (diff) |
fixes for arm?
Diffstat (limited to 'coroutine.c')
-rw-r--r-- | coroutine.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/coroutine.c b/coroutine.c index 6219883..34d84c8 100644 --- a/coroutine.c +++ b/coroutine.c @@ -52,15 +52,24 @@ static void call_with_stack(void *stack, cr_fn_t fn, void *args) { /* %1 */"r"(stack), /* %2 */"r"(fn), /* %3 */"r"(args) - : + : "rdi" ); #elif __arm__ #define STACK_GROWS_DOWNWARD 1 - asm volatile ("mov r0, coroutine_table[_cur_cid].arg" - "mov _saved_stack sp" - "mov sp, coroutine_table[_cur_cid].stack" - "bl coroutine_table[_cur_cid].fn" - "mov _saved_stack sp"); + asm volatile ("mov r0, sp\n\t" /* [saved_sp = sp */ + "str r0, %0\n\t" /* ] */ + "mov sp, %1\n\t" /* [sp = stack] */ + "mov r0, %1\n\t" /* [fn(arg0) */ + "blx %2\n\t" /* ] */ + "ldr r0, %0\n\t" /* [sp = staved_sp */ + "mov sp, r0" /* ] */ + : + : /* %0 */"m"(saved_sp), + /* %1 */"r"(stack), + /* %2 */"r"(fn), + /* %3 */"r"(args) + : "r0" + ); #else #error unsupported architecture #endif |