summaryrefslogblamecommitdiff
path: root/zap/source/amd64/sys/syscall.s
blob: f6a615adef2c5f7997d53618d22561105b82be93 (plain) (tree)


























                                                                                                               
# 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