androidc++assemblyarmmarmalade

Writing android app parts in assembly


I am using Marmalde and C/C++ to write an game for android. Now I eant to write some important parts in assembler to improve the performance. But I am wondering me whether this app could run on the most android devices? (about 90%) Because in general assembler code depends on the processor and different android phones may have different processors, for example Intel or ARM, so I would have to write these parts in different assembler languages for every different processor!?


Solution

  • Yes, of course you will have to write the assembly code for every processor ABI.

    The Android NDK has specific support for different ABIs.

    Keep in mind that, while there are currently only three processor families supported (Intel x86/64, ARM and MIPS) you have to target all the different ABIs not the processors families themselves.

    You can drop MIPS devices safely, they are very rare.
    Intel devices are mostly tablet, but there are some phone too.
    The vast majority of devices out there is ARM.

    If you look at an official optimization guide from ARM v8 or at a very useful optimization guide for Intel you can see that it actually will take some time to write good assembly code, it's not just about making something work (which you should already be able to do easily).

    Hint
    Write first the critical parts in C++, then look at the disassembly and see if you can do better or if you can recognize some sub-optimal patterns.
    Only then rewrite the code in assembly.

    Also before doing such micro-optimizations, try to use better data structures, better algorithms and better resource handling.