2018-11-20 04:59:10 -05:00
|
|
|
##
|
2018-11-20 05:16:29 -05:00
|
|
|
## This file is part of the "Coroutine" project and released under the MIT License.
|
2018-11-20 04:59:10 -05:00
|
|
|
##
|
|
|
|
## Created by Samuel Williams on 10/5/2018.
|
2019-12-27 18:41:47 -05:00
|
|
|
## Copyright, 2018, by Samuel Williams.
|
2018-11-20 04:59:10 -05:00
|
|
|
##
|
|
|
|
|
2020-07-05 04:27:12 -04:00
|
|
|
#define TOKEN_PASTE(x,y) x##y
|
|
|
|
#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
|
|
|
|
|
2020-03-31 21:15:20 -04:00
|
|
|
.file "Context.S"
|
2018-11-20 04:59:10 -05:00
|
|
|
.text
|
2020-07-05 04:27:12 -04:00
|
|
|
.globl PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
|
2020-03-31 21:15:20 -04:00
|
|
|
.align 2
|
2020-07-05 04:27:12 -04:00
|
|
|
.type PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer),%function
|
2020-03-31 21:15:20 -04:00
|
|
|
.syntax unified
|
|
|
|
|
2020-07-05 04:27:12 -04:00
|
|
|
PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
|
2019-06-26 06:02:19 -04:00
|
|
|
# Save caller state (8 registers + return address)
|
|
|
|
push {r4-r11,lr}
|
2020-07-05 04:12:20 -04:00
|
|
|
|
2019-06-26 06:02:19 -04:00
|
|
|
# Save caller stack pointer
|
|
|
|
str sp, [r0]
|
2020-07-05 04:12:20 -04:00
|
|
|
|
2019-06-26 06:02:19 -04:00
|
|
|
# Restore callee stack pointer
|
|
|
|
ldr sp, [r1]
|
2020-07-05 04:12:20 -04:00
|
|
|
|
2019-06-26 06:02:19 -04:00
|
|
|
# Restore callee state (8 registers program counter)
|
|
|
|
pop {r4-r11,pc}
|
2020-12-08 03:21:28 -05:00
|
|
|
|
|
|
|
#if defined(__linux__) && defined(__ELF__)
|
|
|
|
.section .note.GNU-stack,"",%progbits
|
|
|
|
#endif
|