read this promgram,please
- From: spamtrap@xxxxxxxxxx
- Date: 23 Oct 2006 15:44:06 -0700
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
.
- Follow-Ups:
- Re: read this promgram,please
- From: Tim Roberts
- Re: read this promgram,please
- From: Dirk Wolfgang Glomp
- Re: read this promgram,please
- Prev by Date: Trouble understanding FPREM1 in HLA
- Next by Date: Re: Trouble understanding FPREM1 in HLA
- Previous by thread: Trouble understanding FPREM1 in HLA
- Next by thread: Re: read this promgram,please
- Index(es):
Relevant Pages
|