read this promgram,please



what does " shl si,1 add si,di" do?


;search_half_ex5_9
;search an ordered in the extra segment for the word
;value contained in ax
;inputs:es:di=starting address of the list
;first location=length of list(words)
;results:if the value is in the list,
;cf=0
;si=offset of matching element
;if the value is not in the list
;cf=1
;si=offset of last element compared.
dseg segment
low_idx dw ?
high_idx dw ?
dseg ends

cseg segment
b_search proc near
assume cs:cseg,ds:dseg,es:dseg
push ds
push ax
push ax,dseg
mov ds,ax
pop ax
cmp ax,ex:[ds+2]
ja chk_last
lea si,es:[di+2]
je exit
stc
jmp exit
chk_last:
mov si,es:[di]
shl si,1
add si,di
cmp ax,es:[si]
jb search
je exit
stc
jmp exit
search:
mov low_idx,1
mov bx,es:[di]
mov high_idx,bx
mov bx,di
mid: mov cx,low_idx
mov dx,high_idx
cmp cx,dx
ja no_match
add cs,dx
shr cx,1
mov si,cx
shl si,1
compare:cmp ax,es:[bx+si]
je exit
ja higher
dec cx
mov high_idx,cx
jmp mid
higher: inc cx
mov low_idx,cx
jmp mid
no_match:stc
exit: pop ds
ret
bsearch endp
cseg ends
end

.



Relevant Pages

  • Re: Fastcode PosIEx B&V 1.1.1
    ... I2, SubStrLength, StrLength: Integer; ... Exit; ... mov edi,edx ...
    (borland.public.delphi.language.basm)
  • [2] Lock-free questions ...
    ... {$IFDEF FreePascal} ... MOV EDI, sNum32 ... JMP @@EXIT; ... JMP @@EXIT ...
    (comp.programming.threads)
  • Re: simple read char app return wrong value?
    ... We know that sys_read doesn't return until the user hits "enter" (We would prefer, perhaps, that it did. ... If we need to "flush" some, we read into a different buffer, one at a time, until we find the "enter" key. ... Rather than return the number of bytes read, I've modified the program to return (as an exit code) the character entered. ... mov ecx, the_char; input array ...
    (alt.lang.asm)
  • Re: Fastcode PosIEx B&V 1.1.1
    ... jle @Exit ... mov ebp, ... cmp ebp, ... movzx eax, ...
    (borland.public.delphi.language.basm)
  • Re: Eliminating rather unpredictable compares
    ... > mov eax, ... > cmp eax, ... > jne @exit ...
    (comp.lang.asm.x86)