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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 /*
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
2
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
3 Package: dyncall
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 Description: Callback Thunk - Implementation for ARM64 / ARMv8 / AAPCS64
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
7 License:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
8
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
9 Copyright (c) 2015-2024 Daniel Adler <dadler@uni-goettingen.de>,
281
f5577f6bf97a - file header cleanups for release
Tassilo Philipp
parents: 15
diff changeset
10 Tassilo Philipp <tphilipp@potion-studios.com>
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12 Permission to use, copy, modify, and distribute this software for any
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13 purpose with or without fee is hereby granted, provided that the above
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14 copyright notice and this permission notice appear in all copies.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
23
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
29 /* struct DCCallback
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
30 type off size
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
31 ---------|------|------
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
32 DCThunk | 0 | 32
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
33 handler | 32 | 8
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
34 userdata | 40 | 8
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
35 */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
38
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
39 GLOBAL_C(dcCallbackThunkEntry)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
42
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
43 /* input:
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
44 x9: DCCallback* pcb
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
45 x0..x7 ?? GP regs
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
46 d0..d7 ?? FP/SIMD regs
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
47 sp... ?? arguments on stack
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
48
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
49 locals:
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
50 type off size
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
51 ---------|------|------
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
52 Frame 0 16
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
53 DCArgs 16 168
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
54 DCValue 184 16
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
55
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
56 size 200
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
57 aligned 208
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
58
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
59
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
60 locals:
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
61 x10: sp
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
62 x11: DCArgs* args
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
63 */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
64
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
65 mov x10, sp
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
66 stp x29, x30, [sp, #-208 ]!
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
67 mov x29, sp
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
68
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
69 add x11, x29 , #16
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
70
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
71 /* save integer registers */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
72
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
73 stp x0, x1, [x11, #0 ]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
74 stp x2, x3, [x11, #16]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
75 stp x4, x5, [x11, #32]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
76 stp x6, x7, [x11, #48]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
77
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
78 stp d0, d1, [x11, #64]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
82
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
83 eor x12, x12, x12
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
84 stp x10,x12,[x11, #128] /* sp=sp, i=0, f=0 */
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
85
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
86 str x12, [x11, #144] /* s=0, reserved=0 */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
87
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
88
651
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
89 /* call handler:
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
90 args:
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
91 x0: DCCallback* pcb
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
92 x1: DCArgs* args
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
93 x2: DCValue* result
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
94 x3: void* userdata
cab0031c6691 - arm64 files:
Tassilo Philipp
parents: 371
diff changeset
95 */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
96
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
97 mov x0 , x9
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
98 add x1 , x29 , #16
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
99 add x2 , x29 , #184
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
100 ldr x3 , [x9 , #40]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
101
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
102 ldr x11, [x9 , #32]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
103 blr x11
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
104
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
105 and w0, w0, #255
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
117 ldp x29, x30, [sp], #208
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
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