Forum Discussion
Altera_Forum
Honored Contributor
15 years agoPorting PIO C-code from ARM-7 to Nios II (SE1-board) + performance issue.
Hi all, I'm having a try at the moment to port my C-code from the arm-7 mcu, LPC-P2148 to Nios II, SE1-board , Cyclon-II, EP2C20F484C7. The arm-none-eabi-gcc compiler was used for the ARM-7 ...
Altera_Forum
Honored Contributor
15 years agoActually the compiler will transform the loop you gave into:
if (wait != 0) {
do
wait = wait - 1;
while (wait != 0);
}Depending on the code layout the first conditional might get optimised for the 'wait == 0' case. You get better code from a do ... while () loop. So you want while (--wait); However, for the example code, the compiler knew the value of the constant, so won't have compiled the initial test.