aboutsummaryrefslogtreecommitdiff
path: root/src/ARMJIT_x64/ARMJIT_Linkage.S
blob: 8cc0b5f919fb6ce51c864aea4148ecb5007563de (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
.intel_syntax noprefix

#include "ARMJIT_Offsets.h"

.text

#define RCPU rbp
#define RCPSR r15d

#ifdef WIN64
#define ARG1_REG ecx
#define ARG2_REG edx
#define ARG3_REG r8d
#define ARG4_REG r9d
#define ARG1_REG64 rcx
#define ARG2_REG64 rdx
#define ARG3_REG64 r8
#define ARG4_REG64 r9
#else
#define ARG1_REG edi
#define ARG2_REG esi
#define ARG3_REG edx
#define ARG4_REG ecx
#define ARG1_REG64 rdi
#define ARG2_REG64 rsi
#define ARG3_REG64 rdx
#define ARG4_REG64 rcx
#endif

.p2align 4,,15

#ifdef __APPLE__
.global _ARM_Dispatch
_ARM_Dispatch:
#else
.global ARM_Dispatch
ARM_Dispatch:
#endif
#ifdef WIN64
    push rdi
    push rsi
#endif
    push rbx
    push r12
    push r13
    push r14
    push r15
    push rbp

#ifdef WIN64
    sub rsp, 0x28
#else
    sub rsp, 0x8
#endif
    mov RCPU, ARG1_REG64
    mov RCPSR, [RCPU + ARM_CPSR_offset]

    jmp ARG2_REG64

.p2align 4,,15

#ifdef __APPLE__
.global _ARM_Ret
_ARM_Ret:
#else
.global ARM_Ret
ARM_Ret:
#endif
    mov [RCPU + ARM_CPSR_offset], RCPSR

#ifdef WIN64
    add rsp, 0x28
#else
    add rsp, 0x8
#endif

    pop rbp
    pop r15
    pop r14
    pop r13
    pop r12
    pop rbx
#ifdef WIN64
    pop rsi
    pop rdi
#endif

    ret