# While: Example 1 Our first example has a simple condition. In Pep/8 ```While: Example 1
Our first example has a simple condition.
input(N);
while (N &lt; 99)
{
output(N);
input(N);
}
In Pep/8 this might be
top:
skip:
deci
lda
cpa
brge
deco
deci
br
N,d
N,d
99,i
skip
N,d
N,d
top
; sets bits according to value of N
; check condition
; skip loop if N &gt;= 99
; new value for N
; back to test loop condition
While: Example 2
Our second example has two relational and one logical operator.
input(N);
while (N &gt; 6 &amp;&amp; N &lt;= 10)
{
sum += N;
input(N);
}
In Pep/8 this might be
top:
skip:
deci
lda
cpa
brle
cpa
brgt
sta
br
N,d
N,d
6,i
skip
10,i
skip
sum,d
sum,d
top
;
;
;
;
;
sets bits according to value of N
check first part of condition
branch if N &lt;= 6 – no need to check N&lt;=10
note - no need to reload N
skip the loop if N &gt; 10
; sum += N
While: Example 3
Another example (this time with an “or” connector) is
while (A &gt; 2 || B &lt; 7)
{
input(A,B);
output(A+B);
}
In Pep/8 this might be
top: lda
cpa
brgt
lda
cpa
brge
loop:deci
deci
lda
sta
deco
br
skip:
A,d
2,i
loop
B,d
7,i
skip
A,d
B,d
A,d
B,d
-2,s
-2,s
top
; first clause is true so don’t need to check second
; if second clause is also false, don’t do loop
; get two numbers
; use stack for scratch space
; output sum of inputs
```