annotate dyncallback/dyncall_callback_arm32_arm_gas.S @ 406:351bb41d3bb1

- removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
author Tassilo Philipp
date Sun, 03 Oct 2021 10:34:56 +0200
parents f5577f6bf97a
children 7364f285cac8
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
38
fb416abb2059 - armhf callback support (not all working, yet)
cslag
parents: 0
diff changeset
5 File: dyncallback/dyncall_callback_arm32_arm_gas.S
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 Description: Callback Thunk - Implementation for ARM32 (ARM mode)
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
406
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
9 Copyright (c) 2007-2021 Daniel Adler <dadler@uni-goettingen.de>,
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10 Tassilo Philipp <tphilipp@potion-studios.com>
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 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
25
38
fb416abb2059 - armhf callback support (not all working, yet)
cslag
parents: 0
diff changeset
26 #include "../dyncall/dyncall_macros.h"
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
27
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
28 .text
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
29 .code 32 /* ARM mode */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
30
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
31 .globl dcCallbackThunkEntry
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
32
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
33 /* sizes */
249
91db39538e78 - replaced `.set' directives used to set symbol values in assembly files with (seemingly) more portable `=' syntax (e.g. older versions of Sun's `as' don't handle `.set')
Tassilo Philipp
parents: 50
diff changeset
34 /* DCThunk_size = 8 */
91db39538e78 - replaced `.set' directives used to set symbol values in assembly files with (seemingly) more portable `=' syntax (e.g. older versions of Sun's `as' don't handle `.set')
Tassilo Philipp
parents: 50
diff changeset
35 /* DCArgs_size = 24 */ /* for EABI/ATPCS/... */
91db39538e78 - replaced `.set' directives used to set symbol values in assembly files with (seemingly) more portable `=' syntax (e.g. older versions of Sun's `as' don't handle `.set')
Tassilo Philipp
parents: 50
diff changeset
36 /* DCArgs_size = 96 */ /* for armhf */
91db39538e78 - replaced `.set' directives used to set symbol values in assembly files with (seemingly) more portable `=' syntax (e.g. older versions of Sun's `as' don't handle `.set')
Tassilo Philipp
parents: 50
diff changeset
37 /* DCCallback_size = 20 */
91db39538e78 - replaced `.set' directives used to set symbol values in assembly files with (seemingly) more portable `=' syntax (e.g. older versions of Sun's `as' don't handle `.set')
Tassilo Philipp
parents: 50
diff changeset
38 DCValue_size = 8
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
39
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
40 /* struct DCCallback offsets and size */
249
91db39538e78 - replaced `.set' directives used to set symbol values in assembly files with (seemingly) more portable `=' syntax (e.g. older versions of Sun's `as' don't handle `.set')
Tassilo Philipp
parents: 50
diff changeset
41 /* CTX_thunk = 0 */
91db39538e78 - replaced `.set' directives used to set symbol values in assembly files with (seemingly) more portable `=' syntax (e.g. older versions of Sun's `as' don't handle `.set')
Tassilo Philipp
parents: 50
diff changeset
42 CTX_handler = 12
91db39538e78 - replaced `.set' directives used to set symbol values in assembly files with (seemingly) more portable `=' syntax (e.g. older versions of Sun's `as' don't handle `.set')
Tassilo Philipp
parents: 50
diff changeset
43 CTX_userdata = 16
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
44
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
45
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
46 /* Called by thunk - thunk stores pointer to DCCallback in r12 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
47 dcCallbackThunkEntry:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
48
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
49 /* Prolog. This function never needs to spill inside its prolog, so just store the permanent registers. */
406
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
50 stmdb r13, {r4-r11, r13, r14} /* Permanent registers and stack pointer, etc... -> save area on stack (except counter). */
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
51 mov r11, r13 /* Set frame pointer. */
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
52 sub r13, r13, #40 /* Adjust stack pointer. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
53
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
54 /* Grab arguments. */
406
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
55 mov r4, #0
38
fb416abb2059 - armhf callback support (not all working, yet)
cslag
parents: 0
diff changeset
56 #if defined(DC__ABI_ARM_HF)
406
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
57 stmdb r13!, {r4} /* Init freg_count and dreg_count to 0 */
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
58 stmdb r13!, {r4}
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
59 fstmdbd r13!, {d0-d7} /* Store all fp-registers in DCArgs' f[16] */
38
fb416abb2059 - armhf callback support (not all working, yet)
cslag
parents: 0
diff changeset
60 #endif
406
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
61 stmdb r13!, {r0-r4, r11} /* Spill first 4 args to DCArgs, along with reg_count (init to 0) and (stack) pointer to remaining args. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
62
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
63 /* Prepare callback handler call. */
406
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
64 mov r0, r12 /* Parameter 0 (r0) = DCCallback pointer (r12, pointer to thunk). */
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
65 mov r1, r13 /* Parameter 1 (r1) = DCArgs pointer (r13, stack pointer). */
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
66 sub r13, r13, #DCValue_size /* Make room for return value. */
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
67 mov r2, r13 /* Parameter 2 (r2) = results pointer. */
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
68 ldr r3, [r12, #CTX_userdata] /* Parameter 3 (r3) = userdata pointer. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
69
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
70 /* Call. */
406
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
71 ldr r4, [r12, #CTX_handler] /* Load callback handler pointer into r4. */
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
72 mov r14, r15 /* Branch return address(r15) -> link register (r14) -- r15 always points to address of current + 2 instructions (= Epilog code). */
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
73 bx r4 /* Call. */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
74
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
75 /* Return value. */
406
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
76 ldmia r13, {r0, r1} /* Load return value in r0 and r1. */
42
ecc9403e214a - final touch for complete armhf callback support, yay
cslag
parents: 38
diff changeset
77 #if defined(DC__ABI_ARM_HF)
406
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
78 fldmiad r13, {d0} /* Same for floating point return value (if any). */
42
ecc9403e214a - final touch for complete armhf callback support, yay
cslag
parents: 38
diff changeset
79 #endif
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
80
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
81 /* Epilog. */
406
351bb41d3bb1 - removed %-prefixes for register names from arm assembly files (was wrong to begin with, gas accepted them but the clang integrated assembler does not)
Tassilo Philipp
parents: 281
diff changeset
82 ldmdb r11, {r4-r11, r13, r15} /* Restore permanent registers (restore stack ptr and program counter).@@@db not needed since we rewrite r13? */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
83