What we are going to do next isn't as obvious as it seems but isn't so difficult either. First of all we need to add an assembly file to our project. On the internet you can find much about this and most sites mention a JNI folder to put the assembly source files in it. Tis is not of my concern I just put the assembly source file in the cpp folder, the one where native-lib.cpp resides. Later, when you have some 'routine' you can decide to put assembly sources somewhere else, as long as Android Studio knows where to find them it should be all right.
Arrange your project so that you can see your android project like on the figure displayed below.
Right click on cpp and select New - File and give it a name, let's say test-nasm.asm (don't forget .asm). The file should be visible in Android Studio and when NASM support is recognized you will see a blue tag indicating that you're dealing with an assembly file. When you should have forgotten to install the yasm plugin, Android Studio will propose to install the plugin for you. Do so and don't forget to replace yasm with nasm (see: Installing NASM plugin).
What we are going to do next is to replace our C++ example, the one that shows "Hello from C++" by an assembler program that will make us able to show "Hello from NASM" but before starting to code, let's do the administration first.
add enable_language(ASM_NASM) right after line 6 (the one that has cmake_minimum_required(VERSION 3.4.1)
each.asm and .cpp file you add to your project must be added here to inform android studio that these files are included in your project.
add src/main/cpp/test-nasm.asm right after line 21 (the one with src/main/cpp/native-lib.cpp)
The CmakeList.txt file should look similar to the one showed in the image below.
Android Studio propose to sync the project but wait for it because we still need to do some administration.
Next you need to find in the folder Gradle Scripts : build.gradle (module:app) (note: NOT build.gradle (module:TestNasm) )
If you intent to build 32 bit applications then change x86_64 into x86 for both productFlavors as abiFilter. If you should target two types of processors (32 and 64 bit) then add the 32 bit flavor.
You can even add ARM and MIPS support but then you need to figure out how to make Android Studio know when to assemble and link which file(s).
Now you can sync your project. Just click sync now.
In the next article we're gonna put some code in our assembler file and modify the C++ source file