summaryrefslogtreecommitdiff
path: root/zap/source/arm/sys/syscall.s
blob: c4f8d40aa25f6e5705bfe9f2d35819de5b6b2fe6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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