comparison 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
comparison
equal deleted inserted replaced
405:e221473a8217 406:351bb41d3bb1
4 Library: dyncallback 4 Library: dyncallback
5 File: dyncallback/dyncall_callback_arm32_arm_gas.S 5 File: dyncallback/dyncall_callback_arm32_arm_gas.S
6 Description: Callback Thunk - Implementation for ARM32 (ARM mode) 6 Description: Callback Thunk - Implementation for ARM32 (ARM mode)
7 License: 7 License:
8 8
9 Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, 9 Copyright (c) 2007-2021 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.
45 45
46 /* Called by thunk - thunk stores pointer to DCCallback in r12 */ 46 /* Called by thunk - thunk stores pointer to DCCallback in r12 */
47 dcCallbackThunkEntry: 47 dcCallbackThunkEntry:
48 48
49 /* Prolog. This function never needs to spill inside its prolog, so just store the permanent registers. */ 49 /* Prolog. This function never needs to spill inside its prolog, so just store the permanent registers. */
50 stmdb %r13, {%r4-%r11, %r13, %r14} /* Permanent registers and stack pointer, etc... -> save area on stack (except counter). */ 50 stmdb r13, {r4-r11, r13, r14} /* Permanent registers and stack pointer, etc... -> save area on stack (except counter). */
51 mov %r11, %r13 /* Set frame pointer. */ 51 mov r11, r13 /* Set frame pointer. */
52 sub %r13, %r13, #40 /* Adjust stack pointer. */ 52 sub r13, r13, #40 /* Adjust stack pointer. */
53 53
54 /* Grab arguments. */ 54 /* Grab arguments. */
55 mov %r4, #0 55 mov r4, #0
56 #if defined(DC__ABI_ARM_HF) 56 #if defined(DC__ABI_ARM_HF)
57 stmdb %r13!, {%r4} /* Init freg_count and dreg_count to 0 */ 57 stmdb r13!, {r4} /* Init freg_count and dreg_count to 0 */
58 stmdb %r13!, {%r4} 58 stmdb r13!, {r4}
59 fstmdbd %r13!, {d0-d7} /* Store all fp-registers in DCArgs' f[16] */ 59 fstmdbd r13!, {d0-d7} /* Store all fp-registers in DCArgs' f[16] */
60 #endif 60 #endif
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. */ 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. */
62 62
63 /* Prepare callback handler call. */ 63 /* Prepare callback handler call. */
64 mov %r0, %r12 /* Parameter 0 (r0) = DCCallback pointer (r12, pointer to thunk). */ 64 mov r0, r12 /* Parameter 0 (r0) = DCCallback pointer (r12, pointer to thunk). */
65 mov %r1, %r13 /* Parameter 1 (r1) = DCArgs pointer (r13, stack pointer). */ 65 mov r1, r13 /* Parameter 1 (r1) = DCArgs pointer (r13, stack pointer). */
66 sub %r13, %r13, #DCValue_size /* Make room for return value. */ 66 sub r13, r13, #DCValue_size /* Make room for return value. */
67 mov %r2, %r13 /* Parameter 2 (r2) = results pointer. */ 67 mov r2, r13 /* Parameter 2 (r2) = results pointer. */
68 ldr %r3, [%r12, #CTX_userdata] /* Parameter 3 (r3) = userdata pointer. */ 68 ldr r3, [r12, #CTX_userdata] /* Parameter 3 (r3) = userdata pointer. */
69 69
70 /* Call. */ 70 /* Call. */
71 ldr %r4, [%r12, #CTX_handler] /* Load callback handler pointer into r4. */ 71 ldr r4, [r12, #CTX_handler] /* Load callback handler pointer into r4. */
72 mov %r14, %r15 /* Branch return address(r15) -> link register (r14) -- r15 always points to address of current + 2 instructions (= Epilog code). */ 72 mov r14, r15 /* Branch return address(r15) -> link register (r14) -- r15 always points to address of current + 2 instructions (= Epilog code). */
73 bx %r4 /* Call. */ 73 bx r4 /* Call. */
74 74
75 /* Return value. */ 75 /* Return value. */
76 ldmia %r13, {%r0, %r1} /* Load return value in r0 and r1. */ 76 ldmia r13, {r0, r1} /* Load return value in r0 and r1. */
77 #if defined(DC__ABI_ARM_HF) 77 #if defined(DC__ABI_ARM_HF)
78 fldmiad %r13, {%d0} /* Same for floating point return value (if any). */ 78 fldmiad r13, {d0} /* Same for floating point return value (if any). */
79 #endif 79 #endif
80 80
81 /* Epilog. */ 81 /* Epilog. */
82 ldmdb %r11, {%r4-%r11, %r13, %r15} /* Restore permanent registers (restore stack ptr and program counter).@@@db not needed since we rewrite r13? */ 82 ldmdb r11, {r4-r11, r13, r15} /* Restore permanent registers (restore stack ptr and program counter).@@@db not needed since we rewrite r13? */
83 83