Please tell me can we use any other register rather then CX with loop instruction like ....

.........................................
mov ax, 10          ; didn't use cx

again:  any code here

loop again

.........................................
Posted on 2008-06-18 04:28:32 by souch

Please tell me can we use any other register rather then CX with loop instruction like ....

.........................................
mov ax, 10          ; didn't use cx

again:  any code here

loop again

.........................................


There was no reason to post a poll for this type of question.

The LOOP instruction, as defined in the Intel/AMD manuals, expects to use CL/CX/ECX/RCX for the respective LOOP instruction.

However, LOOP has a reputation for being slower than it should be. If you want to replicate LOOP-like functionality with relatively the same efficiency, look into using a DEC/JNZ combination... in which will be compatible with any of the General Purpose Registers.
Posted on 2008-06-18 04:53:23 by SpooK
Spook is right. You can use

test eax, eax
jnz again


or any register to replace eax.
Posted on 2008-06-19 07:06:20 by roticv