1) What is Loop in Assembly Language 8086? Explain Loop with at least two examples in assembly language using emu8086.
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
Comments
Leave a comment