#includbe<LPC17xx.h>
int main() MOVS r2,#0x0F
{ MOVS r3,#0x00
unsigned int a,b,c,i; MOVS r0,#0x00
a=15; B LOOP1
b=0; LOOP2 LSR r1,r2,r0
for(i=0;i<32;i++) TST r1,#0x01
{ BEQ LOOP3
c = a >> i; ADDS r3,r3,#1
if( c & 0x01 ) LOOP3 ADDS r0,r0,#1
b=b+1; LOOP1 CMP r0,#0x20
} BCC LOOP2
while(1); LOOP4 B LOOP4
}
2. Binary Sequence
000000001
000000010
000000100
..
...
100000000
000000000
a=1;
for(i=0;i<32;i++)
a=a<<1;
3. If statement
if(a>b)
{
Body of the condition statement
}
a=a>>12;
CMP r0,r1
BLS LOOP1
;; Body of the condition statement
LOOP1 LSRS r0,r0,#12
if(a>b)
{ Body of the true condition statement
}
else
{ Body of the false condition statement
}
a=a*50;
CMP r0,r1
BHI loop1
;;;Body of the true condition statement
----------------------------------------
B loop2
loop1 ;;;Body of the false condition statement
----------------------------------------
loop2 MOV r3,#0x32
MULS r0,r3,r0
if((a<=b)&&(a>=c))
{ Body of the true condition statement
}
else
{ Body of the false condition statement
}
a=a*50;
CMP r0,r1
BHI loop1
CMP r0,r2
BCC loop1
;;;Body of the true condition statement
----------------------------------------------
B loop2
loop1 ;;;Body of the false condition statement
----------------------------------------
loop2 MOV r3,#0x32
MULS r0,r3,r0
if((a<=b)||(a>=c))
{ Body of the true condition statement
}
else
{ Body of the false condition statement
}
a=a*50;
CMP r0,r1
BLS loop3
CMP r0,r2
BCC loop1
loop3 ;;;Body of the true condition statement
----------------------------------------------
B loop2
loop1 ;;;Body of the false condition statement
----------------------------------------
loop2 MOV r3,#0x32
MULS r0,r3,r0
6. For loop
for(c=0;c<30;c++)
{
Body of the loop
}
a=a*50;
MOVS r1,#0x00
B loop1
loop2 ;;;;; body of the loop
ADDS r1,r1,#1
loop1 CMP r1,#0x1E
BCC loop2
MOV r3,#0x32
MULS r0,r3,r0
7. While loop
int a=30;
while(a>0)
{
a=a-1;
}
8. Do while loop
int a=30;
do
{
a=a-1;
}while(a>0);