Integrating assembly code in JNI
Android NDK allows you to write assembly code at JNI programming. Assembly code is sometimes used to optimize the critical portion of code to achieve the best performance. This recipe does not intend to discuss how to program in assembly. It describes how to integrate assembly code in JNI programming instead.
Getting ready
Read the Passing parameters and receiving returns in primitive types recipe before you continue.
How to do it…
The following steps create a sample Android project that integrates the assembly code:
Create a project named
AssemblyInJNI
. Set the package name ascookbook.chapter2
. Create an activity namedAssemblyInJNIActivity
. Under the project, create a folder namedjni
. Refer to the Loading native libraries and registering native methods recipe of this chapter for more detailed instructions.Create a file named
assemblyinjni.c
under thejni
folder, then implement theInlineAssemblyAddDemo
method.Create a file named
tmp.c
under thejni
folder...