summaryrefslogtreecommitdiff
path: root/zap/source/arm/sys
diff options
context:
space:
mode:
Diffstat (limited to 'zap/source/arm/sys')
-rw-r--r--zap/source/arm/sys/syscall.s32
1 files changed, 32 insertions, 0 deletions
diff --git a/zap/source/arm/sys/syscall.s b/zap/source/arm/sys/syscall.s
new file mode 100644
index 0000000..c4f8d40
--- /dev/null
+++ b/zap/source/arm/sys/syscall.s
@@ -0,0 +1,32 @@
+@ 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>.
+
+.syntax unified
+
+.arm
+
+.globl zap_syscall
+
+zap_syscall:
+ @ System calls on ARM EABI use the following registers:
+ @ r0 : System call identifier
+ @ r1 : First parameter
+ @ r2 : Second parameter
+ @ r3 : Third parameter
+ @ r4 : Fourth parameter
+ @ r5 : Fifth parameter
+ @ r6 : Sixth parameter
+ @ r0 : Return value
+ push {r4-r5,r7,lr} @ Remember that the parameters are now further up the stack.
+ mov r7,r0 @ Move the identifier.
+ mov r0,r1 @ Place parameters.
+ mov r1,r2
+ mov r2,r3
+ ldr r3,[sp,0x10] @ Get the remaining parameters from the stack.
+ ldr r4,[sp,0x14]
+ ldr r5,[sp,0x18]
+ svc 0x0 @ Divinity
+ pop {r4-r5,r7} @ Restore the registers.
+ pop {r0}
+ bx r0