diff options
author | johannst <johannes.stoelp@gmail.com> | 2021-02-26 23:19:03 +0100 |
---|---|---|
committer | johannst <johannes.stoelp@gmail.com> | 2021-02-26 23:19:03 +0100 |
commit | 0d881bc974b74dff75c00a3cab5d535cbb2ace46 (patch) | |
tree | 35c5892c135d5623879b106e93df4cc235669a8d /lib/arch/arm/yield.s | |
parent | 5fbee6be76c8751c282b45c54b8179ae525e00c1 (diff) | |
download | matcha-threads-0d881bc974b74dff75c00a3cab5d535cbb2ace46.tar.gz matcha-threads-0d881bc974b74dff75c00a3cab5d535cbb2ace46.zip |
added implementation for armv7a
Diffstat (limited to 'lib/arch/arm/yield.s')
-rw-r--r-- | lib/arch/arm/yield.s | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/arch/arm/yield.s b/lib/arch/arm/yield.s new file mode 100644 index 0000000..de9d604 --- /dev/null +++ b/lib/arch/arm/yield.s @@ -0,0 +1,32 @@ +# Copyright (c) 2021 Johannes Stoelp + + .arch armv7-a + .section .text, "ax", %progbits + + # extern "C" void yield(const void* new_stack, void** old_stack); + # ^^^^^^^^^ ^^^^^^^^^ + # x0 x1 + .global yield + .type yield, %function +yield: + .cfi_startproc + // prologue + push {fp, lr} + mov fp, sp + + // push callee saved registers + push {r4-r11} + + // arg0: r0 holds new stack + // arg1: r1 holds addr to location current stack must be saved + mov r2, sp + str r2, [r1] // save current stack ptr + mov sp, r0 // switch to new stack ptr + + // pop callee saved registers + pop {r4-r11} + + // epilogue + pop {fp, pc} + .cfi_endproc + .size yield, .-yield |