bt byte ptr [esp + eax], ebx;
bt byte ptr [esp + eax], ebx;
xor eax, eax; // prepare to return false
pushad; // save all registers
mov esi, edx; // esi = pointer to input list
xor ebx, ebx; // ebx = previously encountered number = 0
xor edx, edx; // edx = bitmap of visited numbers = 0
cmp cl, 2; // is input list too short?
jb bad_no_pop; // bad!
again:
lodsd; // read one number
push eax;
bts edx, eax; // check and update the bitmap
jc bad; // same number twice? - bad!
cmp eax, ebx; // sort two recent numbers (ebx = minimum)
ja skip1;
xchg eax, ebx;
skip1:
// Check whether the line crosses a node
sub eax, ebx; // calculate half the difference
shr eax, 1;
jc skip_cross; // odd difference? - no node in the middle
dec eax;
push 0x020e0892;// push magic bitmap onto stack
bt byte ptr [esp + eax], ebx; // is there a node in the middle?
pop edi;
jnc skip_cross; // no - skip the check
add ebx, eax; // calculate the node in the middle
inc ebx;
bt edx, ebx; // was it visited?
jnc bad; // no - bad!
skip_cross:
pop ebx;
loop again;
// The loop was finished normally - return true
popad; // restore registers
inc eax; // change 0 to 1
ret; // return
// Return false
bad:
pop eax; // discard data on stack
bad_no_pop:
popad; // restore registers
ret; // return
xor eax, eax; // prepare to return false
pushad; // save all registers
mov esi, edx; // esi = pointer to input list
xor ebx, ebx; // ebx = previously encountered number = 0
xor edx, edx; // edx = bitmap of visited numbers = 0
cmp cl, 2; // is input list too short?
jb bad_no_pop; // bad!
again:
lodsd; // read one number
push eax;
bts edx, eax; // check and update the bitmap
jc bad; // same number twice? - bad!
cmp eax, ebx; // sort two recent numbers (ebx = minimum)
ja skip1;
xchg eax, ebx;
skip1:
// Check whether the line crosses a node
sub eax, ebx; // calculate half the difference
shr eax, 1;
jc skip_cross; // odd difference? - no node in the middle
dec eax;
push 0x020e0892;// push magic bitmap onto stack
bt byte ptr [esp + eax], ebx; // is there a node in the middle?
pop edi;
jnc skip_cross; // no - skip the check
add ebx, eax; // calculate the node in the middle
inc ebx;
bt edx, ebx; // was it visited?
jnc bad; // no - bad!
skip_cross:
pop ebx;
loop again;
// The loop was finished normally - return true
popad; // restore registers
inc eax; // change 0 to 1
ret; // return
// Return false
bad:
pop eax; // discard data on stack
bad_no_pop:
popad; // restore registers
ret; // return