Compile assembler for Android using NDK

Issue

I’m trying to compile some given assembler files (.S) for Android using the NDK. Unfortunately I’m getting the same error for each line: Error: bad instruction

Extract of the code:

#define FLAG_C 70(%ebx)

lsr_carry:
    cmpb    $32, %cl
    jae lsr_carry_32
    testb   %cl, %cl
    je  lsr_carry_zero
    shrl    %cl, %eax
    setc    FLAG_C
lsr_carry_zero:
    ret
lsr_carry_32:
    jne ls_carry_33
    shll    $1, %eax
    setc    FLAG_C
    xorl    %eax, %eax
    ret
ls_carry_33:
    xorl    %eax, %eax
    movb    %al, FLAG_C
    ret

I think I havent understood the basics of assembler programming. Does anyone can help me?

Solution

You’re trying to compile x86 code. Most Android devices run on ARM and the public NDK compiles only for ARM.

Answered By – Igor Skochinsky

Leave a Comment