Haodong Wang wrote:
Here is
the code doing 1million times of multiplications, I expected it finishes
in a couple seconds. However, it seems there is an infinite loop, and
it never ends. Did I do anything wrong?
...
register uint16_t a1 = 1;
register uint16_t a2 = 2;
asm volatile (
" mov #1000, r15 \n"
" LPI: mov #1000, r14 \n"
" LPJ: mov %0, &0x0130 \n"
" mov %1, &0x0138 \n"
" mov &0x013a, %0 \n"
" mov &0x013c, %1 \n"
" inc %0 \n"
" inc %1 \n"
" dec r14 \n"
" jnz LPJ \n"
" dec r15 \n"
" jnz LPI \n"
:"+r"(a1), "+r"(a2)
:
);
you cannot just use registers at will, like you do with r15/r14. the
compiler may decide to use these to pass a1 and a2 (that is probably the
case and the root of your problem)
i think you can use the third ':' parameter ("clobbers") to declare
registers you want to use.
or you simply allocate local variables b1, b2 and pass them like you did
it for a1 and a2. and use them for you loop counters
chris