The following code will multiply the contents of the registers ecx
and edx
and store the result in register eax
. The content of the registers ebx
and edx
is destroyed:
mov ebx, 1
mov eax, 0
repeat:
test ecx, ebx
jz dontadd
add eax, edx
dontadd:
add edx, edx
add ebx, ebx
jnz repeat
without ... LOOP
If "LOOP" does not only cover the "LOOP" instruction but any conditional jump instructions:
Doing a multiplication without conditional jump instructions is a bit more difficult but not impossible; the following example does so (Input: ecx
and edx
, output eax
, the content of all registers used will be destroyed):
mov ebx, 1
mov eax, 0
not ecx
# Repeat the following code 32 times:
mov esi, ebx
and esi, ecx
dec esi
and esi, edx
add eax, esi
add edx, edx
add ebx, ebx
# (repeat the code here)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…