This blog was last modified 428 days before.
Loop
LOOP
is the basic repeat instruction. You can use it like this:
mov cx, 10
mov ax, 0
add_ax_loop:
inc ax
loop add_ax_loop
Notice that CX
is used implicitly.
The code below is actually equals to:
mov cx, 0
mov ax, 0
mov bx, 10
add_ax_loop:
inc ax
dec bx
cmp ax, bx
jne add_ax_loop
You can find out that the code using LOOP
is more succinct, and more important, it could help you save one register.
Repeat
There are several avaiable repeat instruction:
-
REP
Repeat following chain instructionCX
times. -
REPE
REPNE
Repeat following chain instruction untilEF==1
(EF<>1
), maximumCX
times. -
REPZ
REPNZ
Similar to above.
However the usage of RET
is limited, which, based on 8086 CPU Manual, would only availible to the "string" instructions.
Anyway open your emulator and try it out yourself!
No comment