Running Assembly Code on Android

Android phones use mostly ARM architecture, so ARM assembly code can be run (at least in principle) on Android phones as well as on Raspberry Pi’s. Turns out that it is actually quite easy to do so, and the code seems to run with little problems. I found a good tutorial to do so at Uri Shaked’s blog.

After compiling my Snake Game with the NDK libraries and pushing it to my phone with adb (see instructions in the above link), I run the game using the Termux terminal app. To do so, one must copy the program to Termux home directory so that Termux has the permission to run it.

cp /data/local/tmp/mato .
./mato

A few notes:

  • Systems calls seem to work with same parameters on Android NDK and Raspberry Pi
  • C-dependent libraries don’t work at least out-of-the-box. This means you have to use system calls. Also no “main”, use “_start” as the program entry point.

My GitHub page for the Snake game.

You May Also Like

Leave a Reply

Your email address will not be published.

Note: comments are moderated.