Shop OBEX P1 Docs P2 Docs Learn Events
simple ide c inline asm waitcnt problem — Parallax Forums

simple ide c inline asm waitcnt problem

Mart1970Mart1970 Posts: 23
edited 2014-09-04 00:26 in Propeller 1
First hello to everybody.
Iam trying to make the inline asm waitcnt to work.
But whate i do it's seems to stay in a delay off 1 second.

code:

while(1)
{
int time;
unsigned int delay;
__asm__("mov r1, #0xff\n\t"
"shl r1, #16\n\t"
"or dira, r1\n\t"
"or outa, r1\n\t"
"rdlong r2, #0\n\t"
"add r2, cnt\n\t"
"waitcnt r2, %[delay]\n\t"
"andn outa, r1\n\t"
"strloop:"
"rdlong r2, #\n\t"
"add r2, cnt\n\t"
"waitcnt r2, %[delay]\n\t"
"or outa, r1\n\t"
"if_nz brs #strloop\n\t"
:


: /*inputs */
[delay] "r" (delay),
[time] "r" (time)
);



}

Hope someone can help me .
Thanks

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2014-09-04 00:26
    You tell it to always wait one second. waitcnt dst, src itself waits for dst (cnt + clkfreq in your case) then - after unblocking - adds src to dst. If you want to change that delay should be involved in the initial target calculation, e.g.
    mov     r2, delay
    add     r2, cnt
    waitcnt r2, #0           ' target is cnt + delay
    
Sign In or Register to comment.