0

I am trying to use assembly code in Android app. I found an example code online.

Download Link

This question may related to another question on Stackoverflow.Question Link

The code seems clear and easy to run. But after I do

$ ndk-build

in the root directory of the program.

Error Message is as the following:

[arm64-v8a] Compile        : hello-jni <= multiple.s
jni/multiple.s:6:2: error: unexpected token at start of statement
    @ Multiply by 10, input value and return value in r0
    ^
jni/multiple.s:7:10: error: unexpected token in argument list
    stmfd   sp!, {fp,ip,lr}
              ^
jni/multiple.s:8:6: error: invalid operand for instruction
    mov     r3, r0, asl #3
            ^
jni/multiple.s:9:6: error: invalid operand for instruction
    add     r0, r3, r0, asl #1
            ^
jni/multiple.s:10:10: error: unexpected token in argument list
    ldmfd   sp!, {fp,ip,lr}
              ^
jni/multiple.s:11:2: error: unrecognized instruction mnemonic
    bx      lr
    ^
make: *** [obj/local/arm64-v8a/objs/hello-jni/multiple.o] Error 1

Thanks for your help ! Do not know how to do now:)

Boooooooooms
  • 306
  • 4
  • 21
  • The code you're trying to assemble looks like 32-bit ARM code to me. – Michael Apr 27 '18 at 10:23
  • @Michael But the ARM64-v8a can use both 32-bit ARM code and 64-bit ARM code, can't it? – Boooooooooms Apr 28 '18 at 09:25
  • The _processor_ can run 32-bit code. But you're telling the assembler that you want to assemble for arm64-v8a, while providing 32-bit assembly. The best thing would probably be to either A) rewrite the assembly code to be proper arm64-v8a assembly, or B) build for armeabi-v7a instead. Note that you will have to go with option A eventually if you plan on releasing this on Google Play, since apps with native libraries will be required to have 64-bit versions of those libraries starting from sometime in 2019. – Michael Apr 28 '18 at 09:35
  • @Michael Thanks for pointing out the problem. Actually I know nothing about ARM assembly. I just copy the example code online and try to run them. Now I am going to learn the assembly code. Thanks again! – Boooooooooms Apr 28 '18 at 11:40

0 Answers0