First page Back Continue Last page Overview Graphics

Looping: while


C language code for a while loop:
//count how many 10’s are there in positive number value
//index is the counter
index = 0;
while(value > 0)
value = value - 10;
In the while example a test is performed at the beginning of the loop. If the test condition is false, the code jumps out of the loop. The last statement in the loop is an unconditional branch back to the start of the loop. The ble (branch if less than or equal to zero) instruction performs a two’s complement test.