Forum Discussion
Altera_Forum
Honored Contributor
15 years ago --- Quote Start --- So you want while (--wait); --- Quote End --- That one does the really long wait for a value of zero, which might be what is wanted. I'll get around to looking at NIOS code for these eventually. I tested this on several CISC processors and also HiTech C on several varieties of PIC RISC. For short int, I know the CISCs had a one instruction 'decrement, branch if non-zero'. I think the PIC did too (long time ago now, so I may be mixing my memories), but for whatever reason, the while(var--) did a 1 CPU cycle per count, + overhead. The while(--var) was probably the same except for no short-cut exit. Other variations took significantly longer. NIOS might be different. Either way, the biggest reduction was selecting the processors register size as the variation of the 'int' to use for the counter. Equal variable sizes on processors with different sized registers isn't a fair test.