Assembly

The NDK allows you to use C and C++ in your Android applications. Chapter 2 showed you what native code would look like after the C or C++ code is compiled and how you could use objdump –d to disassemble a file (object file or library). For example, the ARM assembly code of computeIterativelyFaster is shown again in Listing 3–1.

Listing 3–1. ARM Assembly Code of C Implementation of computeIterativelyFaster

00000410 <computeIterativelyFaster>:  410:   e3500001       cmp     r0, #1  ;  0x1  414:   e92d0030       push    {r4, r5}  418:   91a02000       movls   r2, r0  41c:   93a03000       movls   r3, #0; 0x0  420:   9a00000e       bls     460 <computeIterativelyFaster+0x50>  424:   e2400001       sub     r0, r0, #1     ; 0x1  428:   e1b010a0       lsrs    r1, r0, #1 ...

Get Pro Android Apps Performance Optimization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.