diff dyncall/dyncall_call_arm32_thumb_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 00dd15cc5c87
children
line wrap: on
line diff
--- a/dyncall/dyncall_call_arm32_thumb_gas.s	Wed Apr 07 18:51:38 2021 +0200
+++ b/dyncall/dyncall_call_arm32_thumb_gas.s	Sun Oct 03 10:34:56 2021 +0200
@@ -6,7 +6,7 @@
  Description: ARM Thumb call kernel implementation for GNU assembler.
  License:
 
-   Copyright (c) 2007-2011 Daniel Adler <dadler@uni-goettingen.de>, 
+   Copyright (c) 2007-2021 Daniel Adler <dadler@uni-goettingen.de>, 
                            Tassilo Philipp <tphilipp@potion-studios.com>
 
    Permission to use, copy, modify, and distribute this software for any
@@ -37,45 +37,45 @@
 
 	/* Prolog. This function never needs to spill inside its prolog, so just store the permanent registers. */
 	/* Code below is not using high registers, so not storing them in prolog, which is more involved with thumb, anyways. */
-	push	{%r4-%r7, %r14}		/* Frame ptr, permanent registers, link register -> save area on stack. */
-	mov		%r7, %r13	/* Set frame ptr. */
-	sub		%r13, #4	/* Realign stack to 8 bytes (b/c we stored 5 regs = 20b). */
+	push	{r4-r7, r14}	/* Frame ptr, permanent registers, link register -> save area on stack. */
+	mov		r7, r13		/* Set frame ptr. */
+	sub		r13, #4		/* Realign stack to 8 bytes (b/c we stored 5 regs = 20b). */
 
 	/* Call. */
-	mov		%r4, %r0	/* Move 'fptr' to r4 (1st argument is passed in r0). */
-	mov		%r5, %r1	/* Move 'args' to r5 (2nd argument is passed in r1). */
-	mov		%r6, %r2	/* Move 'size' to r6 (3rd argument is passed in r2). */
+	mov		r4, r0		/* Move 'fptr' to r4 (1st argument is passed in r0). */
+	mov		r5, r1		/* Move 'args' to r5 (2nd argument is passed in r1). */
+	mov		r6, r2		/* Move 'size' to r6 (3rd argument is passed in r2). */
 
-	cmp		%r6, #16	/* Jump to call if no more than 4 arguments. */
+	cmp		r6, #16		/* Jump to call if no more than 4 arguments. */
 	ble		call
 
-	sub		%r6, #16	/* Size of remaining arguments. */
-	mov		%r0, %r13	/* Set stack pointer to top of stack. */
-	sub		%r0, %r0, %r6
-	lsr		%r0, #3		/* Align stack on 8 byte boundaries. */
-	lsl		%r0, #3
-	mov		%r13, %r0
+	sub		r6, #16		/* Size of remaining arguments. */
+	mov		r0, r13		/* Set stack pointer to top of stack. */
+	sub		r0, r0, r6
+	lsr		r0, #3		/* Align stack on 8 byte boundaries. */
+	lsl		r0, #3
+	mov		r13, r0
 
-	add		%r1, #16	/* Let r1 point to remaining arguments. */
-	mov		%r2, #0		/* Init byte counter to 0. */
+	add		r1, #16		/* Let r1 point to remaining arguments. */
+	mov		r2, #0		/* Init byte counter to 0. */
 .thumb_func
 pushArgs:
-	ldrb	%r3, [%r1, %r2]		/* Load a byte into r3. */
-	strb	%r3, [%r0, %r2]		/* Push byte onto stack. */
-	add		%r2, %r2, #1	/* Increment byte counter. */
-	cmp		%r2, %r6
+	ldrb	r3, [r1, r2]	/* Load a byte into r3. */
+	strb	r3, [r0, r2]	/* Push byte onto stack. */
+	add		r2, r2, #1		/* Increment byte counter. */
+	cmp		r2, r6
 	bne		pushArgs
 .thumb_func
 call:
-	ldmia	%r5!, {%r0-%r3}		/* Load first 4 arguments for new call into r0-r3. */
-					
-					/* 'blx %r4' workaround for ARMv4t in THUMB: */
-	mov		%r6,  %r15	/* Load PC+2 instructions from here */
-	add		%r6,  #5	/* Increment by 2 instructions (Address of 'Epilog') and set bit 0 (THUMB) */
-	mov		%r14, %r6	/* Store in link register. */
-	bx		%r4		/* Branch and force THUMB-mode return (LR bit 0 set). */
+	ldmia	r5!, {r0-r3}	/* Load first 4 arguments for new call into r0-r3. */
+
+						/* 'blx r4' workaround for ARMv4t in THUMB: */
+	mov		r6,  r15	/* Load PC+2 instructions from here */
+	add		r6,  #5		/* Increment by 2 instructions (Address of 'Epilog') and set bit 0 (THUMB) */
+	mov		r14, r6		/* Store in link register. */
+	bx		r4			/* Branch and force THUMB-mode return (LR bit 0 set). */
 
 	/* Epilog. */
-	mov		%r13, %r7	/* Reset stack ptr. */
-	pop		{%r4-%r7, %r15}	/* Restore permanent registers and program counter. (Force a stay in THUMB in ARMv4, whether ARMv5 can return in ARM or THUMB depending on the bit 0. */
+	mov		r13, r7			/* Reset stack ptr. */
+	pop		{r4-r7, r15}	/* Restore permanent registers and program counter. (Force a stay in THUMB in ARMv4, whether ARMv5 can return in ARM or THUMB depending on the bit 0. */