Just for educational purposes, I would like to add a function to an existing iPhone app, written in ARM assembly. I don\'t need a tutorial on ARM assembly in general, becaus
I just started working with iOS. The first thing I tried to do was add asm code to my project and ran into the same problem. The static data is handled slightly differently in 64-bit mode. I discovered how to do it by looking at the assembler output of the compiler. The same .S file will be compiled as both 32 and 64-bit in Xcode, so prepare it like this:
.globl _myfunction
.align 2
my_constant_data:
.byte 0,1,2,3,4,5,6,7
#ifdef __arm__
.thumb_func _myfunction
.syntax unified
.code 16
//
// call from C as my myfunction()
//
_myfunction:
ldr r0,=my_constant_data
< write your thumb-2 code here >
bx lr
#else // or you can use #ifdef __arm64__
//
// Call from C as myfunction()
//
_myfunction:
adrp x0, my_constant_data@PAGE
add x0,x0, my_constant_data@PAGEOFF
< write your Armv8 code here >
ret
#endif