diff options
Diffstat (limited to 'zap/source/amd64/sys/syscall.s')
-rw-r--r-- | zap/source/amd64/sys/syscall.s | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/zap/source/amd64/sys/syscall.s b/zap/source/amd64/sys/syscall.s new file mode 100644 index 0000000..f6a615a --- /dev/null +++ b/zap/source/amd64/sys/syscall.s @@ -0,0 +1,27 @@ +# Copyright 2022-2023 Gabriel Jensen. +# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +# If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>. + +.globl zap_syscall + +zap_syscall: + # System calls on AMD64 use the following registers: + # rax : System call identifier + # rdi : First parameter + # rsi : Second parameter + # rdx : Third parameter + # r10 : Fourth parameter + # r8 : Fifth parameter + # r9 : Sixth parameter + # eax : Return value + # No registers to save. + movq %rdi,%rax # Move the first parameter (the identifier) to rax. + movq %rsi,%rdi # Move parameters into their designated registers. + movq %rdx,%rsi + movq %rcx,%rdx + movq %r8,%r10 # System calls use r10 instead of rcx. + movq %r9,%r8 + movq 0x8(%rsp),%r9 # Extract the sixth argument from the stack. + syscall # Slime incident + # No need to move the return value. + ret |