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