mov r1,0 // sometimes, xor r1,r1 needs less program space and/or time mov r2,N loop: // do something with r1 inc r1 // may or may not set flags, depending on the implementation cmp r1,r2 // often imlemented as sub r1,r2 but without actually writing the result back to the register, just setting flags jne loop // if implemented as sub r1,r2, jne (jump if not rqual) is equal to jnz (jump if not zero)