The following program contains a loop that counts up by 1 cl

The following program contains a loop that counts up by 1: clr r10 Loop: inc r10 rjmp Loop Program: Create a similar program that counts up by the even numbers (i.e. 0, 2, 4, 6, 8, ...)

Solution

Solution-

clr r10 ; Clear content of r10

Loop:

inc r10 ; increase value of r10 by 1 ie r10 = r10 + 1

rjump Loop ; jump to loop

This will give result 0, 1, 2, 3, 4, 5. 6........

Thus to get 0 , 2 , 4, 6, 8...... value of r10 must be increased by 2.

clr r10 ; Clear content of r10

Loop:

ADI r10, 02H ; Add imediate by 02 ie r10 = r10 + 02

rjump Loop ; jump to loop

 The following program contains a loop that counts up by 1: clr r10 Loop: inc r10 rjmp Loop Program: Create a similar program that counts up by the even numbers

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site