Mercurial > pub > dyncall > dyncall
annotate dyncallback/dyncall_callback_arm64.S @ 651:cab0031c6691
- arm64 files:
* // to /* comments */ (b/c dyncall supports pre-c99 toolchains, in this case it's more for consistency reasons throughout dyncall, as arm64 is newer than 1999)
* removed comment with dead link
* cosmetics
- portasm readme addition
author | Tassilo Philipp |
---|---|
date | Thu, 07 Mar 2024 10:34:10 +0100 |
parents | 451299d50c1a |
children | 0079a8fa894e |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: dyncallback | |
15
03c516772c65
- consistency in filenames that have cpp logic .s -> .S
cslag
parents:
0
diff
changeset
|
5 File: dyncallback/dyncall_callback_arm64.S |
0 | 6 Description: Callback Thunk - Implementation for ARM64 / ARMv8 / AAPCS64 |
7 License: | |
8 | |
651 | 9 Copyright (c) 2015-2024 Daniel Adler <dadler@uni-goettingen.de>, |
281 | 10 Tassilo Philipp <tphilipp@potion-studios.com> |
0 | 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 */ | |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
25 |
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
26 #include "../portasm/portasm-arm64.S" |
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
27 BEGIN_ASM |
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
28 |
651 | 29 /* struct DCCallback |
30 type off size | |
31 ---------|------|------ | |
32 DCThunk | 0 | 32 | |
33 handler | 32 | 8 | |
34 userdata | 40 | 8 | |
35 */ | |
0 | 36 |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
37 TEXTAREA |
0 | 38 |
39 GLOBAL_C(dcCallbackThunkEntry) | |
40 ENTRY_C(dcCallbackThunkEntry) | |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
41 ALIGN(4) |
0 | 42 |
651 | 43 /* input: |
44 x9: DCCallback* pcb | |
45 x0..x7 ?? GP regs | |
46 d0..d7 ?? FP/SIMD regs | |
47 sp... ?? arguments on stack | |
48 | |
49 locals: | |
50 type off size | |
51 ---------|------|------ | |
52 Frame 0 16 | |
53 DCArgs 16 168 | |
54 DCValue 184 16 | |
55 | |
56 size 200 | |
57 aligned 208 | |
58 | |
0 | 59 |
651 | 60 locals: |
61 x10: sp | |
62 x11: DCArgs* args | |
63 */ | |
0 | 64 |
65 mov x10, sp | |
66 stp x29, x30, [sp, #-208 ]! | |
67 mov x29, sp | |
68 | |
69 add x11, x29 , #16 | |
70 | |
651 | 71 /* save integer registers */ |
0 | 72 |
73 stp x0, x1, [x11, #0 ] | |
74 stp x2, x3, [x11, #16] | |
75 stp x4, x5, [x11, #32] | |
76 stp x6, x7, [x11, #48] | |
77 | |
78 stp d0, d1, [x11, #64] | |
79 stp d2, d3, [x11, #80] | |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
80 stp d4, d5, [x11, #96] |
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
81 stp d6, d7, [x11, #112] |
0 | 82 |
83 eor x12, x12, x12 | |
651 | 84 stp x10,x12,[x11, #128] /* sp=sp, i=0, f=0 */ |
85 | |
86 str x12, [x11, #144] /* s=0, reserved=0 */ | |
0 | 87 |
88 | |
651 | 89 /* call handler: |
90 args: | |
91 x0: DCCallback* pcb | |
92 x1: DCArgs* args | |
93 x2: DCValue* result | |
94 x3: void* userdata | |
95 */ | |
0 | 96 |
97 mov x0 , x9 | |
98 add x1 , x29 , #16 | |
99 add x2 , x29 , #184 | |
100 ldr x3 , [x9 , #40] | |
101 | |
102 ldr x11, [x9 , #32] | |
103 blr x11 | |
104 | |
105 and w0, w0, #255 | |
106 cmp w0, 'f' | |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
107 b.eq LABELUSE(retf) |
0 | 108 cmp w0, 'd' |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
109 b.eq LABELUSE(retf) |
0 | 110 |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
111 LABELDEF(reti) |
0 | 112 ldr x0, [x29, #184] |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
113 b LABELUSE(ret) |
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
114 LABELDEF(retf) |
0 | 115 ldr d0, [x29, #184] |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
116 LABELDEF(ret) |
0 | 117 ldp x29, x30, [sp], #208 |
118 ret | |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
119 |
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
120 |
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
121 END_PROC |
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
122 END_ASM |
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
281
diff
changeset
|
123 |