comparison dyncallback/dyncall_callback_arm64.s @ 0:3e629dc19168

initial from svn dyncall-1745
author Daniel Adler
date Thu, 19 Mar 2015 22:24:28 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:3e629dc19168
1 /*
2
3 Package: dyncall
4 Library: dyncallback
5 File: dyncallback/dyncall_callback_arm64.s
6 Description: Callback Thunk - Implementation for ARM64 / ARMv8 / AAPCS64
7 License:
8
9 Copyright (c) 2015 Daniel Adler <dadler@uni-goettingen.de>,
10 Tassilo Philipp <tphilipp@potion-studios.com>
11
12 Permission to use, copy, modify, and distribute this software for any
13 purpose with or without fee is hereby granted, provided that the above
14 copyright notice and this permission notice appear in all copies.
15
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23
24 */
25 // struct DCCallback
26 // type off size
27 // ---------|------|------
28 // DCThunk | 0 | 32
29 // handler | 32 | 8
30 // userdata | 40 | 8
31
32 #include "../portasm/portasm-arm.S"
33
34 .align 4
35 GLOBAL_C(dcCallbackThunkEntry)
36 ENTRY_C(dcCallbackThunkEntry)
37
38 // input:
39 // x9: DCCallback* pcb
40 // x0..x7 ?? GP regs
41 // d0..d7 ?? FP/SIMD regs
42 // sp... ?? arguments on stack
43 //
44 // locals:
45 // type off size
46 // ---------|------|------
47 // Frame 0 16
48 // DCArgs 16 168
49 // DCValue 184 16
50 //
51 // size 200
52 // aligned 208
53 //
54
55 // locals:
56 // x10: sp
57 // x11: DCArgs* args
58
59 mov x10, sp
60 stp x29, x30, [sp, #-208 ]!
61 mov x29, sp
62
63 add x11, x29 , #16
64
65 // save integer registers
66
67 stp x0, x1, [x11, #0 ]
68 stp x2, x3, [x11, #16]
69 stp x4, x5, [x11, #32]
70 stp x6, x7, [x11, #48]
71
72 stp d0, d1, [x11, #64]
73 stp d2, d3, [x11, #80]
74 stp d4, d5, [x11, #96]
75 stp d6, d7, [x11, #112]
76
77 eor x12, x12, x12
78 stp x10,x12,[x11, #128] // sp=sp, i=0, f=0
79
80 str x12, [x11, #144] // s=0, reserved=0
81
82
83 // call handler:
84 // args:
85 // x0: DCCallback* pcb
86 // x1: DCArgs* args
87 // x2: DCValue* result
88 // x3: void* userdata
89
90 mov x0 , x9
91 add x1 , x29 , #16
92 add x2 , x29 , #184
93 ldr x3 , [x9 , #40]
94
95 ldr x11, [x9 , #32]
96 blr x11
97
98 and w0, w0, #255
99 cmp w0, 'f'
100 b.eq .retf
101 cmp w0, 'd'
102 b.eq .retf
103
104 .reti:
105 ldr x0, [x29, #184]
106 b .ret
107 .retf:
108 ldr d0, [x29, #184]
109 .ret:
110 ldp x29, x30, [sp], #208
111 ret