Answer to Question #285685 in Assembler for Ahmed Ali

Question #285685

1) What is Loop in Assembly Language 8086? Explain Loop with at least two examples in assembly language using emu8086.


1
Expert's answer
2022-01-09T02:21:15-0500

The jmp instruction can be used for implementing loops.

The following code can be used for executing the loop-body 10 times

Example:

              MOV      CL, 10

L1:

              <LOOP-BODY>

              DEC        CL

              JNZ         L1

The processor instruction set includes loop instructions for implementing iteration. The LOOP instruction has the following syntax:

Example:

               mov CX,10
l1:
               <loop body>
loop l1

The LOOP instruction assumes that the CX register contains the loop count. When the loop instruction is executed, the ECX register is decremented and the control jumps to the target label, until the CX register value, i.e., the counter reaches the value zero.

Example: ten values from array 1 are written to array 2

           mov cx, 10                              ; counter

           mov si, offset array1

mov di, offset array2

Sum10:

lodsb

           stosb

           loop Sum10




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS