What's with WAITX WC? (and also why MOVD-->SETD?)

RaymanRayman Posts: 10,071
edited 2019-12-04 - 17:52:53 in Propeller 2
I'm trying to decipher this instruction on the spreadsheet when Wx is specified...

Looks like it adds RND (I assume this means a random 32-bit number) to D.
First of all, why add D? Wouldn't that make no difference to the outcome?

Secondly, what good is this?
Wouldn't it have been better if D specified a right shift in RND up to 31 bits?

And, in a completely unrelated question:
Why did we (meaning Chip) change MOVD instruction name to SETD?

Comments

  • WAITX doesn't actually do a +2 addition, that's just representative of the base execution time before any waiting has occurred. Yep, a right shift of RND could have been done when Wx set, an AND is cheaper in logic though.
  • If Wx is specified WAITX waits (D & RND) cycles. In other words you can specify a wait of a random number of cycles. "WAITX #$F WC" will wait between 0 and 15 cycles (well actually between 2 and 17 cycles, because the WAITX instruction itself takes 2 cycles). Waiting a random amount of time could be pretty useful in situations where multiple cogs are trying to access the same resource; otherwise if they're all waiting in lockstep with the same delays then you can end up in some bad situations where one or more cogs are starved.
  • Random wait is also useful in situations where you don't want to leak secret data through timing (since different data->different code path->different timing).
  • RaymanRayman Posts: 10,071
    edited 2019-12-04 - 20:05:48
    Ok, I see now, it's a bitwise "and"... I was thinking addition...
    That makes sense...
Sign In or Register to comment.