Assuming that this high-level language does not contradict C, you can use the arm C compiler to create assembly code from your fragment. For example, if test.c has the following:
void test() { register int i asm("r0"); register int *a asm("r8"); register int *b asm("r9"); register int *c asm("r10"); for (i = 0; i < 10000; i++) { a[i] = b[i] + c[i]; } }
you can run
arm-linux-androideabi-gcc -O0 -S test.c
to create a test.s file that will contain the assembly code for your test function, as well as some additional materials. You can see how your loop was compiled into the assembly below.
<snipped> .L3: mov r2, r8 mov r3, r0 mov r3, r3, asl #2 add r3, r2, r3 mov r1, r9 mov r2, r0 mov r2, r2, asl #2 add r2, r1, r2 ldr r1, [r2, #0] mov ip, sl mov r2, r0 mov r2, r2, asl #2 add r2, ip, r2 ldr r2, [r2, #0] add r2, r1, r2 str r2, [r3, #0] mov r3, r0 add r3, r3, #1 mov r0, r3 .L2: mov r2, r0 ldr r3, .L5 cmp r2, r3 ble .L3 sub sp, fp, #12 ldmfd sp!, {r8, r9, sl, fp} bx lr <snipped>
Now the problem with this approach is to trust that the compiler generates the best code for your research, which may not always be the case, but what you get is quick answers to your questions, such as above, not waiting for people :)
- extra -
GCC allows you to put variables in specific registers, see the relevant documentation .
You can get the cheat sheet here .
Newer versions of GCC create better hand code, as expected. The above cut is generated by version 4.4.3, and I can confirm Linaro 4.7.1 confirms my statement. Therefore, if you take my approach, use the latest toolchain you can get.