assembly - Binary search ALP -



assembly - Binary search ALP -

i have binary search programme in assembly language. don't understand why statement add si,si used in 1 time again loop.

data segment arr dw 0000h,1111h,2222h,3333h,4444h,5555h,6666h,7777h,8888h,9999h len dw ($-arr)/2 key equ 7777h msg1 db "key found @ " res db " position",13,10," $" msg2 db 'key not found!!!.$' info ends code segment assume ds:data cs:code start: mov ax,data mov ds,ax mov bx,00 mov dx,len mov cx,key again: cmp bx,dx ja fail mov ax,bx add together ax,dx shr ax,1 mov si,ax add together si,si cmp cx,arr[si] jae big dec ax mov dx,ax jmp 1 time again big: je success inc ax mov bx,ax jmp 1 time again success: add together al,01 add together al,'0' mov res,al lea dx,msg1 jmp disp fail: lea dx,msg2 disp: mov ah,09h int 21h mov ah,4ch int 21h code ends end start

in loop, ax assigned index of element in array, , index moved si.

the array declared arr dw .... w in dw stands word, each element in array word, 2 bytes on x86 platforms. therefore, need multiply index 2 before using read array. that's add si,si (si + si == si * 2).

search assembly binary x86

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -