comparison 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
comparison
equal deleted inserted replaced
650:4e40299cc673 651:cab0031c6691
4 Library: dyncallback 4 Library: dyncallback
5 File: dyncallback/dyncall_callback_arm64.S 5 File: dyncallback/dyncall_callback_arm64.S
6 Description: Callback Thunk - Implementation for ARM64 / ARMv8 / AAPCS64 6 Description: Callback Thunk - Implementation for ARM64 / ARMv8 / AAPCS64
7 License: 7 License:
8 8
9 Copyright (c) 2015-2020 Daniel Adler <dadler@uni-goettingen.de>, 9 Copyright (c) 2015-2024 Daniel Adler <dadler@uni-goettingen.de>,
10 Tassilo Philipp <tphilipp@potion-studios.com> 10 Tassilo Philipp <tphilipp@potion-studios.com>
11 11
12 Permission to use, copy, modify, and distribute this software for any 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 13 purpose with or without fee is hereby granted, provided that the above
14 copyright notice and this permission notice appear in all copies. 14 copyright notice and this permission notice appear in all copies.
24 */ 24 */
25 25
26 #include "../portasm/portasm-arm64.S" 26 #include "../portasm/portasm-arm64.S"
27 BEGIN_ASM 27 BEGIN_ASM
28 28
29 // struct DCCallback 29 /* struct DCCallback
30 // type off size 30 type off size
31 // ---------|------|------ 31 ---------|------|------
32 // DCThunk | 0 | 32 32 DCThunk | 0 | 32
33 // handler | 32 | 8 33 handler | 32 | 8
34 // userdata | 40 | 8 34 userdata | 40 | 8
35 */
35 36
36 TEXTAREA 37 TEXTAREA
37 38
38 GLOBAL_C(dcCallbackThunkEntry) 39 GLOBAL_C(dcCallbackThunkEntry)
39 ENTRY_C(dcCallbackThunkEntry) 40 ENTRY_C(dcCallbackThunkEntry)
40 ALIGN(4) 41 ALIGN(4)
41 42
42 // input: 43 /* input:
43 // x9: DCCallback* pcb 44 x9: DCCallback* pcb
44 // x0..x7 ?? GP regs 45 x0..x7 ?? GP regs
45 // d0..d7 ?? FP/SIMD regs 46 d0..d7 ?? FP/SIMD regs
46 // sp... ?? arguments on stack 47 sp... ?? arguments on stack
47 // 48
48 // locals: 49 locals:
49 // type off size 50 type off size
50 // ---------|------|------ 51 ---------|------|------
51 // Frame 0 16 52 Frame 0 16
52 // DCArgs 16 168 53 DCArgs 16 168
53 // DCValue 184 16 54 DCValue 184 16
54 // 55
55 // size 200 56 size 200
56 // aligned 208 57 aligned 208
57 // 58
58 59
59 // locals: 60 locals:
60 // x10: sp 61 x10: sp
61 // x11: DCArgs* args 62 x11: DCArgs* args
63 */
62 64
63 mov x10, sp 65 mov x10, sp
64 stp x29, x30, [sp, #-208 ]! 66 stp x29, x30, [sp, #-208 ]!
65 mov x29, sp 67 mov x29, sp
66 68
67 add x11, x29 , #16 69 add x11, x29 , #16
68 70
69 // save integer registers 71 /* save integer registers */
70 72
71 stp x0, x1, [x11, #0 ] 73 stp x0, x1, [x11, #0 ]
72 stp x2, x3, [x11, #16] 74 stp x2, x3, [x11, #16]
73 stp x4, x5, [x11, #32] 75 stp x4, x5, [x11, #32]
74 stp x6, x7, [x11, #48] 76 stp x6, x7, [x11, #48]
77 stp d2, d3, [x11, #80] 79 stp d2, d3, [x11, #80]
78 stp d4, d5, [x11, #96] 80 stp d4, d5, [x11, #96]
79 stp d6, d7, [x11, #112] 81 stp d6, d7, [x11, #112]
80 82
81 eor x12, x12, x12 83 eor x12, x12, x12
82 stp x10,x12,[x11, #128] // sp=sp, i=0, f=0 84 stp x10,x12,[x11, #128] /* sp=sp, i=0, f=0 */
83 85
84 str x12, [x11, #144] // s=0, reserved=0 86 str x12, [x11, #144] /* s=0, reserved=0 */
85 87
86 88
87 // call handler: 89 /* call handler:
88 // args: 90 args:
89 // x0: DCCallback* pcb 91 x0: DCCallback* pcb
90 // x1: DCArgs* args 92 x1: DCArgs* args
91 // x2: DCValue* result 93 x2: DCValue* result
92 // x3: void* userdata 94 x3: void* userdata
95 */
93 96
94 mov x0 , x9 97 mov x0 , x9
95 add x1 , x29 , #16 98 add x1 , x29 , #16
96 add x2 , x29 , #184 99 add x2 , x29 , #184
97 ldr x3 , [x9 , #40] 100 ldr x3 , [x9 , #40]