I have trouble with some inline assembly code. I'm trying to load items from local static array into registers on ARM platform. Unfortunately I have no idea how to tell GCC that it should pass pointer on array to register. This register will be used for indirect acess to array.
// should return argv[1]
int test() {
int argv[4] = {4, 3, 2, 1};
int out;
__asm__ volatile (
"ldr r0, %[ARGV]" "\n\t"
"mov r1, #4" "\n\t"
"ldr r2, [r0, r1]" "\n\t"
"mov %[OUT], r2"
: [OUT] "=r" (out)
: [ARGV] "m" (argv) // <==== i don't know which constraint put here :/
: "r0", "r1", "r2"
);
return out;
}
Now the GCC throw error and I have no idea how to fix it:
Assembler messages:
Error: invalid offset, value too big (0xFFFFFFFC)
Thx
EDIT: I have compiled it with Android NDK (arm-linux-androideabi-g++)
argv
to"rm"
instead? – mattjgallowayint i_argv = (int)argv;
) and pass i_argv instead of argv and it working! But i don't think this is a solution. It's only a hack :/ – zdenek