Compile assembler for Android using NDK
I'm trying to com开发者_如何学Gopile 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?
You're trying to compile x86 code. Most Android devices run on ARM and the public NDK compiles only for ARM.
It appears like you're trying to plug x86 assembly into Android? Most current Android devices are using the ARM architecture, which is a completely different language with entirely different opcodes.
That aside, I would recommend against using Assembly in the first place (well, unless you have existing code that you're trying to port.)
精彩评论