diff options
Diffstat (limited to 'tco.asm')
| -rw-r--r-- | tco.asm | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -15,15 +15,20 @@ format ELF64 -public tco_go -public tco_args -public tco_yield - ; assembly-time configuration options include 'config.inc' assert (STACK_CAPACITY mod 16) = 0 assert MALLOC in <posix_memalign,aligned_alloc,mmap> +macro fn lbl { + label lbl + public lbl + + if IBT_ENABLE + endbr64 + end if +} + ; circular singly-linked list containing callee-saved registers and instruction ; pointer to resume execution of coroutine when yielded to struc ctx_node next { @@ -60,7 +65,7 @@ end if section '.text' executable ; int tco_go(void (*f)(...)) ; spawns a coroutine -tco_go: +fn tco_go call stash ; pushing rdi also aligns stack to 16 byte boundary for function call @@ -154,7 +159,7 @@ end if ; void tco_args(...) ; sets the arguments of the next coroutine -tco_args: +fn tco_args irps reg, rax rdi rsi rdx r10 r8 r9 { mov [coroutine_args.#reg], reg } @@ -170,7 +175,7 @@ tco_args: ; void tco_yield(void) ; yield to next coroutine -tco_yield: +fn tco_yield call stash xor eax, eax jmp switch |
