previous | start | next

IA32 Assembler for: loop statements (1)

int sumFirst(int n)
{
  int sum = 0;
  while(n > 0) {
    sum += n;
    n--;
  }
  return sum;
}

There is no instruction that directly implements 'while' in IA32.

The instructions available are the same form as used for 'if statements':

  compare ...
  if ( result ) goto Label  // conditional jumps
  goto Label                // unconditional jumps


previous | start | next